IK with rotational constraint #1944
-
Hello, I have been able to build off of the following code for IK with positional constraints: https://github.com/stack-of-tasks/pinocchio/blob/master/examples/inverse-kinematics.py Note that I am doing IK with a model that has a
inside the end of the optimization loop, and the positional constraint is met. My issue is that while the positional constraint is met, the base of the robot is rotating freely in 3D. I would like to restrict it to only rotate in 2D (i.e. on the ground). My attempt was to add:
inside the end of the optimization loop, however, this IK call never seems to converge. I am certain that an IK solution exists, as I have verified this by doing the IK on a model without the Any ideas about how else I could try to enforce this base rotational constraint without having IK diverge? Any help will be much appreciated, thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You can formulate your IK as having two tasks:
When there is more than one task, the Jacobian matrices and vectors can be stacked, see e.g. this tutorial on weighted inverse kinematics. Be careful that the Jacobian for your rotational task should include a |
Beta Was this translation helpful? Give feedback.
-
Thanks so much for your suggestion. I was able to achieve what I wanted to with the use of |
Beta Was this translation helpful? Give feedback.
You can formulate your IK as having two tasks:
When there is more than one task, the Jacobian matrices and vectors can be stacked, see e.g. this tutorial on weighted inverse kinematics. Be careful that the Jacobian for your rotational task should include a$log_6$ (
pin.log6
function) as explained in this note on pose task Jacobians. (In case of doubt, you can always take a look at theFrameTask
in Pink, it handles these caveats.)