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

Split static and dynamic contact params #257

Merged
merged 3 commits into from
Oct 7, 2024

Conversation

diegoferigo
Copy link
Member

@diegoferigo diegoferigo commented Oct 7, 2024

This PR introduces the support to separate contact parameters in two categories:

  • The static parameters are stored in the contact model class. A vectorized computation must share the same static parameters.
  • The dynamic parameters are stored in the contact parameters class. These parameters are copied in JaxSimModelData and the user logic can change them during runtime (assuming that the corresponding PyTree remains compatible). These are also the types of parameters over which AD can be performed.

This separation is necessary when the computation of contact forces operates over a JIT primitive that requires a static argument (e.g. fixing the number of iterations of an iterative solver by converting a while loop to a for loop).


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

@diegoferigo diegoferigo self-assigned this Oct 7, 2024
@diegoferigo diegoferigo force-pushed the split_static_and_dynamic_contact_params branch 2 times, most recently from cede54f to 7bbe3c7 Compare October 7, 2024 09:55
@diegoferigo diegoferigo marked this pull request as ready for review October 7, 2024 09:57
@diegoferigo diegoferigo requested a review from xela-95 October 7, 2024 09:57
Copy link
Member

@xela-95 xela-95 left a comment

Choose a reason for hiding this comment

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

Thanks @diegoferigo !! LGTM! 🚀

@traversaro
Copy link
Contributor

Just to mention something related to naming: sometimes (especially in modelling community, like Modelica/FMI/Simulink/Julia's ModellingToolkit) paramters that can be changed during the simulation are called "tunable parameters", see:

This is to avoid ambiguity between the system dynamics state and "dynamics parameters".

@diegoferigo
Copy link
Member Author

Just to mention something related to naming: sometimes (especially in modelling community, like Modelica/FMI/Simulink/Julia's ModellingToolkit) paramters that can be changed during the simulation are called "tunable parameters", see:

* https://fmi-standard.org/docs/3.0.1/#_variable_attributes

* https://it.mathworks.com/help/sldrt/ug/tune-block-parameters-and-matlab-variables.html

* https://discourse.julialang.org/t/automatic-differentiation-with-subset-of-parameters-in-modelingtoolkit/85917

This is to avoid ambiguity between the system dynamics state and "dynamics parameters".

It makes sense, thanks for pointing this out @traversaro. JAX has the concept of static function arguments, and I used the term dynamic as its dual. However, I agree that it may cause confusion. With your suggestion, we can name these dynamic parameters (in JAX terms) as tunable parameters.

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.

Thanks a lot!

@diegoferigo diegoferigo force-pushed the split_static_and_dynamic_contact_params branch from 7bbe3c7 to 49eadf0 Compare October 7, 2024 10:56
@diegoferigo diegoferigo enabled auto-merge October 7, 2024 10:57
@diegoferigo diegoferigo merged commit b7e2fee into main Oct 7, 2024
24 checks passed
@diegoferigo diegoferigo deleted the split_static_and_dynamic_contact_params branch October 7, 2024 11:12
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.

4 participants