Inertia matrix problem

Discussion in 'Simulation' started by tortes, Apr 12, 2019.

  1. I'm working with an example from openai gym and I want to modify the pen model to rotate around the finger. I tried to add some joints on the pen to drive the rotation. But after I add 4 joints(2 pairs) on the pen, it throws a problem of Got MuJoCo Warning: Inertia matrix is too close to singular at DOF 24. Check model. Time = 0.0000.
    Thank for any help!:)
    The related xml parts is as the below::)
    <body name="target" pos="1 0.87 0.2" euler="-1 1 0">
    <geom name="target" type="capsule" size="0.008 0.1" material="material:target" condim="4" group="2" contype="1" conaffinity="1"></geom>
    <site name="target:center" pos="0 0 0" rgba="1 0 0 0" size="0.01 0.01 0.01"></site>
    <site name="target:top" pos="0 0 0.1" rgba="1 0 0 0.5" size="0.0081"></site>
    <site name="target:bottom" pos="0 0 -0.1" rgba="0 1 0 0.5" size="0.0081"></site>

    <joint name="target:joint1" type="slide" axis="1 0 0" damping="0.01" pos="0.1 0 0"></joint>
    <joint name="target:joint2" type="slide" axis="0 1 0" damping="0.01" pos="0.1 0 0"></joint>

    <joint name="target:joint3" type="slide" axis="1 0 0" damping="0.01" pos="-0.1 0 0"></joint>
    <joint name="target:joint4" type="slide" axis="0 1 0" damping="0.01" pos="-0.1 0 0"></joint>
    </body>
    The related error info is as the below::)
    Traceback (most recent call last):
    File "spinning.py", line 26, in <module>
    viewer.add_marker(pos=np.array([x, y, 1]),
    NameError: name 'np' is not defined
    (tensorflow3) tortes@tortes:~/Desktop/gym/mujocotest/assets/hand$ python spinning.py
    Creating window glfw
    (tensorflow3) tortes@tortes:~/Desktop/gym/mujocotest/assets/hand$ python spinning.py
    Creating window glfw
    (tensorflow3) tortes@tortes:~/Desktop/gym/mujocotest/assets/hand$ python spinning.py
    Creating window glfw
    (tensorflow3) tortes@tortes:~/Desktop/gym/mujocotest/assets/hand$ python spinning.py
    Creating window glfw
    (tensorflow3) tortes@tortes:~/Desktop/gym/mujocotest/assets/hand$
    (tensorflow3) tortes@tortes:~/Desktop/gym/mujocotest/assets/hand$ python spinning.py
    Creating window glfw
    Traceback (most recent call last):
    File "spinning.py", line 19, in <module>
    viewer = MjViewer(sim)
    File "/home/tortes/Desktop/tmp/mujoco-py/mujoco_py/mjviewer.py", line 133, in __init__
    super().__init__(sim)
    File "/home/tortes/Desktop/tmp/mujoco-py/mujoco_py/mjviewer.py", line 26,in __init__
    super().__init__(sim)
    File "mujoco_py/mjrendercontext.pyx", line 278, in mujoco_py.cymj.MjRenderContextWindow.__init__
    File "mujoco_py/mjrendercontext.pyx", line 48, in mujoco_py.cymj.MjRenderContext.__init__
    File "mujoco_py/mjsim.pyx", line 105, in mujoco_py.cymj.MjSim.forward
    File "mujoco_py/cymj.pyx", line 115, in mujoco_py.cymj.wrap_mujoco_warning.__exit__
    File "mujoco_py/cymj.pyx", line 75, in mujoco_py.cymj.c_warning_callback
    File "/home/tortes/Desktop/tmp/mujoco-py/mujoco_py/builder.py", line 355,in user_warning_raise_exception
    raise MujocoException('Got MuJoCo Warning: {}'.format(warn))
    mujoco_py.builder.MujocoException: Got MuJoCo Warning: Inertia matrix is too close to singular at DOF 24. Check model. Time = 0.0000.
     

    Attached Files:

  2. The script I'm going to rotate the pen is as the following. It's welcome for any support or better solution.
     
  3. There is no inertia following the four joints or respectively the "child" body of your joints is missing. Also you have two pairs of joints that resemble identical motion degrees-of-freedom, which to my best knowledge, doesn't make an awful lot of sense.
     
  4. Thanks a lot for your answer! I'm a beginner of mujoco and I just follow the example code to control the rotating. Is there some better solutions to rotate an object without setting the redundant joints? The script I use before is as the below. :)
    MODEL_XML = "/home/tortes/Desktop/gym/mujocotest/assets/hand/manipulate_pen.xml"
    model = load_model_from_path(MODEL_XML)
    sim = MjSim(model)
    viewer = MjViewer(sim)
    t = 0
    while True:
    sim.data.ctrl[20] = math.cos(10 * t) * 0.001
    sim.data.ctrl[21] = math.sin(10 * t) * 0.001
    x, y = math.cos(t), math.sin(t)
    viewer.add_marker(pos=np.array([x, y, 1]),
    label=str(t))

    t += 1

    sim.step()
    viewer.render()