Inverse Kinematics

Without knowing your arm configuration, let me just talk about calculating the base angle.
Calculating the base servo angle does not require Z, height above the table, at all.
With your arm on a table surface, imaging a 2 axis grid with the arm at the origin.
Assuming that you have a 180 degree servo on the base, you will use 1/2 of the grid.
Lets use the positive Y half. Quadrants I and II from the image below.

quadrants.jpg

I am going to use standard hobby servo degrees, where 90 degrees points directly up the positive Y axis. 0 degrees points left along the negative X axis and 180 points right along the positive X axis.
Look at this grid and the 6 example points on it.

grid.jpg

It is easy enough to see that for the sevo arm to point to E, the base servo should be at 90 degrees.
Point to G with zero degrees. And point to A with 180 degrees.
But how to calculate those angles mathematically?
Geometry to the rescue.
Arctan() gives us the results we want.
The servo angle is arctan(y/x) / PI * 180
Clearly we need to handle some edge conditions.
If X = 0 then the angle is 90.
If Y = 0 and X > 0 then the angle is 180.

So walk through the 6 point I pictured and calcualte the angle manually. What do you get?

grid.jpg

quadrants.jpg

1 Like