Data transfer between Mujoco and graphics rendering engine

Discussion in 'Simulation' started by rachana_s, Jan 12, 2017.

  1. Hi,

    Is it possible to transfer data between Mujoco and a graphics engine like Ogre3D?
    This is what I'm trying to do: the user interacts with the models in Ogre. I want to send the position and orientations of the models as well as the force the user applies to the models to Mujoco. Mujoco does the physics calculations to find the result of the force applied and then send the new positions and orientations of the models to Ogre which will render it.
    How do I transfer data between Mujoco and a graphics engine like Ogre3D?

    Thank you.
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    Yes, MuJoCo is designed to allow this. Look at the code samples that involve rendering, and also the visualization section of the programming guide:

    http://www.mujoco.org/book/programming.html#Visualization

    Briefly, rendering is divided into abstract and OpenGL. The abstract stage populates the structure mjvScene, which is something like a scene graph (or rather a scene list) and contains all the geom visual properties. You can use that machinery, and then make corresponding calls to Ogre3D instead of calling MuJoCo's OpenGL renderer.

    Note that you should not be setting positions in MuJoCo all the time; if you do that, you are essentially suppressing the physics simulation. Instead, you should let MuJoCo maintain the state of the system, render it, get interaction forces from your GUI, and tell MuJoCo about those forces. To apply 3D forces and torques to simulated bodies, set mjData.xfrc_applied to a non-zero vector. Then when you call mj_step, those forces will be applied to the simulation.

    I was hoping that someone will interface MuJoCo to another 3D rendering engine, so please let me know how it goes, and feel free to ask more specific questions.