Ask Your Question
0

KDL Inverse Kinematics for a Hexapod

asked 2019-02-28 06:49:46 -0500

cr055 gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-03-04 10:25:57 -0500

tfurgerson gravatar image

updated 2019-03-04 13:28:52 -0500

Try this:

    
/* Adapted from pypose:
 * 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
    ans.coxa = radToServo(atan2(X,Y));
    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);
    ans.femur = radToServo(q1 + q2);

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

    return ans;
}

HTH

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-02-28 06:49:46 -0500

Seen: 146 times

Last updated: Mar 04