google-deepmind / mujoco

Multi-Joint dynamics with Contact. A general purpose physics simulator.
https://mujoco.org
Apache License 2.0
8.22k stars 820 forks source link

Stiffness and Damping Switched in Tendon .cs file #2215

Open sriddle97 opened 1 week ago

sriddle97 commented 1 week ago

Intro

Hello, I've been trying to debug my model of a soft robot constructed using composite cable and tendon elements. I made a separate post about the cable element moments of inertia but I also noticed that changing the tendon stiffnesses in the xml file did not result in a higher stiffness when the simulation runs.

My setup

Mujoco, python

What's happening? What did you expect?

As part of the debug process I tried changing the stiffness parameter in the xml file and noticed that multiplying that by even a factor of 1000 did not appreciably change the stiffness experienced when the simulation runs. The force required to contract the tendon a prescribed amount for stiffness=50 is 5N and for stiffness=50,000 it is 5.8N.

I went through the Mujoco Github repository looking for potential bugs and stumbled across one that may be relevant. In the MjBaseTendon.cs file https://github.com/google-deepmind/mujoco/blob/main/unity/Runtime/Components/Tendons/MjBaseTendon.cs it appears that the stiffness is set equal to the damping and vice versa on lines 45 and 46.

Stiffness = mjcf.GetFloatAttribute("damping"); Damping = mjcf.GetFloatAttribute("stiffness");

It looks correct later in lines 55 and 56 but I am not sure what purpose each of those components of the code serve as they are in different protected override sections.

Could this by why changing my tendon stiffness value is not actually resulting in increased stiffness at run time?

Confirmations

yuvaltassa commented 2 days ago

@Balint-H this looks like an actual (easy to fix) bug. Can you confirm?

Balint-H commented 2 days ago

Hello, yes this looks like a clear cut fix, will push it today.