Link to this document's Jupyter Notebook

In order to successfully complete this assignment you must do the required reading, watch the provided videos and complete all instructions. The embedded survey form must be entirely filled out and submitted on or before 11:59pm on on the day before class. Students must come to class the next day prepared to discuss the material covered in this assignment.


Pre-Class Assignment: Robotics and Reference Frames

Image of a 6-axis FANUC robot used in industry

Image from: www.fanuc.com

Goals for today's pre-class assignment

  1. Review
  2. 2D Forward Kinematics
  3. Assignment Wrap-up

Reference: https://studywolf.wordpress.com/2013/08/21/robot-control-forward-transformation-matrices/


1. Review

QUESTION: Matrix $A$ is of size ($m_1 \times n_1$) and matrix $B$ is of size ($m_2 \times n_2$). What must be true about the dimensions in order to multiply $A \times B$?

Put your answer here

QUESTION: The following transformation matrix will move points in $R^n$ dimensional space. What is $n$?

$$ \left[ \begin{matrix} \sin{(\theta)} & -\cos{(\theta)} & 0 & d_x \\ \cos{(\theta)} & \sin{(\theta)} & 0 & d_y \\ 0 & 0 & 1 & d_z \\ 0 & 0 & 0 & 1 \end{matrix} \right] $$

Put your answer here

QUESTION: The above matrix rotates around which axis?

Put your answer here

QUESTION: In the above matrix, how do the scalar values $d_x, d_y, d_z$ influence the transformation?

Put your answer here

QUESTION: Compute $2u+3v$ for vectors $u = (1,2, 6)$ and $v = (4, -1, 3)$.

Put your answer here

QUESTION: What is a homogeneous system of linear equations?

Put your answer here


2. 2D Forward Kinematics

This robot can move in the $x-y$ plane. We can represent the configuration of the robot in its "Joint Space" by knowing the two joint angles or $[a_1,a_2]$. However what we would like is to represent the location of the end of the robot (often called the "end effector" or "hand") in "world" coordinates (i.e. $x-y$ coordinate system).

Today, we will use Linear Algebra and simple transformation matrices to try and calculate how to go from "joint" coordinates to "world" coordinates.

Single axis Robot

The following code draws a simple single axis (single joint) robot with its joint centered at the origin and its initial angle of zero with an robot arm length of 4 "units" long.

A 2D rotation matrix around the origin is defined as the following:

