Home >> Robot Arm Build >> Inverse Kinematics / Math for a Robotic Arm

Inverse Kinematics / Math for a Robotic Arm

This page covers a set of inverse kinematics which can be used to calculate the angles for a four degrees of freedom robot arm.

Essentially, what these calculations do is take a coordinate in 3D space [(5,3,2) for this example] and output the angles the robot arm has to adjust its joints to in order to end up at that point.

This page isn't entirely complete yet as I haven't built the actual robotic arm yet, but I figured that I might as well put up what I have so far. That way, I can just look back at this page if I forget something later on.

Although I haven't tried them with an actual robot arm yet, the calculations have been tested using a 3D CAD program to check the angles, and they seem to work.

The Inverse Kinematics for this Robot Arm:

Here is a zip file which contains the same calculations that are below this text. Robot Arm 2.zip. You will need to download and install Space Time to view the file. It has a free 30 day demo which should be plenty of time to play around with and understand the calculations.

 

It's possible that there might be a typo or two in the text below as I had to copy and paste it from the above Space Time file. The characters didn't always paste correctly, so I had to edit it after. For this reason, it would be better to just go ahead and use the Space Time program in case I missed something.

 

The Space Time program also makes it easy to re-calculate the angles of the robot arm using different coordinates.

 

 

3D Coordinate:

x=5

y=3

z=2

 

Length of Each Arm Section:

a = 5

b = 4

ed=1.5

 

More Variable Assignment and Actual Calculations:

xt=x

l = sqrt(x^2+y^2)

tn = atan(y/x)

 

x = l

z = z + ed

c = sqrt(x^2+z^2)

 

j2 = acos((a^2+b^2-c^2)/(2*a*b))

 

 

theta = acos((c^2+b^2-a^2)/(2*b*c))

ang = atan(z/x)+theta

j1 = atan(z/x)+theta

 

 

x1 = b*cos(ang)

z1 = b*sin(ang)

d = sqrt((x-x1)^2+( z-ed -z1)^2)

j3 = acos((a^2+ed^2-d^2)/(2*a*ed))

 

tn=atan(y/xt)

Answers: (If the coordinate (5,3,2) is used)
j2 = 97.54183
j1 = 77.76453
j3 = 94.69364
tn = 30.96376

Pictures:

You can see what the variables above are referring to in the pictures below.

Note: These calculations are set up so that the angle 'j3' will always point the arm segment 'ed' straight down.

Behind the Math:

I came up with these calculations on my own and would recommend that you try inventing your own inverse kinematics before copying anyone else's. You will understand it a lot better if you go through it step by step. You will also be able to customize it should you design a robot arm which differs from the one on this page.

There is more than one way to solve inverse kinematic problems, so you might be able to come up with a method for finding the correct answer that is more efficient than what I have provided.

I'm not going to go into too much detail right now, but I will point out what you can research if you want to understand the math on this page better.

Law of Cosines:
First up, there is the Law of Cosines. Check out this Wikipedia page and scroll down to "Applications" to see it in its simplest terms.

I used the law of cosines in several places. As long as you know the length of all three sides, you can find any of a triangle's three angles.

Converting between polar and Cartesian coordinates:
You should also look into converting polar coordinates to Cartesian coordinates. Check out this Wikipedia page and scroll down to "Converting between polar and Cartesian coordinates" if you want in-depth information.

Despite the length of the Wikipedia page, only the following is used in the inverse kinematic calculations above.

Trigonometric Functions:
Trigonometric functions can be found on this Wikipedia page.
The only one really used though, excluding that which is covered by the law of cosines, is theta = arctan(opposite/adjacent)

Pythagorean Theorem:
Wiki link

The Pythagorean theorem is used in several places to find the hypotenuse of a triangle.

For these calculations, the law of cosines requires all three sides of the triangle. Two of the sides are easy, the Pythagorean theorem is used to find the third side which isn't quite so obvious. (I know this sounds vague. Once (if) my robot arm is finished, I'll have to add some pictures to illustrate it better.)

 

Home >> Robot Arm Build >> Inverse Kinematics / Math for a Robotic Arm