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

Mujoco (implicit) integration does not offer a mechanism to take into account custom passive forces in qDeriv calculation #2433

Open
jjyyxx opened this issue Feb 18, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@jjyyxx
Copy link
Contributor

jjyyxx commented Feb 18, 2025

The feature, motivation and pitch

While constant stiffness and damping are the most common model for passive forces, there does exist needs for more complex passive forces (piecewise linear, nonlinear, lookup, etc.). Mujoco offers two mechanisms, mjcb_passive callback and passive force plugin, to calculate custom passive forces at maximum flexibility. However, in integration step, if I understand correctly, only simple damping is considered in qDeriv calculation via mjd_smooth_vel -> mjd_passive_vel. This makes the implicit integration less accurate, and may lead to divergence.

Alternatives

No response

Additional context

No response

@jjyyxx jjyyxx added the enhancement New feature or request label Feb 18, 2025
@jjyyxx jjyyxx changed the title Mujoco (implicit) integration does not offer an mechanism to take into account custom passive forces in qDeriv calculation Mujoco (implicit) integration does not offer a mechanism to take into account custom passive forces in qDeriv calculation Feb 18, 2025
@yuvaltassa
Copy link
Collaborator

Yes, this is indeed a missing feature. There are two ways of doing this, using the old callback mechanism and the new plugin mechanism. Ideally, both.

For context, what is the custom passive force that you would like to integrate implicitly?

@jjyyxx
Copy link
Contributor Author

jjyyxx commented Feb 18, 2025

For some context, I encountered this limitation when trying to modify data.qacc (a bit of a hack) before integration. I realized that it didn't affect data.qvel and data.qpos when using the implicit integrator. Upon reviewing the source code, I found that the implicit integrator actually uses data.qfrc_* instead of data.qacc and computes a new local qacc. That's when I noticed the limitation.

That said, I don't have an immediate need for this feature at the moment. I do have a few scenarios where custom passive forces are required, but they are position-dependent (like the passive force plugins for shells and cables in MuJoCo), so they aren't impacted by this limitation. However, one valid use case I can think of is for a magnetorheological damper. Given the large and varying damping factors, there’s a risk of simulation divergence, which could benefit from this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants