Save a model file that integrates non-initial data?

Discussion in 'Simulation' started by Tyler Neylon, Jun 27, 2016.

  1. Is there a variant of mj_saveXML that can save a model that has been updated to include the current state of the data? Conceptually, I'd like to step forward an arbitrary amount of time and then save a new model such that the new model begins exactly where my last simulation ended.
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    This is not possible. The point of separating mjModel from mjData is that mjModel contains all constants that define the model, while mjData contains all variables that change over time. The XML corresponds to mjModel. This is why loading an XML creates an mjModel, and then there is a separate function call that creates the corresponding mjData.

    To save the simulation state, you can create your own file, or define keyframes in the model, set them at the end of the simulation, and then save the XML. Next time you load the XML, you can copy the data from these keyframes into the corresponding fields of mjData. I will add a function to automate this copy procedure.

    The notion of simulation state in MuJoCo is described here:

    http://www.mujoco.org/book/pro.html#prStateControl