# How do I find the inverse kinematics of a 5-DOF manipulator having the following DH parameters?

alpha = [ -90,   0,   0, 90,   0]
a     = [   0, 400, 200,  0,   0]
d     = [63.5,   0,   0, 90, 100]


I am trying to calculate the joint angles but I am stuck after I got the values of Theta1 and Theta2.

If you say you're are stuck after values for the first two angles, you are probably trying an analytical approach. Try solving for IK using standard techniques Jacobian Pseudo Inverse or Cyclic Coordinate Descent. If you are looking for immediate solutions, use Peter Corke's Robotic Toolbox for MATLAB or KDL/TracIK in C++/Python to obtain the values.

• CCD looks like an interesting technique, new to me! This looks like a good reference (now in my reading pile): L. -. T. Wang and C. C. Chen, "A combined optimization method for solving the inverse kinematics problems of mechanical manipulators," in IEEE Transactions on Robotics and Automation, vol. 7, no. 4, pp. 489-499, Aug. 1991. doi: 10.1109/70.86079 – Peter Corke Jan 19 at 22:22

A general IK solution is not possible for an arm with less than 6 joints. You can move the gripper to any point (within reach) but you can't completely control the orientation. If you fix the orientation, say fingers aligned with vertical axis (normal to the work surface), this should simplify the analytic solution.

Using my Toolbox, and starting with the DH kinematic parameters you provide (and assuming they are standard DH, you didn't specify)

>> robot = SerialLink( [zeros(1,5); d; a; alpha*pi/180]')
robot =
noname:: 5 axis, RRRRR, stdDH, fastRNE
+---+-----------+-----------+-----------+-----------+-----------+
| j |     theta |         d |         a |     alpha |    offset |
+---+-----------+-----------+-----------+-----------+-----------+
|  1|         q1|       63.5|          0|    -1.5708|          0|
|  2|         q2|          0|        400|          0|          0|
|  3|         q3|          0|        200|          0|          0|
|  4|         q4|         90|          0|     1.5708|          0|
|  5|         q5|        100|          0|          0|          0|
+---+-----------+-----------+-----------+-----------+-----------+


To get a feel for the robot I drive a graphical model around interactively and choose a reachable point with the gripper fingers downward

>> robot.teach
>> T = transl([550 90 0]) * trotx(180, 'deg')
T =
1     0     0   550
0    -1     0    90
0     0    -1     0
0     0     0     1


Now I can solve for the inverse kinematics

>> robot.ikine(T, 'mask', [1 1 1 1 1 0])
ans =
-0.0000    0.2694   -0.0017   -0.5561         0


where the mask has only 5 ones in it, the Cartesian degrees of freedom we want to control. In this case we accept that we cannot independently control rotation about the z-axis. We can verify the IK solution

>> robot.fkine(ans)
ans =
0.9587         0   -0.2845       550
0         1         0        90
0.2845         0    0.9587 1.916e-11
0         0         0         1


and see that it does give us the desired position, rightmost column, but the rotation matrix is not what we asked for, because rotation about z-axis is chosen for us.

• I tried your function earlier but I got this for some target positions: Warning: ikine: rejected-step limit 100 exceeded (pose 2), final err 0.000175207 > In SerialLink/ikine (line 244) Warning: failed to converge: try a different initial value of joint coordinates > In SerialLink/ikine (line 273) – Amit Deka Jan 21 at 8:16
• @Amit, you need to be sure the pose is reachable, and sometimes you need to provide good estimates of the joint angles (which is a bit self defeating). You could try the ikunc() function if you have the MATLAB Optimisation Toolbox installed. – Peter Corke Jan 21 at 11:44