ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

# KDL Inverse Kinematics for a Hexapod

Dear Community,

lately I have been working on a Hexapod robot and I have got to the point of having the urdf defined and the forward kinematics solved by it. At this point I have realized that solving the inverse kinematics for this class of robots is not a straightforward task.

By reading online I have found the KDL package which could be a solution to my problem, but I am having some difficulties in understanding how to properly use it (I am not really good in this things).

I would like to ask if you know any tutorial I could follow or any reference which might be useful in order to solve the IK of my Hexapod robot (even suggesting alternative methods).

I would really appreciate any answer or suggestion. Thanks for your time.

Best Regards,

Alessandro

edit retag close merge delete

Sort by » oldest newest most voted

Try this:


* Simple 3dof leg solver. X,Y,Z are the length from the Coxa rotate to the endpoint.
*/

ikSolution_t calcLegIK(s32 X, s32 Y, s32 Z)
{

ikSolution_t ans;
s32 trueX;
s32 im;
float q1, q2;
s32 d1, d2;

// first, make this a 2DOF problem... by solving coxa
trueX = sqrt(X*X + Y*Y) - COXA_LENGTH;
im = sqrt(trueX*trueX + Z*Z);    // length of imaginary leg

// get femur angle above horizon...
q1 = atan2(Z, trueX);
d1 = (FEMUR_LENGTH*FEMUR_LENGTH) - (TIBIA_LENGTH*TIBIA_LENGTH) + (im*im);
d2 = 2 * FEMUR_LENGTH * im;
q2 = acos((float)d1/(float)d2);

// and tibia angle from femur...
d1 = (FEMUR_LENGTH*FEMUR_LENGTH) - (im*im) + (TIBIA_LENGTH*TIBIA_LENGTH);
d2 = 2* TIBIA_LENGTH * FEMUR_LENGTH;

return ans;
}


HTH

more