-
Notifications
You must be signed in to change notification settings - Fork 143
[MjWarp] Flex mesh contact is significantly softer than MuJoCo (vertcollide vs contype) #1238
Description
Problem
When using flex with mesh type, I observe significantly softer contact behavior in MjWarp compared to MuJoCo, even with identical contact parameters (solref, solimp, friction, etc.).
Specifically, the object (Stanford bunny) penetrates much deeper into the ground in MjWarp. Stable contact with minimal penetration in Mujoco was not observed in MjWarp.
The key difference between the contact implementation:
- MuJoCo: uses contype / conaffinity
- MjWarp: uses vertcollide (no direct flex collision support)
Video demonstation and reproduction
I attached videos to demonstrate the different simulation results.
MJWarp: https://github.com/user-attachments/assets/535f729e-4daa-444c-99c3-0a2376830b39
Mujoco: https://github.com/user-attachments/assets/bf267b69-b06c-4614-85d6-8fdf35ae52ac
Here is a minimum model file to replicate the results by comment/uncomment lines respectively.
<mujoco model="Stanford_Bunny_Flex_Model">
<option timestep="0.001" integrator="implicitfast" solver="CG">
<flag contact="enable" gravity='enable'/>
</option>
<compiler inertiafromgeom="auto" angle="radian" balanceinertia="true" boundmass="0.001" boundinertia="0.001">
<lengthrange inttotal="50" useexisting="true"></lengthrange>
</compiler>
<size njmax="1000" nconmax="5000" nuser_jnt="1"></size>
<extension>
<plugin plugin="mujoco.elasticity.cable"/>
</extension>
<worldbody>
<geom pos="0 0 -0.5" type="plane" size="10 10 .01"/>
<light pos="0 0 20"/>
<body name="mesh" pos="0 0 0">
<freejoint/>
<flexcomp name='mesh' type="mesh" dim="2" radius=".001" rgba="1 0.9 0.78 1" mass="0.1" rigid='false' dof="full" file="Stanford_Bunny.obj">
<edge equality="true"/>
<!-- In Mujoco using contype=1 and conaffinity=1 -->
<contact selfcollide="none" internal="false" solref="-1e5 -1e3" solimp="0.85 0.9 0.001 0.5 2" condim="6" activelayers="3" friction="1.5 0.005 0.0001" contype="1" conaffinity="1"/>
<!-- In MjWarp using vertcollide='true' -->
<!-- <contact selfcollide="none" internal="false" solref="-1e5 -1e3" solimp="0.85 0.9 0.001 0.5 2" condim="6" activelayers="3" friction="1.5 0.005 0.0001" vertcollide='true' contype="0" conaffinity="0"/> -->
</flexcomp>
</body>
</worldbody>
<equality>
<flex flex='mesh' active='true'/>
</equality>
</mujoco>
Possible reason
Is this difference expected due to the vertcollide mechanism, or does it indicate a mismatch in contact modeling? I have tried to tune the contact solver parameters but it failed to work.
Thanks for help!