mj_load_XML or mj_set_geom

Discussion in 'Feature Requests' started by David Kluger, Dec 29, 2015.

  1. It would be beneficial to be able to change geom parameters in real time via the API. For example, we would like to change a specific geom's parameters from the API such as size, shape, or position. To my knowledge, this is only doable right now by going through the MuJoCo GUI and changing the the loaded .xml through the file menu where the new file has the desired geom parameters predefined.

    I see two ways of achieving this:
    1) Be able to change the .xml in real time with a function such as mj_load_xml(filename) where all geom parameters are defined in filename.xml. This function doesn't need to be too complicated if it mandates that the number of motors, joints, geoms, bodies, etc are the same between the two .xmls. Alternatively, calling mj_load_xml would require subsequent API calls to redefine structure sizes to make the API cooperate with the .xml you would like to run.

    2) Change a specific geom's parameters in real time via the API with a function such as mj_set_geom(geomid, geomstruct). geomstruct would have all of the same fields users would normally have to define in the .xml to create a geom of desired shape, position, solimp, solref, etc.

    Please let me know if I have overlooked API calls that already exist with this functionality or if this functionality can be added in future releases.
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    Indeed, this is not currently possible. The only way to change geom properties is to edit the XML model file, and re-load it by pressing Ctrl+L or using the re-load button on the toolbar. If there are geoms you need to edit often, you could put them in a separate XML file that is included form the main file. Either way, the entire model will be compiled from scratch.

    Another thing you can do is create multiple sets of geoms for different scenarios, and show only the set that is currently needed. This can be done using geom groups. But groups can only change visualization properties; there is no way to enable and disable collision properties without re-loading the model.

    If you were using MuJoCo Pro directly (it is the physics and rendering SDK used to build MuJoCo HAPTIX), you could write code that makes all kinds of model changes online. But HAPTIX can only do whatever was programmed in the API...

    Adding an API call that changes geom parameters online in the already compiled model is doable. I will put it on the to-do list for the 1.3 release. It should come out in about a month.
     
  3. Dear Emanuel,

    Any updates on this?

    Would it ever be possible to load models in HAPTIX programatically?

    Something like taking the name of the *.xml file in the command line as a parameter for example?

    Thanks for such a great software.

    Best
     
  4. Emo Todorov

    Emo Todorov Administrator Staff Member

    Some of the geom parameters can now be modified via the socket API -- size and color.

    As for loading models programmatically, it is not in the cards. There are lots of things in the GUI that need to be updated when the model changes, and this was designed to be triggered from the HAPTIX controls, not the socket API. So internally the change would be larger than it appears.
     
  5. Great.
    I see, I understand. As an external observer one always assumes it is just a few lines ;-)

    Do you know of any way equivalent to:
    >mjhaptix.exe model.xml

    which would allow to call the program and load a model? Nothing "programmatic", say batch like :confused:?
     
  6. Emo Todorov

    Emo Todorov Administrator Staff Member

    The only argument to mjhaptix.exe is -nomocap which disables motion capture and skips initialization of the Optitrack. The executable is designed to be used via the GUI.