ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Mon, 04 Mar 2019 10:25:57 -0600KDL Inverse Kinematics for a Hexapodhttps://answers.ros.org/question/317025/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,
AlessandroThu, 28 Feb 2019 06:49:46 -0600https://answers.ros.org/question/317025/kdl-inverse-kinematics-for-a-hexapod/Answer by tfurgerson for <p>Dear Community,</p>
<p>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. </p>
<p>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). </p>
<p>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). </p>
<p>I would really appreciate any answer or suggestion. Thanks for your time.</p>
<p>Best Regards,</p>
<p>Alessandro</p>
https://answers.ros.org/question/317025/kdl-inverse-kinematics-for-a-hexapod/?answer=317447#post-id-317447Try this:
<pre><code>
/* 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;
}
</code></pre>
HTHMon, 04 Mar 2019 10:25:57 -0600https://answers.ros.org/question/317025/kdl-inverse-kinematics-for-a-hexapod/?answer=317447#post-id-317447