Custom mesh jittering in Mujoco environment in OpenAI gym

Discussion in 'Simulation' started by cyril, Nov 19, 2018.

  1. I've tried modifying the FetchPickAndPlace-v1 OpenAI environment to replace the cube with a pair of scissors. Everything works perfectly except for the fact that my custom mesh seems to jitter a few millimeters in and out of the table every few time steps. I've included a picture mid-jitter below:

    Xp9Kj.png

    As you can see, the scissors are caught mid-way through the surface of the table. How can I prevent this? All I've done is switch out the code for the cube in pick_and_place.xml with the asset related to the scissor mesh. Here's the code of interest:

    ```
    <body name="object0" pos="0.0 0.0 0.0">
    <joint name="object0:joint" type="free" damping="0.01"></joint>
    <geom size="0.025 0.025 0.025" mesh="tool0:scissors" condim="3" name="object0" material="tool_mat" class="tool0:matte" mass="2"></geom>
    <site name="object0" pos="0 0 0" size="0.02 0.02 0.02" rgba="1 0 0 1" type="sphere"></site>
    </body>
    ```

    I've tried playing around with the coordinates of the position and geometry but to no avail. Any tips? Replacing mesh="tool0:scissors" with type="box" gets rid of the problem entirely but I'm back to square one.
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    You did not provide the model so I cannot be sure, but I am guessing the reason is the following. The collision mechanism uses the convex hull of the mesh, and generates a single contact with the box. When the convex hull has large flat areas, this single contact has to run around (over time steps) to prevent penetration over the entire surface.

    There are two solutions to this problem:

    1. Replace the ground box with a plane (or is it already a plane?) and use MuJoCo 2.0. The latest version of the collision detector generates multiple contacts between a mesh and a plane, which results in more stable simulation. But this only works for plane-mesh, not for box-mesh.

    2. The better solution is to break the mesh into several meshes, and include them as multiple geoms in the same body. Then MuJoCo will construct the convex hull of each sub-mesh, resulting in multiple contact points (even without the special plane mechanism mentioned above) and furthermore it will be a better approximation to the actual object geometry.
     
  3. I think I might go with the second option as I doubt openAI supports MuJoCo 2.0. Thank you for the quick reply and the excellent program! I've also uploaded the mesh if you care to look at it: it's my first 3D model which I learned to make yesterday so I'm sure there are a ton of mistakes. Please let me know what you think/what I can improve!
     

    Attached Files:

  4. I was able to break the scissors into two distinct meshes and joined them as so in XML:

    <body name="object0" pos="0.0 0.0 0.0">
    <joint name="object0:joint" type="free" damping="0.01"></joint>
    <geom size="0.025 0.025 0.025" mesh="tool0:l_scissors" condim="3" name="object0a" material="tool_mat" class="tool0:matte" mass="2"></geom>
    <geom size="0.025 0.025 0.025" mesh="tool0:r_scissors" condim="3" name="object0b" material="tool_mat" class="tool0:matte" mass="2"></geom>
    <site name="object0" pos="0 0 0" size="0.02 0.02 0.02" rgba="1 0 0 1" type="sphere"></site>
    </body>

    The jittering is a *lot* less pronounced right now which is awesome. What other improvements would you suggest I make to get rid of it entirely?
     
  5. Emo Todorov

    Emo Todorov Administrator Staff Member

    Break it into even more meshes. At rest, each contact point immobilizes 3 DOFs. A rigid body has 6 DOFs, and your object has an extra internal DOF, so that makes 7. So you need 3 active contacts, i.e. the object should be broken into at least 3 sub-meshes.
     
    cyril likes this.
  6. Worked perfectly, thank you!