Skip to content

flex unstable,Severe numerical instability (NaN/Inf in QACC) of MuJoCo flexcomp when parent body has non-identity quaternion orientation #3364

Description

@fanke-polimi

Intro

Hi!

I am a graduate student at Politecnico di Milano.

I am trying to attach a soft, flexible gripper (modeled as a MuJoCo flexcomp) to the end of a robotic manipulator arm. However, I encounter a severe numerical instability issue whenever the parent body has a non-identity quaternion rotation (quat parameter).

The simulation crashes with the following error:

WARNING: Nan, Inf or huge value in QACC at DOF 8. The simulation is unstable. Time = 0.2380.

I used the official MuJoCo example gripper_trilinear.xml as my starting point. The original example runs perfectly stable. But when I simply wrap the gripper model inside an additional parent body (representing the robot arm's end flange) and apply a rotational quaternion to that parent body, the simulation becomes extremely unstable and crashes within the first 0.2 seconds.

My setup

  <body name="base" pos="0 0 .8" quat="0.7071 0 0.7071 0">
    <body name="hand" pos="0 0 .37" quat="0.8944 0.4472 0 0">
      <joint name="lift" type="slide" range="0 1"/>
      <geom type="box" size=".2 .1 .05" rgba=".2 .2 .2 1"/>
      <body name="right_gripper">
        <joint name="right" type="slide" axis="-1 0 0"/>
        <geom type="box" size=".02 .1 .15" pos=".18 0 -.2" rgba=".2 .2 .2 1"/>
        <flexcomp type="mesh" file="cap.obj" pos=".16 0 -.25" dim="3" euler="0 -90 0"
                  origin="0 0 0" radius=".001" rgba="0 .7 .7 1" mass=".005" name="left"
                  dof="trilinear">
          <elasticity young="1e4" poisson="0.1" damping=".1"/>
          <contact selfcollide="none" internal="false" contype="2" conaffinity="2"/>
          <pin id="4 5 6 7"/>
        </flexcomp>
      </body>
      <body name="left_gripper">
        <joint name="left" type="slide" axis="1 0 0"/>
        <geom type="box" size=".02 .1 .15" pos="-.18 0 -.2" rgba=".2 .2 .2 1"/>
        <flexcomp type="mesh" file="cap.obj" pos="-.16 0 -.25" dim="3" euler="0 90 0"
                  origin="0 0 0" radius=".001" rgba="0 .7 .7 1" mass=".005" name="right"
                  dof="trilinear">
          <elasticity young="1e4" poisson="0.1" damping=".1"/>
          <contact selfcollide="none" internal="false" contype="2" conaffinity="2"/>
          <pin id="0 1 2 3"/>
        </flexcomp>
      </body>
    </body>
  </body>
</body>
<!-- <body>
  <freejoint/>
  <geom type="box" size=".05 .1 .1" pos="0 0 .1" rgba=".5 .5 0 1" priority="1"
        contype="2" condim="6"/>
</body> -->

What's happening? What did you expect?

Setting rgba="1 0 0 1" renders as green, I expected it to render as red.

Here is a screen-shot showing a green sphere:

Steps for reproduction

  1. Load the model below.
  2. Run the code below.
  3. See green sphere (should be red).

Minimal model for reproduction

If you encountered the issue in a complex model, please simplify it as much as possible (while still reproducing the issue).

minimal XML
<mujoco>
  <worldbody>
    <light pos="0 0 1"/>
    <geom type="sphere" size="1" rgba="1 0 0 1"/>
  </worldbody>
</mujoco>

Code required for reproduction

import mujoco
import mediapy as media
model = mujoco.MjModel.from_xml_string(xml)
data = mujoco.MjData(model)

with mujoco.Renderer(model) as renderer:
  mujoco.mj_forward(model, data)
  renderer.update_scene(data)

  media.show_image(renderer.render())

Confirmations

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions