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.
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.
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.