Load mesh into xml file

Discussion in 'Modeling' started by yongxf, Jun 1, 2017.

  1. Hi there,
    I have to import the an mesh file called fingertip_convex.stl into the distal finger link. The mesh model is a part of the body "finger1_dist", and attached at the end of the finger1_dist_geom. The code is shown as below:

    However, the simulation got stuck at the beginning I load the xml file. Not sure where the problem is. Is it because that I didn't give info on the mass/inertia of the mesh file?

    Thanks a lot!
    Code:
    <asset>
               <mesh file="fingertip_convex.stl"/>
    <\asset>
    <body name='finger1_dist'>
               <geom name='finger1_dist_geom' type='capsule' fromto='0.07 0 0.11 0.03 0 0.15'  size='0.01' />
               <geom type="mesh" mesh="fingertip_convex" pos="0.03 0 0.15" quat="0.69566 0.716713 -0.0354863 0.0334839"/>
               <joint name='finger1_dist_joint' type='hinge' pos='0.07 0 0.11' axis='0 -1 0' range='-90 90' damping='0' stiffness='0'/>
     </body>
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    What exactly do you mean by "the simulation got stuck"? Did the software freeze or crash, or is the model not moving they way you expect?

    I am not seeing anything wrong with the XML you posted. If you send me the entire model I can test it.
     
    Kyokushin likes this.
  3. When I try to drag the xml to the simulation, it shows: xxx.exe has stopped working, but the cmd window didn't give any error message.

    I attached the file in the following.

    Thanks.
     

    Attached Files:

  4. Emo Todorov

    Emo Todorov Administrator Staff Member

    Can you also send me the mesh file you are using? I tried your model with a different mesh in place of fingertip_convex.stl and it works fine, so maybe there is something unusual about that specific STL file that is causing a crash.
     
  5. Attached Files:

  6. Emo Todorov

    Emo Todorov Administrator Staff Member

    Your model works fine when I load it. See attached image corresponding to the initial state (I scaled down the mesh by 0.002). This is a very large mesh so it takes a while to load, but I am not seeing any issues. I tested it in MuJoCo Pro 1.40 and 1.50 on Windows. Which software version and OS are you using? Also, have you tried this in simulate.exe or are you using an executable that you compiled?
     

    Attached Files:

    Kyokushin likes this.
  7. Thanks so much Professor for your comments and trial.

    1. I tested the xml file in my own project, the compiled exe by me cannot work. But it works for the version without mesh part, and work for the barrett hand in mujoco website.
    2. When use pre-compiled exe (windows, I tried both 1.31, 1.40) , they works fine, but fingertip looks superbig.
    3. Then I built a new project in windows vs 2013 using mjpro1.40, it looks exactly the same with pre-compiled exe file, also the fingertip looks pretty big.

    I guess my own project cannot work because my script has heavy computation load, and somehow my xml file has super big fingertip model, the exe file cannot handle these.

    A question is why my fingertip looks so large. I opened it in 3D builder, I saw the size should be around 10 mm. I also opened the bhand_finger_dist_link_convex.stl file, it has 40 mm length in 3D builder, but looks pretty normal in mujoco.

    Thanks!
    upload_2017-6-2_12-25-6.png
     
  8. Emo Todorov

    Emo Todorov Administrator Staff Member

    I also noticed that your mess is too big, and scaled it down like this:

    <mesh file="fingertip_convex.stl" scale="0.002 0.002 0.002"/>

    Not sure why 3D builder is showing 40mm, maybe it infers the units automatically somehow.

    You should reduce the vertex density on that mesh btw. It just slows down the collision detector and the renderer for no good reason. MeshLab is a good tool for processing meshes.
     
  9. Thanks Professor, I have reduced the volume of the fingertip, size now is less than 100K, and use the scale command.

    I finally found the issue: in my script, I use the command:
    Code:
    cur_contact = &((d->contact)[i]);
    mj_id2name(m, 1, cur_contact->geom1)
    mj_id2name(m, 1, cur_contact->geom2) 
    Basically, I first extract the id of two geometries that are in contact, then I use mj_id2name() to extract the names that are in contact.
    Finally, I compare the names with "object" to see whether one of these two names is "object".

    But the problem is: the input of the mj_id2name is actually id of the BODY, but cur_contact->geom1 returns id of the GEOM. In my current setup, one body might have two geoms, that results in Access violation reading location.

    I have created a function to convert the geom id to body id, and the xml file loads successfully now.

    Thanks Professor for your help!
    Best regards,
    Yongxiang Fan