Difference between changing values in mjData and mjModel

Discussion in 'Simulation' started by Jędrzej Orbik, Oct 15, 2019.

  1. If one would like to change the position of the object during the simulation what would be intuition if one should change the values of mjData or mjModel between simulation steps? Sometimes I find that I have to change the mjData (for example to change to set the position of camera) and sometimes I need to change the mjModel (if I change the position of the whole body).

    Sometimes (for bodies with freejoint) I even have to change the qpos vector to change the position of the object, so it is pretty confusing. It would be good to have a better understanding of the distinction between the model and data.
    Last edited: Oct 15, 2019
  2. Mjdata contains the system state (qpos, qvel, (warmstartdata, ...)), that is, everything that is required to compute the next time step. When you alter the state manually and step once, then of course, objects will change their location to your desired value.
    Mjdata contains everything that is computed from this system state at runtime. This includes results from forward kinematics, forward dynamics and so on.
    If you change anything other than the system state, it will just be overwritten, it has absolutely no effect.

    Mjmodel contains the stuff that isn't altered, so basically the parameters of your model. This includes the kinematic structure of your model, the masses but also meta infromation like the number and type of actuators/ joints ect..

    My explanation is rather coarse, but to be fair it is pretty decently explained in the mujoco documentaion.
    Last edited: Oct 15, 2019
    Kyokushin and Jędrzej Orbik like this.
  3. Thank you Florian!