RSDK-13982 - construct model table from urdf#645
Conversation
|
Mentioned this in the previous PR but I'm not convinced we need Eigen? I would be in favor of reusing |
lia-viam
left a comment
There was a problem hiding this comment.
lgtm, try running bin/run_clang_format.sh if linter still isn't passing
acmorrow
left a comment
There was a problem hiding this comment.
This looks good, I have some comments to consider though.
| 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) |
There was a problem hiding this comment.
Is this still true? Ditto below?
|
|
||
| /// @brief One row of the model table: the per-joint URDF fields. | ||
| /// @note `xyz`/`rpy`/`axis` are taken directly from the URDF. | ||
| struct JointRow { |
There was a problem hiding this comment.
You could put JointType in here, so you had JointRow::[T|t]ype::k_[revolute,continuous,prismatic,fixed].
There was a problem hiding this comment.
I am not a fan of this.
It feels like there is less cognitive overhead with keep it this way.
edit: and with your proposal the jointtype is hidden one level deeper right?
There was a problem hiding this comment.
I think it comes down to this question: Is JointType something intrinsically useful, or is it just a discriminator to understand how to interpret the fields of JointRow. If it is intrinsically valuable, then I'm more OK with making it a top-level type on its own. If it is just the descriminator for JointRow, I'd be in favor of nesting it.
There was a problem hiding this comment.
FYI now that they are both at least in ModelTable I'm less inclined to push JointType into JointRow though I do think the argument holds.
I'm resisting the urge to say that JointRow should be some sort of variant, because if I see it correctly, the only real structural variant is for the fixed case.
| if (row.type == JointType::fixed) { | ||
| row.axis = Vector3{0, 0, 0}; | ||
| } else if (parsed.axis_opt) { | ||
| if (magnitude(*parsed.axis_opt) < 1e-12) { |
There was a problem hiding this comment.
Why this value and not some other?
…0514-RSDK-13982-construct-model-table
60f7024 to
57560da
Compare
acmorrow
left a comment
There was a problem hiding this comment.
Similar thoughts as the UR Arm review about pushing harder to make these classes, rather than structs with helper functions.
| k_prismatic = 2, | ||
| k_fixed = 3, | ||
| }; | ||
|
|
There was a problem hiding this comment.
Are there any connections between the set of possible values of these vectors, and the types of joints?
You could consider adding static factory methods on JointRow, like JointRow::fixed(std::string name, ...).
There was a problem hiding this comment.
xyz and rpy just tell us the position and orientation of "things", eg. links.
axis is our biggest hint here.
If it's (0, 0, 0) then we can deduce that it's a fixed joint with certainty.
But on the other hand if it's a non-zero unit vector we do not have a way of knowing if the joint type is revolute, continuous or prismatic.
|
|
||
| /// @brief One row of the model table: the per-joint URDF fields. | ||
| /// @note `xyz`/`rpy`/`axis` are taken directly from the URDF. | ||
| struct JointRow { |
| @@ -0,0 +1,43 @@ | |||
| /// @file referenceframe/private/kinematics_model_table_internals.hpp | |||
There was a problem hiding this comment.
I don't think you should doc comment it if it is under private, since otherwise doxygen docs will I think end up picking it up, even though consumers of the SDK can't use it.
There was a problem hiding this comment.
You still ahve the rest of this file doc commented though.
It should be easy, just change /// to //
There was a problem hiding this comment.
Sorry a bit confused by this: in the current version of the code I just removed all the lines which were prefixed with : ///
…m:nfranczak/viam-cpp-sdk into 20250514-RSDK-13982-construct-model-table
| @@ -0,0 +1,43 @@ | |||
| /// @file referenceframe/private/kinematics_model_table_internals.hpp | |||
There was a problem hiding this comment.
You still ahve the rest of this file doc commented though.
It should be easy, just change /// to //
|
|
||
| /// @brief One row of the model table: the per-joint URDF fields. | ||
| /// @note `xyz`/`rpy`/`axis` are taken directly from the URDF. | ||
| struct JointRow { |
There was a problem hiding this comment.
FYI now that they are both at least in ModelTable I'm less inclined to push JointType into JointRow though I do think the argument holds.
I'm resisting the urge to say that JointRow should be some sort of variant, because if I see it correctly, the only real structural variant is for the fixed case.
| /// @brief URDF joint type, restricted to arm-relevant joints. | ||
| /// @note Underlying values are stable and form the wire encoding for | ||
| /// column 9 of the tensor produced by `to_tensor()`. | ||
| enum class JointType { |
There was a problem hiding this comment.
I suspect the linter is going to want you to give this a smaller integral type.
There was a problem hiding this comment.
A bit confused by this, the linter did not complain.
There was a problem hiding this comment.
OK, maybe we don't do that anymore.
…0514-RSDK-13982-construct-model-table
lia-viam
left a comment
There was a problem hiding this comment.
mostly minor/optional stuff but still lgtm
| std::vector<ParsedJoint> parse_urdf(const KinematicsDataURDF& urdf) { | ||
| namespace pt = boost::property_tree; | ||
| pt::ptree tree; | ||
| const std::string text(reinterpret_cast<const char*>(urdf.bytes.data()), urdf.bytes.size()); |
| row.xyz = parsed.xyz; | ||
| row.rpy = parsed.rpy; | ||
|
|
||
| if (parsed.type_str == "revolute") { |
There was a problem hiding this comment.
I wonder if we want a public to_string or joint_type_from_string ?
There was a problem hiding this comment.
I am not convinced that we need a public to_string or joint_type_from_string.
My reasoning is that users always get a parsed JointType values values via from(urdf) / from(tensor) and never see the strings.
The to_string has no user anywhere in this flow.
| xt::xarray<double> out = xt::zeros<double>({rows_.size(), std::size_t{10}}); | ||
| for (std::size_t i = 0; i < rows_.size(); ++i) { | ||
| const auto& r = rows_[i]; | ||
| out(i, 0) = r.xyz.x(); |
There was a problem hiding this comment.
I don't love this but struggling to come up with an alternative
int idx = 0;
for (const auto& vec3 : {std::cref(r.xyz), std::cref(r.rpy), std::cref(r.axis)}) {
for (const auto& val : arr.data) {
out(i, idx++) = val;
}
}honestly not sure if this is preferable, your call
There was a problem hiding this comment.
while more compact/abstract, I think that what we have now is slightly clearer to read.
There was a problem hiding this comment.
in that case maybe just a line break between the blocks where you're operating on the different vec3's
| /// @brief URDF joint type, restricted to arm-relevant joints. | ||
| /// @note Underlying values are stable and form the wire encoding for | ||
| /// column 9 of the tensor produced by `to_tensor()`. | ||
| enum class JointType { |
There was a problem hiding this comment.
OK, maybe we don't do that anymore.
| namespace sdk { | ||
| namespace impl { | ||
|
|
||
| /// @brief Per-joint parse result, pre-validation. |
There was a problem hiding this comment.
Here, for instance, there is still a doxygen style comment on an internal header.
There was a problem hiding this comment.
ok I can change.
does that mean that this for example is incorrect?
https://github.com/viamrobotics/viam-cpp-sdk/blob/main/src/viam/sdk/rpc/private/viam_grpc_channel.hpp#L14
as follow up will do sva