erwincoumans / motion_imitation

Code accompanying the paper "Learning Agile Robotic Locomotion Skills by Imitating Animals"
Apache License 2.0
1.13k stars 284 forks source link

[retarget_motion] Inverse Kinematics Issue with limits #42

Closed edgarcamilocamacho closed 3 years ago

edgarcamilocamacho commented 3 years ago

Hello.

When you call the Inverse Kinematics method, by here, you don't include the jointRanges parameter, and as I understand from the PyBullet documentation, don't including it implies that limits and rest pose are ignored.

When testing with Laikago, if you remove lowerLimits, upperLimits and restPoses when calling that function, the program works well too, so I think it is not necessary because optimizer is finding the correct solution first, without taking into account the joints limits.

But I am testing with other robot, and as inverse kinematics is not taking into account the joint limits, it is returning an incorrect solution. I have:

joint_lim_low = [-0.35, 0.0, -2.44, -0.35, 0.0, -2.44, -0.35, 0.0, -2.44, -0.35, 0.0, -2.44] joint_lim_high = [0.35, 1.57, 0.0, 0.35, 1.57, 0.0, 0.35, 1.57, 0.0, 0.35, 1.57, 0.00]

And I am getting out of the range values in joints 0 and 11:

joint_pose = [-0.37, 0.23, -0.34, 0.26, 0.14, -0.18, -0.22, 0.13, -0.22, 0.33, 0.17, 0.07]

This is the result of the inverse kinematics solution (see the rear right leg):

image

I tried to add the jointRanges parameter (as the difference of limits), but pybullet crashes (with both my robot and Laikago).

erwincoumans commented 3 years ago

We don't use joint limits. Make sure the orientation of the legs at the start is reasonable, and the motion capture data can be tracked without hitting the joint limits. Why would the legs 'flip' if the motion is reasonable? The IK uses the current joint angles as starting point and searches for the closest solution towards the target end effector.