Skip to content

RSDK-13982 - construct model table from urdf#645

Open
nfranczak wants to merge 13 commits into
viamrobotics:mainfrom
nfranczak:20250514-RSDK-13982-construct-model-table
Open

RSDK-13982 - construct model table from urdf#645
nfranczak wants to merge 13 commits into
viamrobotics:mainfrom
nfranczak:20250514-RSDK-13982-construct-model-table

Conversation

@nfranczak
Copy link
Copy Markdown
Member

@nfranczak nfranczak commented May 20, 2026

as follow up will do sva

@nfranczak nfranczak requested a review from a team as a code owner May 20, 2026 15:41
@nfranczak nfranczak requested review from lia-viam and njooma and removed request for a team May 20, 2026 15:41
@lia-viam
Copy link
Copy Markdown
Member

Mentioned this in the previous PR but I'm not convinced we need Eigen? I would be in favor of reusing Vector3 from linear_algebra.hpp or an appropriate xtensor type

Copy link
Copy Markdown
Member

@lia-viam lia-viam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, try running bin/run_clang_format.sh if linter still isn't passing

@nfranczak nfranczak requested a review from acmorrow May 26, 2026 19:39
Copy link
Copy Markdown
Member

@acmorrow acmorrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, I have some comments to consider though.

Comment thread conanfile.py Outdated
self.requires(self._grpc_requires())
self.requires('protobuf/[>=3.17.1 <6.30.0]')
self.requires(self._xtensor_requires(), transitive_headers=True)
self.requires('eigen/[>=3.3.0]', transitive_headers=True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still true? Ditto below?

inline bool operator==(const Vector3& a, const Vector3& b) {
return a.data == b.data;
}
inline bool operator!=(const Vector3& a, const Vector3& b) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised the formatter didn't do it for you, but please throw a blank line inbetween these definitions.

namespace sdk {

/// @brief URDF joint type, restricted to arm-relevant joints.
enum class JointType { revolute, continuous, prismatic, fixed };
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be k_revolute, etc.


/// @brief Convert a model table to a double tensor of shape (n, 10).
/// Columns: 0..2 xyz, 3..5 rpy, 6..8 axis, 9 joint type as
/// underlying enum value (0=revolute, 1=continuous, 2=prismatic, 3=fixed).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to do that, I'd suggest giving the JointType enum values matching explicit values.


/// @brief One row of the model table: the per-joint URDF fields.
/// @note `xyz`/`rpy`/`axis` are taken directly from the URDF.
struct JointRow {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could put JointType in here, so you had JointRow::[T|t]ype::k_[revolute,continuous,prismatic,fixed].


namespace viam {
namespace sdk {
namespace urdf_model_table_internals {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elsewhere, where we have had private headers, we have gathered the inner namespace as impl (we can't call it private since that is a keyword). It might be better to stick to that convention.

if (row.type == JointType::fixed) {
row.axis = Vector3{0, 0, 0};
} else if (parsed.axis_opt) {
if (magnitude(*parsed.axis_opt) < 1e-12) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this value and not some other?

for (std::size_t i = 0; i < tensor.shape()[0]; ++i) {
const double type_v = tensor(i, 9);
const int type_i = static_cast<int>(type_v);
if (static_cast<double>(type_i) != type_v || type_i < 0 || type_i > 3) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to compare against the enum values here, not constants.

@nfranczak nfranczak force-pushed the 20250514-RSDK-13982-construct-model-table branch from 60f7024 to 57560da Compare May 29, 2026 20:38
@nfranczak nfranczak requested a review from acmorrow May 29, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants