#### ECE 452: Robotics, Algorithms and Control final project, spring 2014. This project was developed by Bryan Bickel.

**Project Objective:**The objective of this project was to develop a program which would animate the movement of a serial link robotic manipulator in MATLAB. The program was to implement a graphical user interface (GUI). The problem statement defines the number of links, the initial twist coordinates, the initial configuration of the manipulator, velocity, and the end point as the user input.

**Project Methodology:**Because the program needed to work with any serial link manipulator that the user could specify, “End point” was assumed to be a vector specifying the end value of each joint’s variable.

### Part 1: The ~~Easy~~ Hard Way

A command line program (one utilizing the command window and work space in MATLAB) was first developed to gather and interpret user data. An example manipulator was programmed in to streamline testing.
The program gathered N, the number of joints, and then ran a for loop N times to gather information on each joint. Points qi, a 3 by 1 vector, and the joint twist zeta_i, a 6 x 1 vector, were gathered in the for loop.
Once the joint information was gathered, the initial transformation matrix gst(0) was created for each point qi. This matrix was equal to [R P; 0 1] where R is the 3×3 identity matrix and P is the vector qi. 0 a 1×3 vector of all zeros, and 1 is 1×1 and equal to 1.
Another for loop gathered the end point data which consisted of each joint’s ending angle and the frame in which it would reach this angle by. This allows some joints to move quickly through their angle and others to move much more slowly.
Once all the information was gathered, each animation frame was created through a for loop. Each iteration of the for loop would create the twist hat matrix [ OmegaHat, v; 0] where OmegaHat is the skew symmetric matrix created from the twist’s axis w and v is the twist’s velocity. A twist is a 6×1 vector consisting of 2 3×1 vectors [v; w]. Lowercase v is velocity and w is the axis.
Each joint’s zetaHat matrix is multiplied by the joint’s ending angle Theta and the frame count/the joint’s end frame. This quantity is then passed to MATLAB’s “expm(<var>)” function to create the matrix exponential. The code snippet is:
zetaTheta = expm(zetaHat*(endTheta(1)*(thetaFrame(1)/thetaFrameEnd(1) )));
The matrix exponential is used to create the matrix gst(t) for each point qi by multiplying the exponential matrix by the original gst(0). The vector P inside each gst(t) matrix is extracted and plotted using scatter3 and plot3 to create our animated robotic manipulator. Getframe and Movie are used to create the animation.
The command line program is available for download here: https://copy.com/z41DpJzmonSw
### Part 2: The Easy ~~Hard~~ Way

**The GUI**was developed utilizing code adapted from the above example. It was developed using MATLAB’s built in GUI editor, GUIDE. The final version of the GUI has several built in examples and also accepts user input. A screenshot of the final GUI is shown below: The GUI went through several iterations until the simplest, easiest to use form was decided on. The options were labeled as intuitively as I could make them. On the left, the

**“End Frame”**option allows the user to edit how long the animation should run for. The

**“Number of joints (q)”**option allows the user to specify how many points, which represent each joint, in the manipulator.

**“Autocreate Twists”**allows the user to decide if the computer should create the twists using Twist = ( -w x q; w) where w, v are 3×1 vectors representing the axis and point q. The twist is a 6×1 vector. The autocreate feature only creates revolute joints. If the joint is prismatic, you will have to edit it (while the ‘autocreate’ checkbox is unchecked) to be Twist = ( w, 0) where w and 0 are 3×1 vectors specifying the axis and 0 is all zeros.

**“Normalize w and create Theta”**normalizes the axis and uses the magnitude as the value for each joint’s end Theta. The

**popup box labeled “Twists zeta”**in the screenshot allows the user to examine the matrices representing points q, axis w, twists zeta, ending angles, and the ending frames in the table. Each column represents data pertaining to the column number’s joint. (Column 1 represents q1 when q is selected. Column 4 would represent q4.)

**“Flush All Tables to MATLAB”**saves all of the variables specified in the GUI to the work space in MATLAB’s command window. On the right side, starting in the top, are the example manipulators. Most of the examples pick random values for end frame and ending angles. Screenshots of the simulation and their real life counterparts are shown below: The Kraft Viper Manipulator was also simulated, but because of it’s unique geometry, I recommend using another program that can visualize the wire frame of the manipulator. The jaws opening is represented by point farthest left in the screenshot. The prismatic joint does work, but the entire jaw mechanism is represented by two points at the left of the picture, which does not visually represent the manipulator well. Real life Kraft Viper Manipulator:

### Downloads:

The GUI is available under the University of Illinois/NCSA License (when applicable, like when Mathwork’s license does not apply) and without warranty of any kind from here: https://copy.com/EjaTS8faXvBb The command line program is available for download here: https://copy.com/z41DpJzmonSw### References:

In order to develop the GUI, I used a lot of reference material put together by Mathworks as well as some code snippets provided by people on their forums. The mathematics were taught by Professor Zefron during lecture. Dr. Zefron also provided notes over the course blackboard site. Course material was adapted from the following books: Howie Choset et al., Principles of Robot Motion: Theory, Algorithms, and Implementations, MIT Press, 2005. Murray, Li, and Sastry,*A Mathematical Introduction to Robotic Manipulation*, CRC Press, 1994. The images used above to illustrate real life examples were found using a google image search. The uArm photo is from: http://technabob.com/blog/wp-content/uploads/2014/01/uarm-desktop-robot-arm-by-ufactory.jpg The SCARA photo is from: http://www.scielo.br/img/revistas/jbsms/v24n3/16743f5.gif The Kraft Viper photo is from: http://karczmarzepolisty.files.wordpress.com/2014/01/screen-shot-2014-01-08-at-10-20-11.png

### MATLAB Tutorial:

I found the documentation explaining how to easily do what I needed done to be quite lacking. The hardest part of making the GUI was guessing what was wrong and trying to understand how different the GUI programming is from normal MATLAB. I’ve put together some easily explainable screenshots to help people quickly learn how to use GUIDE.**Callbacks:**Callbacks are the bread and butter of using guide. There are different types based on the user interface you are editing. Just right click whatever you want to edit and view the callback in the editor. It makes zooming through 1000 lines of code so much faster. Now that you have the editor open to the callback you need to edit, here is some key concepts that I thought took too long to find answers to: Some key things that are really useful:

**Saving data in handles:**by default, when you edit handles, it does not actually save the data like we’re used to in normal MATLAB operation. Make sure to call “guidata(hObject,handles)” to save the data structure. This took forever for me to understand what was going on.

**Exporting data to MATLAB’s Workspace:**This would have been extremely useful if I had found it way earlier. Use “assignin(‘base’, ‘WorkSpaceVariableName’, variableName) ;” to save variableName into the normal workspace/command window we know and love. It will be saved as “WorkSpaceVariableName”.