osudrl/cassie-mujoco-sim

How to use sim.set_qpos() to set only part of the qpos?

Closed this issue · 2 comments

When I am trying to use sim.set_qpos() to set only part of the joints, say, only knee joint, the achilles will still be at their original position rather than connected to the heel spring. How can I fix this issue?

I believe the achilles position is constrained by the equality constraint defined in the xml file. If you just use the initial qpos for the achilles joints and change the others, the constraint will be violated. I believe the way to solve it will be using inverse kinematics to calculate the corresponding qpos that satisfies the constraint. Or you can let the simulation run for a few iterations (you can keep the knee joint to the desired value via PD control), the constraint should be enforced by the simulator automatically.

Thanks, I have found using the simulation to enforce the constraint is a good way.