Cache kinematics and dynamics computations in JaxSimModelData
#340
+1,008
−1,069
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 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 flagThe class
KynDynComputation
inherits fromcommon.ModelDataWithVelocityRepresentation
, so it will have its ownvelocity_representation
attribute, which will be useful for performing the conversions.The kinematics and dynamics computations will be accessible via a property of
JaxSimModelData
, throughKynDynProxy
which is a proxy class that ensures that the attributes ofKynDynComputation
are set and returned in the correct velocity representation.The value of the cache invalidation flag
JaxSimModelData._kyn_dyn_stale
is set toTrue
when anyreset_*
method is called. For this reason, aRuntimeError
will be raised if the user tries to access to the invalidated cache. At this scope, theupdate_kyn_dyn
method would set the cache invalidation flag toFalse
and update the_kyn_dyn
attribute.📚 Documentation preview 📚: https://jaxsim--340.org.readthedocs.build//340/