site_xpos is not updating after calling mj_kinematics or mj_forward

Discussion in 'Simulation' started by Phani Teja, Oct 11, 2018.

  1. Hello,

    I have been trying to check simple forward kinematics and see what will be the positions of my sites without using mj_step. However, when I use mj_kinematics or mj_forward none of the values of site_xpos in mj_Data updates. Can you please tell me where I am doing wrong and how can I go about this? Also what does mj_kinematics and mj_forward do internally when I run them? Does it effect anything in mj_Data?
     
  2. I am also facing the same issue with mj_kinematics. Could someone guide us on how to deal with this, please?
     
  3. Emo Todorov

    Emo Todorov Administrator Staff Member

    Both mj_kinematics() and mj_forward() should update mjData.size_xpos... can you post a model where you observed this behavior? Also, which version of MuJoCo are you using, and are you calling it from C/C++ code or via a Python wrapper?
     
  4. I am using mujoco150 and the code is in C++.
    I was assigning a value to d->ctrl and then called mj_kinematics/forward. This did not update the site_xpos.
    However I observed that if I assign a value to d->qpos directly and then call mj_kinematics, the same seems to work and site_xpos is updated.
    why is this happening? I have attached my xml file.
     

    Attached Files:

  5. Have you tried step() (ing) the simulation?
     
  6. Emo Todorov

    Emo Todorov Administrator Staff Member

    mj_kinematics and mj_forward do not advance the simulation. They compute kinematic and dynamic quantities for the current timestep, and the controls do not affect the positions within a single timestep. You have to integrate forward in time, using mj_step.