(Python module bug here: https://github.com/openai/mujoco-py/issues/78) I'm setting the qpos of one of the joints in this model (the only named joint) to exactly pi/2, and then calling forward() on it. Code: <mujoco> <compiler angle="radian"/> <worldbody> <body> <joint axis="1 0 0" type="slide" /> <joint axis="1 0 0" type="hinge" /> <joint axis="0 1 0" type="hinge" name="y" /> <joint axis="0 0 1" type="hinge" /> <geom size="1" type="sphere" /> </body> </worldbody> </mujoco> This is returning the following MuJoCo warning: Inertia matrix is too close to singular at DOF 0. Check model. Time = 0.0000. I'm trying to reproduce this with pure-C code, but it looks like the issue is unlikely in the python module.
I was able to reproduce the error without python, using the above XML and this simple program: Code: #include "mujoco.h" int main(int argc, const char** argv) { mj_activate("mjkey.txt"); mjModel* m = mj_loadXML(argv[1], 0, NULL, 0); mjData* d = mj_makeData(m); d->qpos[2] = 1.5707963267948966; mj_forward(m, d); return(0); } This results in the following output: WARNING: Inertia matrix is too close to singular at DOF 0. Check model. Time = 0.0000.
More information: the error is fixed if I add or subtract 1e-8 (0.00000001) to the angle. Only exactly pi / 2 seems to have this issue.
The inertia matrix in that configuration is: 4.2e+03 0 0 0 0 1.7e+03 0 1.7e+03 0 0 1.7e+03 0 0 1.7e+03 0 1.7e+03 which is indeed singular. You can obtain this by calling mj_printData and looking for QM. The reason it is singular is because you have placed the system in a kinematic singularity, where the first and third hinge joint axes are aligned, corresponding to exactly the same rotation. In this configuration the system only has 3 effective degrees of freedom, while the inertia matrix is 4-by-4, and so the rank of the matrix becomes 3. People in robotics have worried about this problem for decades, and have designed various control tricks to avoid such configurations. MuJoCo issues a warning and silently replaces the zero with 1e-15.