Create convex contact geometry directly with mesh?

Discussion in 'Modeling' started by Hao, Jul 19, 2017.

  1. Hao

    Hao

    I wonder is there any way I can easily turn a mesh file into "a combination of convex shapes", like when I input a curved bar it turned into a set of spheres.
    Also, why even I set
    <compiler convexhull="false"/>
    There is still contact point in place with no mesh, like the figure below.
    http://imgur.com/a/3sxe3
    the circular bar is a half disk when convexhull="true", but it still interacts with the green box even I set it false?
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    MuJoCo only handles convex collisions. Setting convexhull="false" means that the convex hulls are not precomputed at compile time, but they are still computed implicitly at runtime (making the simulation slower).

    There is a library called HCAD which can decompose a non-convex mesh into a union of convex meshes:

    https://github.com/kmammou/v-hacd
     
    Kyokushin likes this.
  3. Hao

    Hao

    Thanks for your helping.
    However, by doing so the object became multiple convex shape pieces. To assemble them isn't easy while we need to know all weld joints position. Is there any toolbox that will make this job easier?
    Right now I use solidworks to read wrl file (get the combined of mesh), and export to matlab simscape and turned it into multiple bodies robot, finally retrieve all joint position manually.
     
  4. Emo Todorov

    Emo Todorov Administrator Staff Member

    You should attach all geoms to the same body, instead of creating a body for each geom and welding them together. HCAD will create all the pieces in a common coordinate frame, which is what you need when attaching multiple geoms to the same body. So you don't have to worry about specifying offsets and rotations -- the mesh vertex coordinates already have that information baked in.
     
  5. Hao

    Hao

    I had built a model with multiple meshes for each component, the basic structure is I create a body, attached all mesh with it, and later attached the child object in it with the similar manner.
    Code:
    <body name="parent">
       <body pos="0 0 0">
       <geom type="mesh" mesh="mesh1_1" density=10/>
       </body>
       <body pos="0 0 0">
       <geom type="mesh" mesh="mesh1_2" density=10/>
       </body>
    
    
       <body name="child">
          <body pos="0 0 0">
              <geom type="mesh" mesh="mesh2_1">
          </body>
       </body>
    </body>
    However, it seems like I need to add mass to the body that I attached mesh in order to run the simulation. While I could just create a negligible mass (0.0000001), I wonder is there any way I don't need to add the extra mass?
     
  6. Emo Todorov

    Emo Todorov Administrator Staff Member

    You don't need all these bodies. MuJoCo allows a single body to have lots of geoms attached to it.

    Bodies without mass are not allowed. When you attach a geom to a body, the mass is computed automatically. But your body named "child" does not have geoms attached to it, so its mass is 0. The way to solve this is use a single body and attach all the mesh geoms to it. The only reason to create a new body is to allow it to move relative to the parent.
     
    Kyokushin likes this.
  7. Hao

    Hao

    I am confused about the model I am using now. I attached some body with density under a body with no mass and attached all of them under a body with mass. It turned out that it still works, is that because there is no joint between body with mass and no mass, so the one with no mass is viewed as a dummy?
    It is like [ (body w/ mass)<->(body w/o mass) <-> (body w/ mass)] <-> (body w/ mass)