Compactness of imported mesh

Discussion in 'Simulation' started by Nikita, Apr 26, 2020.

  1. Hi! I have a problem about two meshes behaviour (mesh extension file is .stl). Here is my xml file:

    <?xml version="1.0" encoding="utf-8"?>
    <mujoco>
    <compiler angle="radian" coordinate="local" meshdir="./stls" convexhull="false"></compiler>
    <option timestep="0.002" gravity="0 0 -9.81">
    <flag warmstart="enable"></flag>
    </option>

    <asset>
    <mesh file="middle_link_1.stl" name="middle" scale="0.25 0.25 0.25"></mesh>
    </asset>

    <worldbody>
    <light directional="true" cutoff="4" exponent="20" diffuse="1 1 1" specular="0 0 0" pos=".9 .3 2.5" dir="-.9 -.3 -2.5 "/>

    <geom name="ground" type="plane" pos="0 0 0" size="10 20 0.001" rgba=" .25 .26 .25 1"/>
    <body pos="0 0 2">
    <inertial diaginertia="0.009 0.0086 0.0041" mass="2.55" pos="0 0 0"></inertial>
    <geom type="mesh" mesh="middle"/>

    <body pos="0 0 8.7">
    <inertial diaginertia="0.009 0.0086 0.0041" mass="2.5587" pos="0 0 0" quat="0 1 0 0"></inertial>
    <geom type="mesh" mesh="middle"/>
    <joint name="joint_1" type="hinge" axis="1 0 0" limited="true" range="-0.5 0.5" />
    </body>
    </body>
    </worldbody>

    <actuator>
    <position joint='joint_1' name='motor' gear="1" forcelimited="true" forcerange="-10 10"/>
    </actuator>

    </mujoco>

    I attach mesh file also.
    My goal was to create a joint between two geoms and control it. I wanted it to rotate like elbow (in the same axis -> joint type is hinge). I placed them in the right way: small stick-link in the upper body is going through the hole in the bottom body. But when I put joint and actuator in it and try to control it, the upper body stick-link goes out from bottom body hole. The question is why that happened? And how can I change my code to avoid it? Thanks for helping.
     

    Attached Files:

  2. I opened you model using the standard 'simulate' executable and selected 'Rendering -> Joints' and this make it clear the joint is not in the right axis nor the right position: (screenshot)
    [​IMG]

    The roughly correct joint would be:
    • <joint name="joint_1" type="hinge" axis="0 1 0" pos="-1.1 0 0.0" limited="true" range="-0.5 0.5" />
    A tip: if you use the default simulation, you can pause the simulation and manually change the joint position. This is an easy debugging to see if your joints are correct.

    However the model still did not properly simulate. My guess is it is a bad idea to include the bolt in the model. I would suggest you use the STL only for visualization, but rely on a simple capsule geom to model the contacts. This should make your model more robust.

    And you might want to modify the STLs such that the origin is more sensible. You could put the origin of the model at the joint, such that it could corresponds to the body frame.
     

    Attached Files:

    Nikita likes this.
  3. Thanks a lot for the answer!! I got my bad about joint positioning! I have as an example robot.xml (in the attachment, OpenAI model of 7 DOF robot-manipulator) of the file, which uses imported meshes from STL file, so I tried to imitate this approach to construct robot. But their implementation works very stable. If it will be useful there is github link to pull their code: https://github.com/nik31096/gym.git, and file robot.xml for 'simulate' util is placed here: './gym/gym/envs/robotics/assets/fetch/robot.xml'. Can you please explain how does it work?
     

    Attached Files:

  4. I can't run the robot.xml file you posted, I get an error "XML Error: Schema violation: unrecognized element"

    I don't know why it works for them. Could you post a screenshot of this robot? I expect the robot doesn't include the bolt, i.e. there are no bodies wrapped around each other.
     
  5. I am sorry if I attached wrong file. I attach another file directly from gym repo. But to run this file using 'simulate' util one needs to have directories with meshes and textures, so it is necessary to pull gym repo and run robot.xml from there.
     

    Attached Files: