Society of Robots - Robot Forum

Software => Software => Topic started by: idee17 on November 29, 2012, 08:59:56 PM

Title: Inverse Kinematics Help
Post by: idee17 on November 29, 2012, 08:59:56 PM
     I have little experience with trigonometric functions, and was seeing if anyone can help me get some algorithms running for inverse kinematics. I have read of the robot arm tutorial with the inverse kinematics stuff and understood most of it, except the part with "psi" and "theta". I thought that those words are like variables that values assigned too (more programming experience then trig), if that's right, what symbol do they correspond to? Just one more thing, I'll be running the algorithms that are processing intense on my computer.   

psi = arccos((x^2 + y^2 - L1^2 - L2^2) / (2 * L1 * L2))
theta = arcsin((y * (L1 + L2 * c2) - x * L2 * s2) / (x^2 + y^2))
where c2 = (x^2 + y^2 - L1^2 - L2^2) / (2 * L1 * L2);
and s2 = sqrt(1 - c2^2);

~Thanks Idan
Title: Re: Inverse Kinematics Help
Post by: Joker94 on November 29, 2012, 09:55:26 PM
Psi and theta are just  Greek letters that are commonly used to represent angles when applying equations to a geometry scenario, such as you posted. There is not set value for this letter, essentially it is just a variable that can be used to represent an angle.It is more so convention that Greek letters are used to label angles.

When you are writing programs you don't have to use these symbols, you can use any unique letter in your program. For example Psi could be swapped for A and theta could be swapped for B to make programming simpler.


Title: Re: Inverse Kinematics Help
Post by: newInRobotics on November 30, 2012, 03:28:32 AM
Θ - theta
Ψ - psi
Title: Re: Inverse Kinematics Help
Post by: idee17 on December 03, 2012, 07:03:30 AM
Thanks for the fast responses guys, this will really help me out.
Title: Re: Inverse Kinematics Help
Post by: idee17 on January 22, 2013, 04:55:43 PM
I realized a couple days ago that I would need a robot arm with 4 DOF instead of the 3 DOF arm example. I have looked at various websites and haven't found the equations that do what is needed. Also, the base angle could be ignore and have the inverse kinematics work in 2D. If anyone knows how to do this or could point me in the right direction it would be appreciated.
The FBD is attached...

~Thanks Idan
Title: Re: Inverse Kinematics Help
Post by: jwatte on January 23, 2013, 10:50:42 AM
The thing with IK is that a two-segment IK has a closed form solution (well, two solutions, as it's a quadratic equation.) Three segments can still be reduced to two, if you use the first axis to select a solution plane and then sove the two-segment case. This is what I do for my quadroped walker, for example -- the hip points the legs in the right direction; the two knees position the tip of the foot in the right place.

For more than three segments, or for the case of three segments that are all co-planar, you no longer have a nice quadratic equation that gives you the solution. There are generally infinitely many solutions, and the math is not closed-form anymore. There are two solutions used in general: Iterative solutions, and overconstrained solutions.

The idea behind iterative solutions is that, if you start out with a particular solution, and then move the goal a small way, then you can look for the smallest delta to the IK solution that solves for the new goal. This is popular in animation software, for example, where two characters may be holding hands, and we want the contact point to be roughly between the center of gravity of the two characters. The draw-back is that you're not guaranteed anything in particular about the solution, because what it is depends on how you got there.

The idea behind over-constraining is to add constraints to the solution that aren't necessarily encoded in the physics, and thus reduce it to a set of two-segment problems you can solve in order. For example, for a three-segment leg, getting the toe-top at a particular point could be done where the last segments joint is positioned anywhere on a circle around the desired end point. If you define that the last segment joint should always be straight up from the contact point, for example, the circle collapses to a point, and you can solve the first two segments for that point, and then solve the last segment trivially to reach the goal. (The "walker" solution I suggest above is actually a special case of this method.)

So, if you're not comfortable with the math just yet, now's probably a good time to pull up the textbooks, or go to or to brush up on it!
Title: Re: Inverse Kinematics Help
Post by: idee17 on January 23, 2013, 11:00:57 PM
Thanks for the response, it answered a lot of my questions. I have been reading up on IK and think I have found a paper publish by MIT that seems to have all the information necessary to begin coding it into the algorithms to control the arm. I will most definitely read about the two solutions you mentioned and work on my math skills from some of those sites you mentioned, I haven't obtained the math skills yet  :'(  (in Algebra 2 right now). Tell me what you think about the paper, here is the link ↓ (

Title: Re: Inverse Kinematics Help
Post by: Gertlex on January 24, 2013, 01:01:01 AM
The book chapter/paper is an excellent find.  I saved a copy for my own reference.  It describes the same approach I've used for IK stuff, and is thus just what you need.
Title: Re: Inverse Kinematics Help
Post by: jwatte on January 24, 2013, 12:11:20 PM (

This is not actually a "paper" (as that typically means a peer-reviewed journal publication,) it is lecture notes / course materials for a class at MIT that teaches these things.
That being said, that's exactly what you want -- if you can figure this out, you'll be in good shape!
The more I get into robots, the more I find that the math I learned from computer graphics, animation, and physics simulation is totally applicable, btw. That shows all those who said computer games would amount to nothing ;-)
Title: Re: Inverse Kinematics Help
Post by: idee17 on January 24, 2013, 03:20:17 PM
Oh, never really knew the definition of a "paper" thanks for the advice =)  I'll start getting it coded for the robot arm. When ever i get it finish i'll be sure to post the code that i ended up with, for others to use...

ps: I going to keep playing and making computer games  :D

~Thanks Idan