Inverse kinematics advice #378
-
Given a kinematic reference state for each body in global space (6 DoF), what's the best way to project it to a joint space state, in order to use it as reference to calculate errors (and torques) for an actuated kinetic chain? The current way I handle it is based on the modeling docs. I have a humanoid, mocap bodies for each of its segments, and a duplicate copy of the humanoid with collisions and joint dynamics turned off (I'll refer to this second humanoid as "kinematic humanoid"). Each segment of the kinematic humanoid is paired up with the mocap bodies with weld constraints. Then, differences are calculated from the joint states of the original, kinetic humanoid and the kinematic humanoid. To update the reference, the mocap bodies are moved to the next frame of the animation. Does anyone have experience/advice for this issue? Is it better to handle inverse kinematics via projection matrices (or attempt to, as there may not always be one)? Is it better to use weld constraints or rotation ones for the non-root bodies? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Your approach is sort of a physics-based IK (we call it "puppeteering"). It works, but is not the classic way of doing IK, which is based on the kinematic Jacobians. Here is a Python-based example. |
Beta Was this translation helpful? Give feedback.
-
I for one do not understand why folks go for the mocap-based hack in MuJoCo. There is a trove of literature on inverse kinematics, especially in the context of controlling humanoids. For instance, what you describe is exactly what the Jacobian does - mapping a change in joint positions to a change in Cartesian pose - and MuJoCo gives you that analytically and for free (unlike other simulators). Take advantage of it! Here are 2 references to quickly read on the matter: For humanoids, my understanding is that constraints end up clashing so hierarchies/stacks of tasks are implemented and solved with QP-based approaches (I think Nicholas Mansard is an expert here, might be worthwhile perusing his Google Scholar page). For simpler robots like a 6/7-DOF arm, differential kinematics (using a jacobian pseudo-inverse + feedback loop) is enough. So my recommendation is rather than writing your own IK solver from scratch, potentially look at what other libraries do. I've heard good things about pinnochio. You'd probably need an interface to convert the MJCF to whatever it ingests. A google search seems promising. And pink seems to be a new python-based IK package for humanoids that leverages pinnochio under the hood. Finally a shameless plug: I had to write a pseudo-inverse IK implementation for a humanoid hand. Each finger of the hand is an end-effector which is quite similar to the humanoid setup where the hands and the feet are the end-effectors. You could take a look at the implementation to see what was done. Hope it can be useful. |
Beta Was this translation helpful? Give feedback.
Your approach is sort of a physics-based IK (we call it "puppeteering"). It works, but is not the classic way of doing IK, which is based on the kinematic Jacobians. Here is a Python-based example.