Clarification on Why cfrc_ext Remains Zero Despite Nonzero Contact Forces #2403
Unanswered
kankanzheli
asked this question in
Asking for Help
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Intro
Hi!
I am a graduate student at Waseda, I use MuJoCo for my research on RL.
My setup
python 3.9
mujoco 3.15
My question
Hi,
I am using the latest MuJoCo version (importing via import mujoco) for simulating a robot composed of multiple bodies connected by joints. In my XML, I have set different collision properties—for example, external objects have collision parameters “2 1” while the robot’s internal parts have “1 2”—so that external objects should collide with the robot.
During simulation, I observe that when collisions occur, the contact force computed via mujoco.mj_contactForce (applied to an entry in the data.contact array) returns nonzero values (e.g., one contact yields a force of [275.69809179, 145.15425173, -1.96484692] in the contact coordinate system). However, when I iterate over the robot’s body names and read each body’s external force from data.cfrc_ext (transformed to world coordinates), I consistently get zero.
My understanding is as follows:
cfrc_ext Recording:
data.cfrc_ext is meant to record the net external force acting on each body. I have read that if collisions occur internally (i.e., between parts of the same robot), then by Newton’s third law, each collision produces forces on two bodies that are equal in magnitude and opposite in direction, so that when these forces are accumulated, they cancel out and the net external force is zero.
My Issue:
Even when an external collision occurs (with an external object that should have nonzero collision forces), I still see that data.cfrc_ext remains zero—even though individual contacts (via mj_contactForce) show nonzero values.
Could you please clarify the following points?
Under what conditions does cfrc_ext register nonzero external forces? Is it correct that it only records the net external force (so that any internal contact forces cancel out)?
If an external collision occurs (e.g., between a robot body and an external object), why might cfrc_ext still be zero?
Also, can you confirm the coordinate system used by mj_contactForce (I understand that it returns a 6D vector in the contact coordinate system, where the first three components are the force and the last three are the torque)? How does this relate to the force recorded in cfrc_ext, which I believe is expressed in the body’s local coordinate system?
I have attached my XML model and a code snippet for reference. Any guidance on how to obtain or interpret the external forces correctly would be greatly appreciated.
Thank you very much!
Minimal model and/or code that explain my question
Code:
Confirmations
Beta Was this translation helpful? Give feedback.
All reactions