google-deepmind / mujoco

Multi-Joint dynamics with Contact. A general purpose physics simulator.
https://mujoco.org
Apache License 2.0
7.62k stars 751 forks source link

Remove dynamics from simulation #1540

Open aleada23 opened 4 months ago

aleada23 commented 4 months ago

Discussed in https://github.com/google-deepmind/mujoco/discussions/1533

Originally posted by **aleada23** March 21, 2024 Good morning. I'm a student and I'm using MuJoCo for a project. I know that dynamic is an important feature for this engine, but I need to remove it from my environment. I've created an environment, also using Robosuite, where a robot has to perform tasks. Now, I need to remove the dynamics from the environment to make computation lighter for implementing a new learning component. Is it possible to remove the dynamics? I would like to avoid any calculations related to it, as it isn't necessary in this new phase. The dynamics currently does not constitute a fundamental part of my simulation during the learning phase, so I can do without it. I am only interested in keeping some functionalities active, such as the rangefinder sensors, or obtaining the Jocobian for solving inverse kinematics for robot control. Therefore, I would like to do away with the dynamics completely removing the values. For instance, if I were to zero out masses and frictions, I would remove a significant portion of the dynamics from the simulation, but I believe the calculations would still be performed, keeping the simulation slow as it is now. Any suggestion about this? Thank you for your time
Balint-H commented 4 months ago

Yuval's suggestion under your previous post would probably work for you. If you have your own way of updating or setting qpos/qvel, you can just call individual sub-steps from mj_step as needed.

I recommend reading up of the simulation loop section in the docs, especially the breakdown of mj_step1. You can check the source code of the substeps inside mj_step1 (e.g. for mj_fwdPosition) or their summaries in the API documentation, if you need to go even more fine grained.

aleada23 commented 4 months ago

Thank you, I'll check the documentation that you provided.