Forward Kinematics 2D:
Problem:
Given the angles
and
, find the X and Y coordinates of the end effecter of a robotic arm with segment lengths a1 and a2 as shown.
First write the segments x and y as a function of the specified coordinates: The x and y coordinates of segment a1 can be written as:

Since the angle
is relative to the segment a1, the angle
can be defined as follows:
Since:

Then:

The x and y coordinates of segment a2 can be written as:

Therefore the total X and Y coordinates can be written as

Forward Kinematics: 3D
The arm also features base rotation so that there is some angle
as shown which rotates the arm into the z axis. Building on the 2D example, we now need to rotate the arm. The base rotation will not change the definition of the y coordinate. However the x coordinate will be projected onto the z axis as follows:

Where rx is 
Therefore by substituting rx into the above, the components can now be written as:

So given the angles
,
and
along with the segment lengths a1 and a2, the gripper will be positioned according to the above equations.
I wanted to build a robotic arm. The rssc competition for june deals with manipulation of objects.
I looked at different options and decided to build my arm from parts in the lynxmotion servo erector set.
Here is the parts list I used:
|
1
|
Description: Servo “Y” Adapter Cable |
1.95
|
1.95
|
|
3
|
Description: Servo Extender Cable - 12″ |
1.95
|
5.85
|
|
1
|
Description: Little Grip Kit (no servos) |
15
|
15
|
|
1
|
Description: Aluminum “C” Servo Bracket Two Pack |
7.95
|
7.95
|
|
1
|
Description: Aluminum Multi-Purpose Servo Bracket Two Pack |
11.95
|
11.95
|
|
1
|
Description: Aluminum Long “C” ServoBall Bearing Bracket Two Pack |
11.95
|
11.95
|
|
1
|
Description: Aluminum “L” Connector Bracket Two Pack |
5.95
|
5.95
|
|
1
|
Description: Little Grip Attachment Kit |
5.95
|
5.95
|
|
2
|
Description: Aluminum Tubing Connector Hub (pair) |
8
|
16
|
|
1
|
Description: Aluminum Tubing - 2.250″ |
2
|
2
|
|
1
|
Description: Aluminum Tubing - 3.375″ |
2.5
|
2.5
|
|
1
|
Description: Base Rotate Kit (no servos) |
19.95
|
19.95
|
|
1
|
Description: Aluminum Dual Servo Bracket - Black (Single) |
9.95
|
9.95
|
| |
Total |
|
116.95
|
I originally planned to use servos that I already had. I had purchased some Tower Pro servos. These are junk and should be avoided. I had a box full of GWS servos. Most of these are not the right size to fit the servo erector set brackets. I did end up using a couple of them but had several problems. Finally I broke down and bought some Hitec servos. The servo erector set is made for their exact dimensions.
I found an excellent online source for servos and purchased:
|
4
|
Hitec HS475 76 oz inch servo |
14.93
|
59.72
|
|
1
|
Hitec 645MG 133 oz inch servo |
25.99
|
25.99
|
| |
Total |
|
85.
|
I used HS475 servos for the base, shoulder and wrist joints. I used a 645MG for the elbow joint. The elbow joint has the greatest load, and the 645Mg has been a champ so far.
I used a cheap servo from the junk box for the gripper.
The total cost for the arm was around $200.
If you don’t want to build a servo controller then I would recommend either the SSC32 from lynxmotion for $39.95 or the pololu mini servo controller for $24.95
Lynxmotion has written an excellent assembly guide for this arm.
To the left is a picture of my completed arm.
Here is another interesting arm that can be made from servo erector set pieces:

I had an opportunity to play with Crayon Physics. This is a fabulous little game. I decided to start work on something equivalent using vpython. I thought it would be fun to write a physics engine relatively from scratch. I had done this years ago, but vpython really lets you ignore the code and concentrate on the physics. So far I have implemented code to create rectangles and have them collide with each other using an Oriented Bounding Box algorithm.
An Oriented Bounding Box algorithm works as follows:
- Calculate the vector from center to center for the two rectangles (Shown in white)
- Pick one of the four orange arrows from the center to a side. Calculate the projection(dot product) of the center to center vector on to this vector.
- Calculate the projection of each of the other orange vectors on to the vector you picked.
- Sum the projections.
- If the sum of the projections is greater then the projection of the center to center vector then that condition is true. (IE there could be contact along that axis)
- Repeat this process for each of the orange vectors.
- If all of these conditions are true, then the rectangles are intersecting.
While there were some useful hints on the web it took me a while to figure out that I needed to compute the projections of each of the vectors from the center to the side of the rectangle to the normals of each of the axis and thus there were four checks to make in 2d. I kept computing the projections of each of the four vectors to the x and y axis which was not a sufficient set of conditions (I searched for a math error for 20 minutes!)
This technique can easily be expanded into 3d, but there now six tests to do. You also need to test the cross products. More about this when I do it…..
Implementing conservation of linear momentum in the Center of Mass frame was a snap. I am still fighting with angular momentum a bit. I have the rectangles bouncing in the correct sense, but they are not transferring angular momentum appropriately.
I have been doing lots of thinking about how to visualize electric fields and build an intuition for E field interactions. I have written a program in python to visualize electric field vectors. I am still thinking about how best to do this. This evening I spent a couple of hours playing around with an idea of having a bunch of electrons fixed in 3D around an atom with a central nucleus. You control the charge on a particle (your ship.) You fly around by changing the charge on your ship and taking advantage of the interactions between the forces of the central positive nucleus and the charged electrons. The goal is to collide with each of the electrons in the atom.
I finally managed to get sound working using winsound calls.
The problem with this game is that:
- While the physics of the electrical interactions are modeled correctly the atomic model is wrong and reinforces a classical model of the atom.
- The game isn’t fun.
I am brainstorming about how to make the physics of the atom make more sense in the game, or I should just give up on the idea of the atom and have a bunch of point charges in space. (Perhaps if I put in some sort of feature where you observe the electrons to localize them and then their position evolves.) The problem is having something approaching a 20th century physical model.
Here is an executable of the game just for fun (Windows only) flyingcharge.zip
Vpython is a set of extensions to the python programming language designed to allow easy visualization and computational modeling for an introductory physics or engineering course. Since the goal is to have students develop their own models and simulations the IDLE environment is ideal. However, creating a stand alone executable would allow vpython based simulations to be deployed for students to use outside the programming environment.
Here are the steps to build an executable.
- Download PyInstaller. The latest version is 1.3
- Unzip it into a directory called pinst in the directory of your python install i.e. Python24 etc

- Run the file called Configuration.py in the pinst directory by double clicking on it. This will create a configuration file based on your version of python.
- To make PyInstaller compile Vpython files you will need to make the following modifications
- Download this version of build.py and copy it over the one in the pinst directory
- Download this version of bindepend.py and copy it over the one in the pinst directory
- Place your code in a directory called code
- Download the this make file and edit it so that it points to the .py file you want to compile.
- Run the make file. This will create an executable file that wraps up all of the python libraries.
- Test it!
- You can delete everything except for the executable.
Notes:
- py2exe is another program that can make windows executables from python source files. However, it does not like the numeric module and I am not a good enough programmer to make it work.
- PyInstaller also makes executables for linux and irix. following the directions here Unix/IRIX instructions
- This installer only works with the STABLE version of vpython found here. The BETA version 4 of Vpython use the Numpy library which is not correctly implemented in this installer. I spent a few minutes trying to work around it, but decided to wait until version 4 comes out of BETA. (Version 4 still seems very buggy to me!)
Here is a sample executable I built: pong.exe