With soft contacts and friction=0, enabling custom PASSIVE forces makes constraint(contact) reactions large — how to keep detection but minimize solver contact forces? #2838
Unanswered
kankanzheli
asked this question in
Asking for Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Intro
Hi!
I am a undergrad student at Waseda, I use MuJoCo for my research on crash simulation.
My setup
MuJoCo version: 3.3.4
Python: 3.10
Renderer: glfw
Timestep / integrator: timestep=0.001, integrator="implicit"
I have a C/C++ plugin that applies forces/torques in the PASSIVE stage via mj_applyFT.
My question
Goal
I want to keep collision detection (contacts, normals, contact points) but minimize MuJoCo’s normal contact reaction, and instead drive separation purely with my own force law applied in PASSIVE.
To weaken the built-in contact, I use soft contact + zero friction:
Minimal Repro (mesh pushes a free capsule)
A sliding mesh_body (with my plugin attached to its geom) pushes a free capsule.
I drive the slider by forcing its qvel to +1.2 m/s.
I print two wrenches (world frame) on the capsule each step:
constraint(contact): accumulated from mj_contactForce(...) (contact frame → world; apply at contact point and shift to the body COM).
plugin(passive): my plugin’s force/torque applied in PASSIVE.
For observability, after calling
mj_applyFT(m, d, F, M, xicom, body_id, d->qfrc_passive);
I also mirror the same values into d->xfrc_applied[6b:6b+6] so Python can read them easily.
What I observe
Without the plugin: plugin(passive) is zero; constraint(contact) is tiny (the mesh can even pass through the capsule).
With the plugin enabled: plugin(passive) becomes sizable (as intended), but constraint(contact) also grows a lot (hundreds of N; and because the force acts at a contact point, it produces a large moment about the capsule COM, causing huge angular velocities).
Example log excerpt for the capsule body:
== [Stage1-F] free_capsule_root F=(-224.567, 0.000, 119.853)
[step t=0.202] free_capsule_root
wrench plugin(passive) F,M = (-224.567, -0.000, 119.853, -0.000, 0.000, -0.000)
wrench constraint(contact) F,M = ( 100.854, 0.000, -0.001, 0.000, -1.574, 0.000)
wrench TOTAL F,M = (-123.713, -0.000, 119.852, 0.000, -1.574, 0.000)
This increase in constraint(contact) happens without changing solref/solimp/friction.
Questions
Is this expected? With soft contact and friction=0, why does adding PASSIVE external forces substantially increase constraint(contact)? I had assumed contact forces would mainly depend on penetration/relative velocity and the solref/solimp parameters, but they seem to strongly depend on other forces present in the same step.
Is there an officially recommended way (parameters or flags) to keep contacts for detection only (i.e., surfaces and normals are reported) while making the solver’s normal reaction as small as possible?
Do you have recommended practices to “decouple” this, or to ensure the solver’s contact reactions remain negligible so that user forces can fully control the normal separation?
Thanks! Any guidance on “detection-only” style contacts or the right way to hand off normal control to user forces would be greatly appreciated.
Minimal model and/or code that explain my question
Python: reading plugin PASSIVE wrench mirrored to xfrc_applied
Code:
Confirmations
Beta Was this translation helpful? Give feedback.
All reactions