Based on point 17 of Forward Dynamics Simulation Pipeline, MuJoCo calculates the vector of Coriolis, centrifugal and gravitational forces. I hope its calculated for each time instant based on the current Joint position and Joint velocities. I would like to access those values, so that I can perform gravity compensation for the each robot joints instantly. Is there any way to do that ? Also I am getting segmentation fault if use mj_contactForce(m, d, cc, con_force), Can I use this function after the end of the simulation ?
The vector of Coriolis etc. forces is in qfrc_bias, and is computed at each time step. The equaitios of motion are: M(qpos)*qacc + qfrc_bias = (sum of applied forces, passive forces and constraint forces) So if you set qfrc_applied = qfrc_bias in your control law, you will compensate for gravity and all other internal forces. You can use mj_contactForce and all other MuJoCo functions as long as mjModel and mjData are in memory. If you have already deleted them, then you will get a segmentation fault because you are passing an invalid pointer to the library.