Object starting above "ground" and falling

Discussion in 'Simulation' started by Roshan, Feb 11, 2017.

  1. I'm working with mujoco-py and openAI-gym, and I'd like to have my object (a modified version of ant.xml) start suspended above the ground and then "fall." I would like to look at how "hard" it hits the ground and include some sort of actuation that will allow for the direction of motion to change during the simulation.

    It seems like init_qpos and init_qvel are good ways to set initial position and velocity, but I cannot get the object to "fall" when I set qpos to have a higher z value for the torso body. I am setting init_qpos and init_qvel in my python file that runs the simulation. Should I be setting something different? Thank you!
     

    Attached Files:

    • ant.xml
      File size:
      4.8 KB
      Views:
      143
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    If you increase the z coordinate of the torso, the model should indeed move up. What do you mean by "cannot get the object to fall"? It should fall under gravity for any initial position...
     
  3. The model does move up, but when I run the simulation it stays in place above the "ground" ... Changing init_qvel doesn't appear to do anything either.
     
  4. Emo Todorov

    Emo Todorov Administrator Staff Member

    That means there is a bug somewhere, either in the Python wrapper or (more likely) in the way you are calling it. Assuming the simulation is indeed running, the only reason to not fall would be if you disabled gravity. I tried loading your model in the plain MuJoCo simulator (without the Python wrapper) and the ant happily falls for any initial position.

    As a sanity check, try making the change in the XML instead of doing it programmatically and see if that works. Find the line:
    <body name="torso" pos="0 0 0.75">
    and replace it with:
    <body name="torso" pos="0 0 2">
     
  5. Making the change in the XML does not seem to fix it unfortunately. Somehow it seems like gravity is "off" despite the fact that I explicitly set gravity in the <option /> line. I'm looking through the other python files (ant.py, mujoco_env.py) to see if there is something else in the wrapper that is overriding the gravity setting in the XML file, but I don't see anything yet. The gravity for the simulation should only be set in the XML file right?

    I've tried commenting out the actuator and all other bodies that are not the torso to see if that makes a difference as well.