mjStep resets joint angles

Discussion in 'Simulation' started by Ethan Brooks, Nov 25, 2017.

  1. Last edited: Nov 27, 2017
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    If mj_step detects very large numbers or nans, it automatically resets. It is possible that you are setting qpos to a value that is causing the simulation to go unstable, which then triggers the reset.

    What do you mean "setting qpos after mj_forward"? You should set it before mj_forward, otherwise the value you set is not being used in the computation...

    Also, the state of the system contains both position and velocity. Are you setting qvel as well?
     
  3. Sorry, that was a typo. So I set qpos and then call mj_forward. At this point, the model assumes the correct pose. Then when I call mjStep, the model snaps back to the previous position.

    After some further investigation, I realized that this was because my program was assigning new ctrl values between the call to mj_forward and the call to mj_step. These new values were responsible for step "resetting" the position of the model.