# Using arm_kinematics, Inverse Kinematics Calculations fail

I've been going through the PR2 Kinematics tutorials, but using our own arm (http://www.ros.org/wiki/pr2_kinematics/Tutorials) and I've encountered a problem.

Using arm_kinematics (http://www.ros.org/wiki/arm_kinematics) in ROS C-Turtle, we're getting an Inverse Kinematics failed message.

I've also tried doing the forward-kinematics for an arbitrary robot pose, and then putting the result into the inverse kinematics request message. For some 'more complicated' poses (i.e. not very close to straight up) the inverse kinematics fails. For simple poses (close to straight up, all 0's) I can get a single inverse kinematic solution. The forward kinematics calculations look like they're all working correctly, however.

Any ideas of what I should look into?

Originally posted by John Hoare on ROS Answers with karma: 765 on 2011-07-11

Post score: 1

Are you filling in anything for the ik_seed_state?

FWIW, arm_kinematics was written because no generic IK solver existed for anything but the PR2. I acknowledge that it doesn't work in all situations, and welcome patches for my naive implementation of IK.

Originally posted by David Lu with karma: 10932 on 2011-07-11

This answer was ACCEPTED on the original site

Post score: 2

Comment by John Hoare on 2011-07-12:
Okay, I'll make sure to change around the seed states, I was using all zeros because thats what the tutorial was using, and I was modifying the goal state from there.

Comment by dornhege on 2011-07-11:
Depending on the arm configuration all zeros is actually quite likely a very bad seed state as it is likely causing singularities.

Comment by Pi Robot on 2011-07-11:
I find that seeding with the current joint_state rather than all zeros can also help find a solution more often.

Comment by egiljones on 2011-07-11:
For the kdl solver (which is the base of arm_kinematics), yes, you may need to start with different seed state positions, as local minima may prevent the solver from converging for certain seed states. Adding iterations should potentially help as well.

Comment by John Hoare on 2011-07-11:
Is the general approach to generate random configurations and try multiple times?

Comment by Sachin Chitta on 2011-07-11:
Try changing the seed state to not be all zeros. Use a random state (within joint limits). arm_kinematics uses a numerical solver unlike the pr2_arm_kinematics which uses a custom analytical solution. Numerical solvers can be very dependent on the initial seed choice.

Comment by John Hoare on 2011-07-11:
After changing the maxIterations, the search goes on for longer, but it still does not seem to find a solution.

Comment by arebgun on 2011-07-11:
Changing the number of iterations didn't help either?

Comment by John Hoare on 2011-07-11:
I am, and it was all Zeros, like in the tutorial. I'm able to find solutions to close to this, so I believe its probably a case of the solver timing out. However, I have a timeout of 10 seconds set, and its telling me no solution exists well before then.

Did you try increasing the number of iterations or increasing the timeout value? It might be that it's timing out or reaching iteration limit before finding any IK solution.

To change the maximum number of iterations of the IK solver, set maxIterations parameter of arm_kinematics node to some value:

<node pkg="arm_kinematics" type="arm_kinematics" name="arm_kinematics" >
<param name="maxIterations" value="5000" />
</node>


Originally posted by arebgun with karma: 2121 on 2011-07-11

This answer was NOT ACCEPTED on the original site

Post score: 2