Add utilities to handle SDF models as a directed trees #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a number of new features, all targeted to be used as utilities for processing a
rod.Model
as a tree. Some of the feature below or future features are taken fromjaxsim.parsers
, that could be replaced in the future by these newrod
features.1. Creating directed trees
Although SDFormat supports closed kinematic loops / parallel robots (example),
rod
currently doesn't, as by the way also URDF. Excluding these particular families of kinematics, any robot model could be modelled as a directed tree (i.e. an oriented Direct Acyclic Graph with nodes restricted to have just one parent).In our directed tree:
Furthermore, in order to support SDF frames, we also allow attaching extra elements to both links and joints.
2. Computing forward kinematics
The new
TreeTransforms
class allows to compute the forward kinematics of links, frames, and joints. The pose of these elements can be expressed wrt any other element part of therod.Model
.Currently this FK is meant to be used just for performing computations on the kinematic tree, that means that we consider all joints having a zero positions. This limitation will be removed in future PRs.
3. Resolving frames
A SDF model could have either explicit or implicit frames. To ease processing, this PR introduces a resolve_model_frames helper that adds to all elements of the model an explicit pose.
4. Switching frame convention
Partially related to feature 3, SDF has its own default convention of implicit frames when either the pose element is missing or the
relative_to
attribute is not set. This PR introduces aswitch_frame_convention
helper that updates all transforms following different frame conventions:Sdf
: converts allrod.Pose
elements to use the default reference frames of SDFModel
: converts allrod.Pose
elements to be expressed wrt their parent model (__model__
)World
: converts allrod.Pose
elements to be expressed wrt the world frameUrdf
: converts allrod.Pose
elements to be expressed wrt the equivalent defaults used in URDFThis is particularly useful especially for the last convention, for example if in the future we want to convert a deserialized SDF to URDF since serializing the XML having already the correct poses would be pretty easy.
Future work
This PR is already useful as it is and I propose to merge it with these features that are already too many. Future PR will address some features left out:
Footnotes
could be taken from
jaxsim.parser.descriptions.LinkDescription.lump_with
like other features of this PR ↩could be taken from
jaxsim.parsers.KinematicGraph.reduce
↩