

We've seen the forward kinematics problem. The inverse kinematics
problem is much more interesting and its solution is more useful.
At the position level, the problem is stated as, "Given the
desired position of the robot's hand, what must be the angles at all
of the robots joints?"
Humans solve this problem all the time without even thinking
about it. When you are eating your cereal in the morning you just reach
out and grab your spoon. You don't think, "my shoulder needs to
do this, my elbow needs to do that, etc." Below we will look at
how most robots have to solve the problem. We will start with a very
simple example.


The figure above is a schematic of a simple
robot lying in the XY plane. The robot has one link of length l
and one joint with angle Ø. The position of the robot's
hand is X_{hand}. The inverse kinematics problem (at
the position level) for this robot is as follows: Given X_{hand}
what is the joint angle Ø? We'll start the solution to this
problem by writing down the forward position equation, and
then solve for Ø.



X_{hand} = lcosØ
(forward position solution) 

cosØ = X_{hand}/l 

Ø = cos^{1}(X_{hand}/l) 


To finish the solution let's say that this
robot's link has a length of 1 foot and we want the robot's hand
to be at X = .7071 feet. That gives: 


Ø = cos^{1}(.7071) = +/ 45
degrees 

Even for this simple example, there are two
solutions to the inverse kinematics problem: one at plus 45 degrees and one at
minus 45 degrees! The existence of multiple solutions adds to
the challenge of the inverse kinematics problem. Typically we
will need to know which of the solutions is correct. All
programming languages that I know of supply a trigonometric
function called ATan2 that will find the proper quadrant when
given both the X and Y arguments: Ø = ATan2(Y/X). Now we have
the tools we need to look at a more interesting inverse
kinematics problem:
You may have to use your
imagination a bit, but the schematic above is the planar part
of the SCARA robot we discuss in the industrial
robots section. Here's the statement of the inverse
kinematics problem at the position level for this robot: 


Given: X_{hand}, Y_{hand},
Ø_{hand} 

Find: Ø_{1}, Ø_{2}
and Ø_{3} 


To aid in solving this problem, I am
going to define an imaginary straight line that extends
from the robot's first joint to its last joint as
follows: 



B: length of imaginary
line 

q_{1}: angle
between Xaxis and imaginary line 

q_{2}: interior
angle between imaginary line and link l_{1} 


Then we have: 




B^{2} = X_{hand}^{2}
+ Y_{hand}^{2}
(by the Pythagorean theorem) 

q_{1} = ATan2(Y_{hand}/X_{hand}) 

q_{2} = acos[(l_{1}^{2}
 l_{2}^{2} + B^{2})/2l_{1}B]
(by the law of cosines) 

Ø_{1} = q_{1}
+ q_{2 }
(I know you can handle addition) 

Ø_{2} = acos[(l_{1}^{2}
+ l_{2}^{2}  B^{2})/2l_{1}l_{2}]
(by the law of cosines) 

Ø_{3} = Ø_{hand}
 Ø_{1}  Ø_{2} 


That completes the
solution for Ø_{1}, Ø_{2} and Ø_{3}
given X_{hand}, Y_{hand}, Ø_{hand}.
Most inverse kinematics solutions at the position level
proceed in a similar fashion. You will use your knowledge of
trigonometry and geometry coupled with your creativity to
devise a solution. The solution given above works as is for
SCARA robots. If you can imagine turning the SCARA robot on
its side, then you will see that the solution above also works
for the positioning components of most six degree of freedom
industrial robots too. The inverse kinematics solution for
Cartesian robots is trivial as all axes are perpendicular by
definition and thus there is no coupling of the motions.
I recently noticed that there are number of folks that have
translated this solution into computer code. If you are
interested I'm sure you can find them with a little searching.
I saw a couple on GitHub.