$$ \left[ \begin{matrix} x_{end} \\ y_{end} \end{matrix} \right] = \left[ \begin{matrix} \cos(a) & -\sin(a) \\ \sin(a) & \cos(qa \end{matrix} \right] \left[ \begin{matrix} x_{start} \\ y_{start} \end{matrix} \right] $$

The following rotation matrix will rotate the point $45^o$ around the origin:

The following code uses the Jupyter interact function and numpy to make an interactive view of the above. This lets us change the value of the rotation motor and see how it changes the robot. The input to the function is the axis angle and the output is the $x-y$ coordinates.

Note: it can take some time for the interaction to catch up. Try moving the slider slowly...

DO THIS: Inspect the above code.

QUESTION: Which line of the code defines the transformation matrix for the robot joint?

Put your answer to the above questin here.

QUESTION: Which line of code defines the length of the robot arm?

(Note you can turn line numbers on and off in jupyterhub. Use the menu at the top to figure out how.)

Put your answer to the above question here

Multi axis robot

Now, let's consider the robot from the video:

Notice it has two joints $a_1$ and $a_2$ and offset lengths of $d_1$, $d_2$ and $d_e$. The joint space for this robot is just its angles $[a_1, a_2]$. However, what we want is to know the location of end effector point $p_e$ at the gripper in the "world" reference frame, which the bottom most axies "on the ground".

At each joint, we can define a reference frame that rotates and then transforms the origin to the ealier joint. The forward transformation matrices capture the relationship between the reference frames of different links of the robot.

For example, We can move from the base motor, or $p_1$, reference frame to the world, or $p_w$, reference frame using the following equations:

$$ p_w = \left[ \begin{matrix} \cos(a_1) & -\sin(a_1) \\ \sin(a_1) & \cos(a_1) \end{matrix} \right] p_1 + \left[ \begin{matrix} 0 \\ d_1 \end{matrix} \right]. $$

The equation shown above are a little tricky to work with because the$ \left[ \begin{matrix} 0 \\ d_1 \end{matrix} \right] $ part makes the equation non-linear (if you don't believe me? Remember the rules for making a function linear and apply them and see for yourself). However, there is an easy trick in Linear Algebra to convert the above to one big linear matrix. This trick requires us to keep an extra 1 (one) for each point but makes the math work out nicely. Basically the trick works as follows:

$$ \left[ \begin{matrix} x_w \\ y_w \\ 1 \end{matrix} \right] = \left[ \begin{matrix} cos(a_1) & -sin(a_1) & 0 \\ sin(a_1) & cos(a_1) & d_1 \\ 0 & 0 & 1 \end{matrix} \right] \left[ \begin{matrix} x_1 \\ y_1 \\ 1 \end{matrix} \right] $$

Let's call the transformation matrix for Joint 1, $J_1$, and we can rewrite the equations as follows:

$$p_1 = J_1p_2$$

DO THIS On your own, write out the above matrix multiplication and convince yourself that it is the same as the one above.

Now, we can move from the $p_2$ reference frame to the $p_1$ reference frame basically the same equation:

$$ \left[ \begin{matrix} x_1 \\ y_1 \\ 1 \end{matrix} \right] = \left[ \begin{matrix} cos(a_2) & -sin(a_2) & d_2 \\ sin(a_2) & cos(a_2) & 0 \\ 0 & 0 & 1 \end{matrix} \right] \left[ \begin{matrix} x_2 \\ y_2 \\ 1 \end{matrix} \right] $$

For the last step we can do a simple linear transpose from the end effector $p_e$ reference frame to the $p_2$ reference frame:

$$ \left[ \begin{matrix} x_2 \\ y_2 \\ 1 \end{matrix} \right] = \left[ \begin{matrix} 1 & 0 & d_2 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{matrix} \right] \left[ \begin{matrix} x_e \\ y_e \\ 1 \end{matrix} \right] $$

If we call each transformation matrix $J_1, J_2, J_e$ then hopefully you can see that we can string these transformation matrices together such that we get a single transform from the end effector all the way back to the world coordinates as follows:

$$p_w = J_1J_2J_ep_e$$

Let's see what this looks like in Python. I am going to use numpy. The plotting gets a little awkward but hopefully it makes sense.

First, lets initialize the variables to some discreet numbers:

Next, I am going to define a set of points in the end effector coordinate system. These points are picked to form a sort of "C" shaped designed to look sort of like an end effector. I will plot them to help show you what I mean:

The next step is to apply the $J_e$ transformation matrix to the gripper points which will put them in the $p_2$ coordinate system. Once the points are transposed the code concatenates the origin (0,0) onto the list of points so we can part of the robot arm in the plot:

We do this again. Apply the $J_2$ transformation matrix to put the points into the $p_1$ coordinate system, concatenate the origin and plot the results.

We do it yet again. Apply the $J_1$ transformation matrix which will put the points in the $p_w$ coordinate system, concatenate the origin and plot the results. The result is a skeletal frame representing our robot.

DO THIS: Modify the rotation variables a1 and a2 in the above code and see if the new robot configuration looks right. HINT make sure your angles are in radians.

The following is the same code as above but put into an interactive function to make the code easier to play with:

Note. If the interact plot is really choppy on your machine this is because the function is coninuously updating as you move the sliders. Consider replacing the interact function with interact_manual to eliminate the continuous updates. You will have to change the import code in line 1.

QUESTION: Move the above robot so that the end effector is "gripping" the target (yellow/orangeish star). Notice that there is more than one point in the "joint space" that gives the same answer. This is the reverse Kinematic problem (which is harder). We know the point we want but we need to find the joints that put the robot at that point.

Put your answer to the above question here.

DO THIS: The code in the following cell is cut and pasted from above. Modify the code to add a third Joint to the robot.

QUESTION: Do the reverse Kinematics again, and find three angles that place the robot on the star.

Put your answer to the above question here.


3. Assignment wrap-up

Please fill out the form that appears when you run the code below. You must completely fill this out in order to receive credit for the assignment!

Direct Link to Google Form

If you have trouble with the embedded form, please make sure you log on with your MSU google account at googleapps.msu.edu and then click on the direct link above.

Assignment-Specific QUESTION: What three angles did you find that place the robot on the star.

Put your answer to the above question here

QUESTION: Summarize what you did in this assignment.

Put your answer to the above question here

QUESTION: What questions do you have, if any, about any of the topics discussed in this assignment after working through the jupyter notebook?

Put your answer to the above question here

QUESTION: How well do you feel this assignment helped you to achieve a better understanding of the above mentioned topic(s)?

Put your answer to the above question here

QUESTION: What was the most challenging part of this assignment for you?

Put your answer to the above question here

QUESTION: What was the least challenging part of this assignment for you?

Put your answer to the above question here

QUESTION: What kind of additional questions or support, if any, do you feel you need to have a better understanding of the content in this assignment?

Put your answer to the above question here

QUESTION: Do you have any further questions or comments about this material, or anything else that's going on in class?

Put your answer to the above question here

QUESTION: Approximately how long did this pre-class assignment take?

Put your answer to the above question here


Congratulations, we're done!

Course Resources:


Written by Dr. Dirk Colbry, Michigan State University Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.