How to calculate the inertia?

Discussion in 'Modeling' started by Rian Jo, May 2, 2019.

  1. Hi,

    I would like to calculate the inertias of two articulated bodies.

    First, I created a floating body in the XML with a diaginertia. When I tried to the inertia information from mjData->cinert with one body, it gives me diagonal inertia as I inputted.

    However, when I created two linked bodies in the XML with the diaginertia, I can't get the diagonal information from mjData->cinert.

    My testing model is attached below.

    And I tried to read by,



    for (int i = 0; i < 2; i++)
    {
    for (int j = 0; j < 3; j++)
    for (int k = 0; k < 3; k++)
    _inertia_CoM_mjc[j][k] = mjData->cinert[i*10 + j * 3 + k];
    }

    It seems that mjData->cinert gives diagonal elements in the first three components when I tried with one body. However, I'm not sure that with two bodies.

    How can you calculate the inertias of linked bodies?

    And in what order does mjData->cinert give?

    Thank you.
     

    Attached Files: