Changing physical properties online?

Discussion in 'Modeling' started by Mincheol, Mar 2, 2020.

  1. Hello, I want to implement a dynamic system that changes its physical properties online (via executed scripts).

    For instance, while the rendering is happening, a ball of mass that becomes heavier or lighter or a beam that changes its inherent stiffness depending on the commands that I give.

    Any clue or suggestion on how to implement this would be helpful.

    Thank you.
     
  2. You can just change the model at runtime, although (to the best of my knowledge) you might run the risk of causing undefined behavior within the engine for some of the parameters.
    However, make sure that you call

    void mj_setConst(mjModel* m, mjData* d);
    Set constant fields of mjModel, corresponding to qpos0 configuration.

    after your changes to recompute relevant dependencies.
     
  3. Thanks for the advice. I am looking into it, I was able to make changes to the available parameters in MjModel (e.g. body_mass for mass),
    but it doesn't really grant me the access to the intrinsic properties defined in the object xml such as stiffness and damping.
    I was thinking of changing the particle structure of the composite object to change its overall stiffness, but is there any other way to go around this?

    Thank you.
     
  4. If you are using the openAi wrapper, than I have no idea if changes take affect at all, other than that you should be able to also modify damping values ect. However be careful. The xml sort of offers a high level parametrization of composite objects, just as a helper to then fill in the appropriate fields or create hundreds of subgeoms. "springdamper" just gets evaluated and stiffness and damping are set accordingly. What I suggest is that you load your xml into mujoco simulate and then press save xml. This creates a xml that has all these bare lower-level fields filled in. Modifying the corresponding mjmodel parameters should then result in relevan changes.
     
  5. Thanks for the reply. I did try extracting XML from Mujoco simulator and indeed it showed some low-level parameters that didn't show up before. I was able to change those parameters in mjmodel in my main script. Thanks again, that helped a lot! Now I'm in experimenting mode :D