Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend functional APIs #117

Merged
merged 27 commits into from
Mar 26, 2024
Merged

Extend functional APIs #117

merged 27 commits into from
Mar 26, 2024

Conversation

diegoferigo
Copy link
Member

@diegoferigo diegoferigo commented Mar 22, 2024

This PR extends the functional APIs with a lot of new functions:

  • New jaxsim.api.com module.
  • New jaxsim.api.com.com_linear_velocity function.
  • New jaxsim.api.com.centroidal_momentum function.
  • New jaxsim.api.com.centroidal_momentum_jacobian function.
  • New jaxsim.api.com.locked_centroidal_spatial_inertia function.
  • New jaxsim.api.com.average_centroidal_velocity function.
  • New jaxsim.api.com.average_centroidal_velocity_jacobian function.
  • New jaxsim.api.contact.collidable_point_forces function.
  • New jaxsim.api.contact.collidable_point_dynamics function.
  • New jaxsim.api.link.velocity function.
  • New jaxsim.api.model.locked_spatial_inertia function.
  • New jaxsim.api.model.total_momentum_jacobian function.
  • New jaxsim.api.model.average_velocity function.
  • New jaxsim.api.model.average_velocity_jacobian function.
  • New jaxsim.api.model.link_contact_forces function.
  • New jaxsim.math.transform module.
  • New Adjoint.from_transform method.
  • Added some missing docstrings.
  • Extended tests for new functions.

These are particularly useful for (differentiable) model-based control, especially in centroidal coordinates cc @DanielePucci.

Refer to Traversaro2017a1 and Section 3.9 of Traversaro2017b2 for more details.


📚 Documentation preview 📚: https://jaxsim--117.org.readthedocs.build//117/

Footnotes

  1. Traversaro, Pucci, Nori, A Unified View of the Equations of Motion used for Control Design of Humanoid Robots, 2017 url.

  2. Traversaro, Modelling, Estimation and Identification of Humanoid Robots Dynamics, 2017, url.

Comment on lines 69 to 71
with data.switch_velocity_representation(VelRepr.Mixed):
W_ṗ_G = average_centroidal_velocity(model=model, data=data)[0:3]
return W_ṗ_G
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens for others velocity representation?

Copy link
Member Author

Choose a reason for hiding this comment

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

This method always returns ${}^W \dot{\mathbf{p}}_G$, where $G = ({}^W \mathbf{p}_{\text{CoM}}, [W])$ like iDynTree.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you think that it can be more uniform returning instead ${}^{G[W]}\boldsymbol{v}_{W,G} \in \mathbb{R}^3$ in inertial-fixed and mixed representations, and ${}^{G[B]}\boldsymbol{v}_{W,G} \in \mathbb{R}^3$ in body-fixed? There are some methods in iDynTree (and also here since I maintained the approach) doing that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that could make sense. Anyhow, I was actually confused by the data.switch_velocity_representation, but after checking it out now everything is clear.

Copy link
Member Author

Choose a reason for hiding this comment

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

@traversaro I'm going to merge this PR with jaxsim.api.com.com_linear_velocity always returning ${}^W \dot{\mathbf{p}}_{\text{CoM}}$. We can discuss if it's sound returning something else in body-fixed coordinates in #108.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok!

Copy link
Contributor

Choose a reason for hiding this comment

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

By the way, I looked in iDynTree, and to me it seems that always returning ${}^W \dot{p}_{CoM}$ https://github.com/robotology/idyntree/blob/7e029b963d44fa2606bd608019ba9b82a4398741/src/high-level/src/KinDynComputations.cpp#L1941-L1958 is a bug/inconsistency in iDynTree, that we may want to fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok if this is the intended usage, then I'll update directly this PR instead of doing it in #108.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@traversaro traversaro left a comment

Choose a reason for hiding this comment

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

Minor comments.

Copy link
Collaborator

@flferretti flferretti left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Diego!

@diegoferigo diegoferigo merged commit e1c9175 into functional Mar 26, 2024
21 checks passed
@diegoferigo diegoferigo deleted the extend_functional_apis branch March 26, 2024 14:19
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.

None yet

3 participants