Robotics CITS3241


Exercise Sheet 3: Playing with Denavit-Hartenberg Matrices

A three link 'Puma' style robot has the following link parameters

link variable theta offset length twist
1 theta1 theta1 d1 0 pi/2
2 theta2 theta2 0 l2 0
3 theta3 theta3 0 l3 0

Write a MATLAB m file

  function [T] = DHtrans(theta, offset, length, twist)
that takes the four Denavit-Hartenberg link parameters and constructs a transformation matrix representing the coordinate frame at the end of the link.

Remember the D-H transformation is

T = rotz(theta) * trans(0,0,offset) * trans(length,0,0) * rotx(twist);

  = [ cos(theta) -sin(theta)*cos(twist)  sin(theta)*sin(twist) length*cos(theta)
      sin(theta)  cos(theta)*cos(twist) -cos(theta)*sin(twist) length*sin(theta)
          0             sin(twist)             cos(twist)         offset
          0                 0                      0                 1           ];

Use the function DHtrans() and the plotframe() function you wrote last week to construct a function

  function puma3dof(theta1, theta2, theta3)
This function takes the three joint angles, calculates the forward kinematics of the Puma arm and plots a stick diagram of the arm along with the link coordinate frames displayed using plotframe.

Your function will need to specify the appropriate D-H parameters for a Puma arm. Choose link lengths/joint offset values of say, 3, so that the coordinate frame plots are not larger than the link lengths. As before you will need to initialise and 'hold' a set of 3D axes within which you will do your plotting.

Write a small function that calls your puma3dof function in a loop that varies the three joint angles to give you an animation of its motion.

MATLAB programming note

MATLAB allows you to build structures on the fly. For example, the following code
  a(1).width = 1;  a(1).height = 2;
  a(2).width = 4;  a(2).height = 5;
constructs a two element array called 'a'. Each element of a has two fields, one called 'width' and the other called 'height'.

When writing your code it would probably be nice to construct a 'link' structure that stores the angle, offset, length and twist values for each link of your robot.

A 'Stanford Arm' style robot has the following link parameters

link variable theta offset length twist
1 theta1 theta1 d1 0 pi/2
2 theta2 theta2 0 0 -pi/2
3 d3 0 d3 0 0

Remember the Stanford arm consists of a vertical rotary axis, followed by a horizontal rotary axis, followed by a final translation axis that extends in and out.

Write a function

       stanford3dof.m(theta1, theta2, d3)
This function takes the two joint angles and the prismatic extension of the last link, and calculates the forward kinematics of the Stanford Arm. Again you should plot a stick diagram of the arm along with the link coordinate frames displayed using plotframe.

Work out the zero position of the arm - it will help you understand your results!

Note: To write this function you should only have to modify puma3dof.m by a very small amount.

Some example images of what you should get

Portfolio Note

Save listings of DHtrans, puma3dof and stanford3dof. They will be required for your portfolio.


Copyright © 2002-2007
School of Computer Science & Software Engineering,
The University of Western Australia.