Errors in Inertia Matrix

Discussion in 'Simulation' started by yongxf, Dec 20, 2016.

  1. Hi there,

    I try to obtain the Inertia matrix using the following code (in Mujoco 131), and I found an error: the diagonal entry always add 4*10^{-4} to the specified value.

    Code:
    mjtNum* dense_M = mj_stackAlloc(d, m->nv*m->nv);
    mjtNum* M_hand = mj_stackAlloc(d, (m->nv - 3)*(m->nv - 3));
    mj_fullM(m, dense_M, d->qM);
    cout << "dense M" << endl;
    mju_printMat(dense_M, m->nv, m->nv);
    For example, when I specify the following entries in the .xml model:
    Code:
    <inertial pos="0 0 0.14" quat="1 0 0 0" mass="0.555555" diaginertia="0.011111 0.01 0.01"/>
    I get the following inertia:
    0.55595500 0.00000000 0.00000000
    0.00000000 0.55595500 0.00000000
    0.00000000 0.00000000 0.01151100

    No matter how large I specified, the error will always be 4*10^{-4}

    Is this a potential bug? Do you use specified value or use the output value during computation?


    Thanks,
    Best regards,
     
  2. Is it because numerical consideration, i.e. to avoid singularities? so you choose to add \espilon I in M matrix?
     
  3. Emo Todorov

    Emo Todorov Administrator Staff Member

    The joint-space inertia matrix M reflects both the masses and inertias of the bodies making up the model. It is difficult to calculate this quantity by hand and figure out what it should be.
     
  4. Oh, I didn't calculate by hand. I specified them in the xml model. I expect the system can output the specified value. For example, when I specify mass = "0.555555", I expect 0.555555 appears in joint space inertia matrix. However, it didn't. Rather, the 0.555555 + 4e-4 appears in the M matrix when I print it to screen. (no matter what value I specified, I observe the same gap 4e-4).

    The inertia matrix is used in my controller. I have to make sure the inertia Matrix in my controller is consistent with the value in the simulation. If you use 0.555555 + 4e-4 all the time in Mujoco, then I will use 0.555555 + 4e-4. But if in your simulator, you use 0.555555, then I have to subtract 4e-4 from the printed value.


    I can feel that Mujoco uses 0.555555 + 4e-4 all the time, just want to make sure.

    Thanks,
    Best
     
  5. Emo Todorov

    Emo Todorov Administrator Staff Member

    You cannot specify the joint-space inertia in the XML. The only thing you can specify is the rigid-body inertia and mass. The joint-space inertia is then calculated automatically, and the relation is not always obvious. It depends on what degrees of freedom you have in the model, where the joint centers/axes are relative to the bodies etc. MuJoCo does not add small constants to the inertia calculation.
     
  6. Thanks Professor,

    You are correct. The reason that there is a 4e-4 gap is because I set the joint armature='0.0004' as default. But I never notice this when adding joint in order to simulate planar object grasping. Now the result seems reasonable.

    Thanks again!

    Merry Christmas!
     
    Xinghao Zhu likes this.