Convex decomposition does not add concavity to simulation objects

Discussion in 'HAPTIX' started by David Kluger, May 27, 2015.

  1. I tried installing the HACD library as suggested on the MuJoCo overview. I used the newer V-HACD 2.0 binaries the same developer released. The binaries are able to perform the decomposition into a .stl file, but MuJoCo cannot load them because they are in ASCII format (at least that's what the error message tells me).

    So I tried using Google SketchUp and added some plugins to perform CDs and export into binary .stl format. MuJoCo can render objects defined by the .stls generated by this method, but there is still no concavity. For example, I added a ring I made using SketchUp and its convex decomposition into the simulation. I placed a cylinder into the simulation inside of the ring. MuJoCo renders the objects just as I would expect and I can see faint lines in the ring where the convex decomposition broke apart the ring. However, once I press play, the ring shoots upwards as if the hole in the middle is solid.

    Have you found and confirmed a reliable method to generate concave meshes in MuJoCo? Have you tried using the HACD library with any success?
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    If the .stl file defines a non-convex mesh, it will be rendered correctly but the collision detector will use its convex hull. The only way to do collisions with a non-convex mesh is to decompose it into a union of convex meshes, put each resulting convex mesh in separate .stl file, and assign each of these files to separate geom. All these geoms should belong to the same body (because you don't want them to move relative to each other). Is this what you are doing? Or are the convex meshes in a single .stl file? If it is the latter, we are back to the situation where a single convex hull is used to represent one non-convex mesh -- which happens to contain multiple pieces that are convex, but MuJoCo doesn't know that, it sees it as a single mesh.

    If you send me the model or upload it on the forum under Resources I would be happy to take a look.
  3. I see. The convex meshes I was describing were in a single .stl file.

    In the future, for hollow/concave objects that we need in simulations, we will render convex pieces together in the same body with separate .stl files as you suggested. Building and rendering these multi-part meshes will be a bit of a hassle, but 100% doable. Thanks for getting back to me.
  4. It would be good if Mujoco could support .obj files like PyBullet. Then instead of having to define multiple meshes from multiple stl files assets, all could be defined in one .obj asset.

    Is there at least a way to automatically generate multiple stl files from one .obj or one .stl file, (and perhaps anything else also that can simplify the modification of the MJCF)?

    I have a .obj (or stl) file which includes of around 150 convex meshes inside it for which it is rather difficult to if I were to make a separate stl file of each and write an xml file.
    Last edited: Mar 7, 2020
  5. I suggest writing a simple bash/python script that goes through the .obj file and makes a system call to the command line interface of meshlab. I remember doing that once for exactly your purpose.
  6. Hi Alireza,
    Have you figured out how to do this by scripts? I ran into the same situation as you where I had a .obj file containing multiple convex meshes but I'm not sure how to integrate them with mujoco. Thanks in advance!
  7. @kracon7 Hi, what I did in the end was writing a script in Blender's python interface to import the obj file and automatically separate and save stl files while writing an xml for them.
    If you wanted more information about it I'd be happy to help over email or whatsapp:, +49 15 77 37 941 68