Meshes as freejoints

Discussion in 'Modeling' started by Benedikt Sarnes, Oct 31, 2018.

  1. Hi!

    When I joint meshes (.stl) as "free" I get strange contacts in the simulation.

    As seen in the pictures, the ring causes a hard contact with the other geoms (boxes) when placed vertically and strangely kinda floats into the boxes when placed horizintally.

    I coded it like this:
    ___________________________________________________________
    <mujoco model="kuka_lbr_iiwa_14_r820">

    <compiler angle="radian" convexhull="false" />
    <size njmax="500" nconmax="100" />

    <compiler inertiafromgeom="true" angle="degree"/>
    <option timestep="0.001" gravity="0 0 -9.81" />

    <default>
    <geom condim="3" conaffinity="1" contype="1"/>
    <motor forcelimited="true" ctrllimited="true"/>
    </default>

    <asset>
    <mesh name="ring" file="Stl-Files/ring_modeled_V2.stl" scale="0.001 0.001 0.001" />
    </asset>

    <worldbody>
    <light directional="false" diffuse="1 1 1" specular="0 0 0" pos="0 0 10" dir="0 0 -1" castshadow="false"/>

    <geom name="robotstand" type="box" pos="0 0 -0.25" size="0.15 0.15 0.25" />
    <geom name="pickup_box" type="box" pos="0.70 -0.70 -0.25" size="0.10 0.10 0.25" density="5000" />
    <geom name="place_box" type="box" pos="0.70 0.70 -0.25" size="0.10 0.10 0.25" />
    <geom name="floor" type="box" pos="0 0 -0.55" size="1 1 0.05" />

    <body name="ring" pos="0.7 -0.7 0" >
    <joint type="free" name="freejoint"/>
    <geom type="mesh" mesh="ring" mass="0.405" />
    </body>

    </worldbody>
    </mujoco>
    ________________________________________________________

    I obviously want the ring to have a "hard contact" with the other geoms from every side.
    I couldn't figure out a solution with the documentation so I hope, someone can help me here :)

    Regards,
    Ben
     

    Attached Files:

  2. If anyone has the same problem in the future:

    Setting the parameters for contact simulation to a really high stiffness
    (solref)
    solved the problem that the ring was floating into the boxes.

    Code:
        <body name="ring" pos="0.7 -0.7 0" >
                <joint type="free" name="freejoint"/>
                <geom name="ring" type="mesh" mesh="ring" mass="0.405" solref="-100000 -1000" />
        </body>
    
    This on the other hand creates pretty unrealistic contact physiks for the ring. Just adjusting the solver parameters (solimp) didn't solve the problem in the simulation - So if anyone has a better solution, please let me know :)
     
  3. During the modeling process I encountered another problem.

    The robot is supposed pick up the mesh and in order to do so, it's grippers need to reach inside the ring (as seen in the picture).
    I loaded the complete ring as an .stl into the simulation and the automatically created convex hull for collision detection formed a cylinder. That way the grippers can't reach into the ring.

    For this Problem with the convex hulls the blender Add-on V-HACD (https://github.com/kmammou/v-hacd) is often recommended in this Forum.

    Because the add-on left out some important faces I need for the intended collisions and the granularity of the created convex hulls couldn't be adjusted fine enough, it didn't do the job for me.
    Instead I redid the CAD models of the ring and the grippers and devided the models into smaller meshes myself. I for example created 3 meshes for the ring (picture) and rotated them around every 20 degrees. This way, the convex hulls were fine enough and included all important faces for the contacts so that the ring could be picked up by the grippers.

    Code:
        <body name="ring" pos="0.7 0 0.1" >
    
            <joint type="free" name="freejoint"/>
            <inertial mass="0.405" pos="0 0 0.018" diaginertia="0.001435 0.001435 0.002403"/>
    
            <geom type="mesh" mesh="ring1" class="grey" />
            <geom type="mesh" mesh="ring2" class="grey" />
            <geom type="mesh" mesh="ring3" class="grey" />
    
            <geom type="mesh" mesh="ring1" class="grey" euler="0 0 20"/>
            <geom type="mesh" mesh="ring2" class="grey" euler="0 0 20"/>
            <geom type="mesh" mesh="ring3" class="grey" euler="0 0 20"/>
    
    <!-- redo for every 20 degrees until: euler="0 0 340" -->
    <!-- the meshes are pretty simple, all 3 combined are under 3.5 kb -->
    <!-- definitions in class="grey": <geom rgba="0.6 0.6 0.6 1" solimp=".99 .99 .01" solref=".001 1" /> -->
        </body>
    
    
    As stated in the comment, the contact problem dissapeared and setting the solver parameters now did the job just fine.

    For me, the V-HACD library works good with simple parts but when there are more complex tasks that require contacts at defined faces, slicing the part into smaller meshes myself worked a lot better.
     

    Attached Files:

    Last edited: Nov 21, 2018