CSC242 2003 Robot Kinematics

Matlab

You should use Matlab for this exercise: There are books in the bookstore: I think it's Introduction to Matlab for Scientists and Engineers by Dolores Etter. Here's a link to Amazon.com's page on it: MatLab Text .

Also there are reference books in the UG laboratory. One set is obvious a tutorial "getting started" set, the other is obviously a "reference" set, and soon to arrive is a reference for the image processing tooklit. Don't lose them. Of course feel free to help each other learn MatLab, share neat features you discover, etc.

ALSO there is on-line documentation: go to URL www.mathworks.com and follow the matlab link (to www.mathworks.com/products/matlab/ and go down and follow the Documentation link and there you are!

Multi-Link Arm

I'd like you to model a 3- or more- link arm. We'll talk strictly about revolute (rotational) joints below, but if you want to model prismatic (sliding) joints that's easy too. You can do what you like here, but the easiest sort of linkage to visualize is planar. If you want to model a 3-D arm, that would be fun too. The forward kinematics problem is: given the joint angles (three of them for a three-link arm), where is the endpoint of the last link (where a gripper would be). In Fig. 25.5, if you number the joints from 1 at the base to 6 at the tip, a 3-link planar arm would just use 2,3, and 5. A basic 3-link 3-D arm would use 1,2,3. Although you can assume that each link is a 1-dimensional line, and the next link rotates about the previous link's endpoint.

It's pretty easy, given the rotation angles, to compute where the endpoint is. It is simply the cascaded coordinate transformation induced by the length of the links and the angles of rotation. So e.g. say the link lengths are L1, L2, L3, where L1 is fixed to the world, L2 is in the middle, connected to L1 and L3, and L3 is the "final" link, only connected to L2. Say there are three rotary joints that allow these links to rotate through 360 degrees. Call the rotations R1, R2, and R3. Say R1, R2, and R3 are 0 when L1, L2, and L3 are laid out along the X axis. Positive rotations move the joints counterclockwise. Then to compute where the endpoint of L3 is: start at (0,0), and push the endpoint out along the X-axis by L3. Then rotate that endpoint around the origin by R3. Then push the result out along the X-axis by L2 and rotate by R2. Repeat with L1 and R1, and you're done.

Represent points by 2- (or 3-) dimensional column vectors (matrices, in Matlab), with the X coordinate in the first row and the Y-coordinate in the second. To rotate a point represented this way around T degrees, multiply its column vector on the left by the matrix

  cos(T) -sin(T)
  sin(T) cos(T)
  
If you have a little .m type function that constructs a rotation matrix for T degrees (actually you should use radians, but whatever...) called Rot(T), then (if I'm thinking correctly), the forward kinematics for our 3-link arm is
  X = Rot(R1)* (L1  + Rot(R2) *  ( L2  + Rot(R3)*( L3))) ,
  Y              0                  0               0
  
where * is matrix multiplication, + is vector (matrix) addition, and the clumsy stacked Li's and 0's are column vectors. For 3-D you need to be able to rotate around a different axis, which means you go to 3x3 matrices. See any relevant book or me.

The output of this expression is the X, Y vector giving the (x,y) location of the end of the robot arm. You will probably also want to keep track of the intermediate joints of the arm so that you can use the Matlab graphing facilities to draw the links instead of just the tip position. You should see how to use subsets of the above equation to compute the positions of the end of the first and second links.

What is NOT so easy is the inverse problem: given (x,y), what are R1, R2, and R3? This is clearly a very useful problem, since it says: I want to reach to this spot in space, how do I set my joint angles to get there. You and I do this sort of thing all the time! There can be a single answer, several answers, or no answer in general.

For your assignment, you should implement a kinematic robot arm simulation, demonstrate that it works to your satisfaction, and then explore such things as its working volume (or area). The input to your simulation might be a "moveto(t1, t2, t3)" sort of command, which just sets the three joint angles to the indicated values. Your kinematics-only simulation will instantaneously go to the required coniguration. Any assumptions about joint angle limitations are extra, if you want to do that. A "moveby(dt1, dt2, dt3)" command is sometimes fun (good for commanding trajectories)...it increments joint angles rather than resets them. Not much intellectual difference. Your matlab output can be just the position of the end effector (if you are interested in graphically illustrating the working volume, say); note that you can plot lots of points at once or sequentially plot things to make a movie. It is also fun to draw the arm, which amounts to plotting the positions of the joints and joining them with lines. This way you can make a movie of your arm reacting to commands. You are to think about how you might solve the inverse kinematic problem. You might first experiment with different combinations of link lengths to see how you can easily create arms that can't reach every point in their working volume (long first link and very short 2nd and 3rd, for instance). You might use Matlab to draw some pictures showing the arm moving around.. maybe the 1st joint moves slowly, the 2nd moves a little faster, the 3rd faster? You can get crude animation just by plotting the results as you generate them. Save some plots for your writeup.

Back to inverse kinematics: can you solve the equations? If so how, if not why not? (See any robotics book). Could you learn the answer? If so how, and why not implement it? What occurs to me is just a look up table, possibly with interpolation. You can systematically set known values of the three joint angles and remember the resulting position. Then you have to "invert" this mapping so you can find the angles given the position you want. You would probably want to interpolate between the closest positions if you don't want one you previously memorized exactly. The problem is interesting because there may be multiple solutions, the interpolation problem is not linear.

If you want to go a little farther, you might explore "trajectory generation", in which you want a sequence of joint angle settings that take you through a desired trajectory (just a straight line is plenty hard enough). In this problem you can run across "singularities", where you can't continuously get from one point to the next, even if they are very close, without lots of joint motion.

In any event, please give me your best idea about how to solve the inverse kinematic problem (feel free to consult any robotics book you can find). The more detailed and the more implemented your ideas, the better. Trajectories are a natural extension that add lots of interest.

Neural Nets

You might decide to construct a "neural" net to learn this inverse kinematic mapping. I recommend implementing the algorithm of Fig. 19.14 with sigmoidal activation functions. NNs are very naturally expressed in arrays, so this is a natural application. Your code should be general as regards number of input, output, and hidden units, and their connectivity, and also learning rate (alpha in R&N). You may even want more than one layer of hidden units. For the inverse kinematics problem, I figure two inputs (x,y) , 3 outputs (R1, R2, R3). In training, you supply an (x,y) and the net comes out with an R1, R2, R3 (presumably random at first). You use R's to construct the true (x, y), and you thus have an error with which to do back propagation. This is risky; I'm not sure there's enough structure to have the net converge.

Due Date and Grading

Due Date: As per WebCT assignment.

Total of 140 points: Content: 100 points, Presentation: 40 points.

[ csc242 Home ]