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

Cache kinematics and dynamics computations in JaxSimModelData #340

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

flferretti
Copy link
Collaborator

@flferretti flferretti commented Jan 15, 2025

This PR aims to improve the performances by caching computations and simplifying the codebase.

The class JaxSimModelData will have two additional attributes:

  • _kin_dyn: private attribute to store the kyndyn computations
  • _kin_dyn_stale: the cache invalidation flag

The class KynDynComputation inherits from common.ModelDataWithVelocityRepresentation, so it will have its own velocity_representation attribute, which will be useful for performing the conversions.

The kinematics and dynamics computations will be accessible via a property of JaxSimModelData, through KynDynProxy which is a proxy class that ensures that the attributes of KynDynComputation are set and returned in the correct velocity representation.

The value of the cache invalidation flag JaxSimModelData._kyn_dyn_stale is set to True when any reset_* method is called. For this reason, a RuntimeError will be raised if the user tries to access to the invalidated cache. At this scope, the update_kyn_dyn method would set the cache invalidation flag to False and update the _kyn_dyn attribute.


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

@flferretti flferretti self-assigned this Jan 15, 2025
@flferretti flferretti force-pushed the save_intermediate_quantities branch from 3725aed to 0e79852 Compare January 15, 2025 15:53
@flferretti flferretti force-pushed the save_intermediate_quantities branch from 0e79852 to dc458fa Compare January 15, 2025 16:07
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.

1 participant