In continuation of my question on modified parameter for Puma 560 posted here Modified DH Parameters for Puma 560. Further I used a available dimension for Puma 560 here (FYI: the figure shows dimension in inches, but all following dimensions in DH parameters for length are converted to mm), [ and trial version of RoboDK simulator to check my result. I assigned the frame as show in the figure from first link, the last link is placed to the flange in the figure below with z6 pointing downward while keeping x6 in same direction as x5.
So the DH parameter looked liked, double alpha[6] = { 0, -90, 0, -90, 90, -90 }; double a[6] = { 0, 0, 431.80, 0, 0, 0 }; double d[6] = { 0, 0, 139.7, 433.07, 0, 55.88 };
I started with joint angles (theta) double theta[6] = { 0, 0, 0, 0, 0, 0 };
My calculations give me same position as Puma 560 simulator except z values are negatives. Correct position for joint angles of zeroes is x = 431.800, y = 139.700, z = 489.580. I get x = 431.800, y = 139.700, z = -489.580.
But if I put double d[6] = { 0, 0, 139.7, -433.07, 0, -55.88 }; then I get the correct value, x = 431.800, y = 139.700, z = 489.580.
I tested with other joint angles, for which I am getting correct values with negative -433.07 and -55.88 in above. So, they must be negatives.
My question is, why I have to take negative values for d to get correct result? Does this is because the value in this case should be assigned as per base frame (all value above base frame is assigned positive and all below should be assigned negative irrespective of convention.)
Base frame is located at same position as frame 1 (refer to the top most link) I used the same procedure as described in "Introduction to Robotics" by J.J. Craig.
EDIT: below is the codes I am using for the computation. Alpha and theta is converted to radians.
////// Craig Matrix - Modified DH Parameters Convention
mat[0] = cos(theta);
mat[1] = -1 * sin(theta);
mat[2] = 0;
mat[3] = a;
mat[4] = sin(theta) * cos(alpha);
mat[5] = cos(theta) * cos(alpha);
mat[6] = -1 * sin(alpha);
mat[7] = -1 * sin(alpha) * d;
mat[8] = sin(theta) * sin(alpha);
mat[9] = cos(theta) * sin(alpha);
mat[10] = cos(alpha);
mat[11] = cos(alpha) * d;
mat[12] = 0;
mat[13] = 0;
mat[14] = 0;
mat[15] = 1;
Above codes will give a 4 x 4 DH transformation matrix for each frame as per Modified DH conventions (Refer to Modified DH parameters on Wikipedia or J.J. Craig book, the matrix is defined there.)
Now, we multiply all matrices as per,
starting with matrix for frame 6 on the right hand side and multiplying it with preceding joint from left hand side. Repeating the same sequence as noted above. This should give as the location of origin of frame 6 with respect to the base frame of the robot.