inverse dynamics error

Discussion in 'Bug Reports' started by Coding Cat, Jun 27, 2018.

  1. I am using MuJoCo to obtain the inverse dynamics from mocap data.

    Firstly, I load in the mocap data into a mocap model (with mocap="true"), and constraint the joints into a physics model A with joints and motors. This step looks good.

    Next, I call the inverse dynamics, and from the document, I get qfrc_inverse.

    To test the value, I created another model B (the same as A), and set its qfrc_applied using the A.qfrc_inverse. And I keep the qfrc_constraint, efc_force the same as A. This step looks wrong. I used a walking motion. But for B, the legs are flying in the air. Some values are as large as thousand level.

    Is it the supposed pipeline? Do I need to set other values?
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    You should not be using mocap bodies, or setting qfrc_constraint etc. The steps are much simpler:

    Inverse dynamics:
    set qpos, qvel, qacc at each time step A. call mj_inverse(). save qfrc_inverse

    Forward dynamics:
    set qpos, qvel as before. set qfrc_applied to the qfrc_inverse data saved earlier. run mj_forward(). this should recover the corresponding qacc. or you can do it in a loop and call mj_step() to integrate.
     
  3. Thanks for your reply. This is also where confused me. From my understanding, setting qpos and qvel will force the model have exactly such joint angles. Because of it, it is not able to tell wether the qrfc value is valid if qpos and qvel is set. Do I have a misunderstanding?

    I found when I set qpos and qvel, the character will follow exactly the same as the qpos and qvel. That is, it will not be able to react to the external forces, or even not physically valid itself.
     
  4. Another question is what the expected qvel/qacc in mujoco. As MuJoCo doesn't use the cartesian coordinate system as the mocap system, is it still correct to calculate the angle velocity/acceleration directly? For example, if I have a the joint quaternions for each bones, is it correct to calculate the velocity as quaternion_next^-1 * quaternion_current, and use euler angle decomposition?