I recently retired and one of things I promised myself was that when I did retire I was going to complete all those projects I had running around inside my head since I was a teenager. That's about 50 years or so of projects. In those days there were no microprocessors and you needed your own machine shop to make the mechanical parts.
One of the projects was building a robot arm from the ground up. Kits are nice, but its all done for you and you never quite learn all the in's and out's of the project. Besides, I always wind up tinkering with them anyway to make them work the way I what them to work.
Among those things that I learned and was needed for the project was to overcome the mechanical challenges of designing and building the arm, forward and inverse kinematics to control the positioning of the arm, and developing the software to control the arm. Thankfully, there is a lot of information out there on the web to help with all these topics.
In this Instructable I want to show you what I came up with using pretty much all off the shelf parts from ServoCity (great source of supply) as well as sharing the information I used for this build to help you in your own projects. Unfortunately, I did not think of doing an Instructable until after the arm was completed so the only thing missing will be the length of the screws used in the build.
P.S. This is my first attempt at an Instructable so be kind.
Special Thanks
I want to thank the following tinkers and builders for their efforts that aided me developing the software for this project:
Travis Wolf for his blog on Inverse Kinematics, Operational space control of 6DOF robot arm with spiking cameras part 2: Deriving the Jacobian and for taking time to answer several questions.
Quark for his excellent G4P library for Processing 3.0 and for resolving several challenges at the Processing Forum as well as GoToLoop.
bboner's Robotic Arm with Arduino driver controlled by Leap Motion at letmakerobots for the the base code and ideas for the Processing GUI and Arduino sketch.
Yes folks, it's still all about doing your homework before you start one of these projects. For me I started with the basics and a good summary on robot arms is the Robot Arm Tutorial at the Society of Robotics web site. To quote the author:
"The robot arm is probably the most mathematically complex robot you could ever build."
Believe me I found this out when I had to develop the equations for forward and inverse kinematics - but with that said I did find a few easy ways to get this done as will let you know as we go along. I will also you all the additional resources/references at the end of this tutorial that I used.
ServoCity:
Pololu.com
Amazon.com
Robotshop.com
This is rather simple:
Down and Install the following Software if you don't already have it on your computer
I am going to assume here that the reader knows how to install applications in their respective OS's as well as installing Arduino libraries.
Instructions for using the Maestro Control Center is provided by Pololu, strongly suggest that read it before setting up your servos: 4. Using the Maestro Control Center.
The SPG785A-BM Servo comes with detailed instructions for assembly, however, we will need to make a minor change to accommodate the 1" Hub Spacer.
What you will have to do is to assemble the Hub Gear with the smooth side up with 3/4 or 1 inch truss head 6-32 screws. First step will be to grab the tube clamp that comes with the Gearbox, the Hub Spacer and one of the screws to start with. Line up the screw holes in the spacer, tube clamp and gear tightly together and attach the three pieces the screw. If you don't hold the three parts tightly you will wind up with a gap which you don't want. It is easy enough to fix by backing off on the screw and then re-tighten again after you get a better grip. You will have to do this in three other places. This is shown in the first photo in this step.
Once you have this assembled attach the base servo with one of the 12 in servo extension cables to channel 0 of the mini-Maestro and connect it with a mini-USB cable to the computer. Double click on the Maestro Control Center Icon and it should automatically connect to your mini-Maestro Controller. On the control panel "Status" tab enable channel 0 and center the servo at 1500 (by the way this is in micro seconds). With the servo still connected insert the gear assembly onto the hub with the alignment line pointing forward and push down in accordance with the supplied instructions. Now the fun begins.
Move the slider on the "Status" tab up to adjust the max value of the servo so that the line moves 180 degrees. Determine what the max value at 180 degrees is on the status tab and adjust that value on the "Channel Settings" tab. If moving the slider does not move the servo 180 degrees increase the value of the max setting on the "Channel Settings" tab and click on the save button. Go back to the Status tab and continue moving the slider until the servo moves 180 degrees. Then go back to the Channel Setting tab, change the max value to what you have on the status tab and click save.
Follow this same procedure for finding min value for 180 degrees in the opposite direction. Don't forget to click the save button. When finishing you should name the channel to "Base".
While on the Channel Setting tab set the "On Startup Error" to 'GoTo' so that the servo defaults to 0 degrees. The settings for my servos are shown in the Channel Setting photo.
On the "Serial Settings" tab your settings should be the same as shown in the photo above.
Now, would be a good time to mount the Arm Base to a piece of ABS, HDPE or your material of choice that is about 8" W by 15" L and about 1/8" thick. Use the holes in the Arm Base as your guide and mark the base plate appropriately. I used a piece of ABS and drilled four holes with a ?? drill and used 1/4" long 6-32 screws.
For this step you will need the SPG785A1-5 Servo Gearbox (7:1), the 90 degree 1" bore tube clamp and a 12 in servo extension cable..
First attach the Gearbox servo to channel 1 of the Mini-Maestro and configure the servo settings.
Next move the servo to center (neutral) or 0 degrees, approximately 1500 on the Control Center and attach the 1" bore tube clamp so that it is aligned with 0 degrees and tighten the hex screw with the 7/64 in. hex wrench.
This part can be a little trick. Take two 1/4" pan head screws and fit in the bottom holes of the Shoulder gearbox at 0 deg and 180 deg. If the 1/4" long screws use a shorter screw. Align the holes with the 0/180 deg holes on the 1" hub space on the Base gearbox. Tighten the screws with a philips head screwdriver. I used the iFIx screwdriver for this - fit nicely in tight quarters. You will have to angle the screwdriver to make this work. NOTE: If I had to do this over i would have got the unassembled version.
This step follows the exact same procedure as the Shoulder Assembly (Gearbox) as in Step 5 with the exception that the servo is connected to channel 3 of the Mini-Maestro, the name on the "Channel Settings" tab should be "Elbow", Speed should be set at 10 and "GoTo" should be at about -135 degrees. Don't forget to attach the 1" 90° Bore Tube Clamp (545464) and tighten the socket screw.
For this step you will need the following:
First step in the assembling the sub-assembly is to mate the Hub Adapter with the 1" Bore Clamping Hub A. Align the holes of the Adapter and Clamping Hub. Take the 1/2" socket head screws (4) and screw the two parts together with 7/64" hex wrench.
Next step is a little tricky as you will not be able to tighten nut on the truss head screw directly. First take one of the 3/8" truss head screws and slide it through the thru hole in the upper left corner of the Quad Hub Mount as shown in the figure. Slide the Hub Adapter onto the screw and align the clamping hub as show in the sub-assembly figure. Once you have done this back off on the screw until it is flush with Hub Adapter and place the screw plate over the screw - now tighten the screw.
Now take the tubing and place it in the Clamping Hub and tighten down on the socket head screw to lock the tubing in place. Make sure it is as tight as you can get it.
Next take the sub-assembly and insert it into the bottom of the servo gearbox. Lock the sub-assembly in place with the (4) remaining socket head screws.
Next take the two extensions springs and link them together. Take one end of a spring and slip it between the tabs of the 90 degree bore clamp. Slide the tightening screw through the holes and loosely tighten the socket head screw prior to attaching the elbow assembly. See the attached photo.
Final step is to mate the elbow with the shoulder. Take the elbow assembly and slide the tube into the 90 deg Clamping Hub of the Shoulder Assembly. The distance between the Shoulder Clamping Hub and Elbow Clamping Hub is approximately 1.25" Tighten down on the socket head screw in the clamp.Double check the distance between the centers so that is as shown in the figure.
Be careful when you let it go as at this point the arm is not balanced so once you let it go it will drop like a rock.
For this step you will need the following:
Assembly is pretty straight forward for this assembly:
Additional parts needed for this step:
Slide the forearm assembly into the elbow right angle bracket. The distance between the center line of the elbow joint and the right angle bracket should be 3.75". Once you have the correct distance tighten the tube clamp screw so the forearm does not move. Make sure that the bracket is level.
Take the Bore Tube Clamp D and attach the end of the spring as shown in picture. Loosely tighten the screw. Slip the clamp onto the end of the forearm aluminum tube and tighten the screw on the clamp.
Parts you will need for this step:
Servoblock assembly instructions are provided by ServoCity as a YouTube video, however, a better set of instructions can be found on YouTube: First Look at ServoBlocks (from servocity.com).
Parts needed for this step:
Attach the pitch hub plate to the flat dual channel `channel bracket on the forearm with the (4) truss head screws. The roll servoblock should be just about over the center line of the base gearbox
Slide the servo cables through the aluminum tubing and use the servo cable servo extensions to connect the three servos to the Mini-Maestro. You should now have a working robot arm that can be controlled through the mini-maestro.
Next set of steps is setting up the electronics for the Arm.
Parts needed for this step:
Perf Board:
Place your components:
Wiring the electronics:
Take a male-female jumper and connect the connect it to the output (-) of the variable regulator breakout board and the other end to the Vin pin of the mini-Maestro.
Take a male-female jumper and connect the connect it to the Rx pin of the mini-Maestro and the other end to pin 11 of the Arduino
Take a male-female jumper and connect the connect it to the Tx pin of the mini-Maestro and the other end to pin 10 of the Arduino.
Lets look at some of the elements of the Arduino sketch before you start trying to use it to move the arm.
The first is the how we tell the sketch the parameters for the servos, since we are using the mini-Maestro library. I did this by setting up a array of structures, each setting the parameters for the arm servo (lines 31-43 of the sketch
struct maestro_parameters { // servo_channel, name, min, max, home, speed, accel, and neutral come // directly from the min-maestro channel settings tab so it is a good // idea to take a screen shot and print it out. int servo_channel; char servo_name[20]; int servo_min; int servo_max; int servo_home; int servo_speed; int servo_accel; int servo_neutral; // The next two variables are required for Arduino mapping function. We will be mapping degrees to // microseconds. fromLow corresponds to the servo_min and and fromHigh corresponds to // servo_max. // If we use the shoulder as an example if your servo_min value is 672 microseconds, // which would correspond to +180 degrees and your servo_max value is 2248 microseconds // which corresponds to -180 degrees the fromLow and fromHigh values would be +180 // and -180 degrees respectively int servo_fromLow; int servo_fromHigh; // The next two variables are used to set the servo constraints. In, other //words the max allowable travel for each of servos int servo_constLow; int servo_constHigh; } servo[6];
Specific values for the servos are set at lines 66-71. For my arm these would be:
servo[0] = (maestro_parameters) {0, "Base", 1064, 1663, 1366, 0, 0, 1504, -90, 90, -80, 80}; servo[1] = (maestro_parameters) {1, "Shoulder", 672, 2248, 2040, 40, 0, 2040, -180, 180, -10, 180}; servo[2] = (maestro_parameters) {2, "Elbow", 928, 1872, 1738, 10, 0, 1505, 180, -180, -160, 45}; servo[3] = (maestro_parameters) {3, "Wrist_Pitch", 928, 2128, 928, 10, 0, 1500, 0, 180, 0, 180}; servo[4] = (maestro_parameters) {6, "Wrist_Rotate", 608, 2448, 1500, 40, 0, 1500, 90, -90, -90, 90}; servo[5] = (maestro_parameters) {7, "Gripper", 1312, 1792, 1358, 7, 0, 1500, 0, 10, 0, 10};
Let's talk about the mapping function for a few seconds. In general the mapping functions is of the following form:
servoPosMs = 4*map(servoPosDeg, servo[servoNum].servo_fromLow, servo[servoNum].servo_fromHigh, servo[servoNum].servo_min, servo[servoNum].servo_max);
For reference we have to multiply the resulting mapping value by 4 since the mini-Maestro library works is expecting values in 1/4 microsecond increments. What i found was that the mapping function was inaccurate for the shoulder and elbow servo gearboxes, it was off by a couple of degrees which caused inaccuracies in positioning the servo arm. What I wound up doing is creating my own linear regression curves for these servos and embedding them in the curve. This was done in sketches moveServo() function.
Let's take a look at this function:
void moveServo() { // The Constrain function limits the servo movement so you do not overdrive the arm into positions you // do not want servoPosDeg = constrain(servoPosDeg, servo[servoNum].servo_constLow, servo[servoNum].servo_constHigh); //Mini Maestro values given in 1/4 ms so you have to multiply by 4. if(servoNum == 1) { servoPosMs = 4*(4.4406*servoPosDeg+1491.1); } else if(servoNum == 2) { servoPosMs = 4*(-2.4208*servoPosDeg+1436.2); } else { servoPosMs = 4*map(servoPosDeg, servo[servoNum].servo_fromLow, servo[servoNum].servo_fromHigh, servo[servoNum].servo_min, servo[servoNum].servo_max); } //Serial.println(servoPosDeg); // setSpeed tells the servo how fast you want the servo to move, // set Target tells the servo where to move maestro.setSpeed((uint8_t) servo[servoNum].servo_channel, (uint16_t) servo[servoNum].servo_speed); maestro.setTarget((uint8_t) servo[servoNum].servo_channel, (uint16_t) servoPosMs); // The while loop is here to tell the sketch to wait till the servo has finished moving before // sending a done message while(maestro.getMovingState() == 1) { //Serial.println("Moving Servo"); }; //Serial.print ("Position is: "); //Serial.println (maestro.getPosition(servo[servoNum].servo_channel)); Serial.println ("Done"); }<p> Serial.println ("Done");</p><p>}</p>
In the posted sketch I have commented out the lines for linear regression. You will have to determine whether you need this or not. Basically tell the servo to move to the +90 or -90 (depending on the servo) and see if it really is at 90 degrees. If you feel as if this is not satisfactory use the Maestro Control center to move the servo to 0, 90 180 degrees (see figure), copy the microsecond values and use MS Excel to do a linear trend line (make sure you tell it to show the equation.
To test the sketch, load the sketch into the Arduino. When finished loading open up the Serial command window and send commands to arm in following form:
servoNum, Target Degrees
Example,
0, 25 then hit return key
This moves the base servo to the left by 25 degrees.
By way of summary:
Servo Num | Servo |
---|---|
0 | Base |
1 | Shoulder |
2 | Elbow |
3 | Wrist Pitch |
4 | Wrist Rotate |
6 | Gripper |
Ok now the fun can begin.
Open Processing and load the Robot Arm.ino file. Click on the run button and you should see the GUI pop up.
First thing you will have to do is to select the Com port that the Arduino Uno is attached to which is done in the drop list in the upper left hand corner of the corner.
Second, click on the Toggle button to enable the arm - this was a fail safe i built in. Now their are two ways to make the arm move. The first is with the sliders. Moving the sliders will move the respective joint in the arm The second way is to move the 2d Inverse kinematic slider on the left middle of the GUI. This will tell the arm to move x distance away from the base and tell it how high off the ground it should be.
If you enable the Forward Kinematic toggle you will see that the two distances match.
If you enable the Fixed Axis toggle you will have the option to set a fixed position for the gripper. "Normal" makes the gripper align with the vertical, "Parallel" makes it stay parallel to the ground, and "Parallel to Arm" makes it stay at the same angle as the forearm. To use this feature you have to have the Forward Kinematic toggle enabled.
A couple of other features:
Reset Arm Button: Sends commands to the arm to move it back to the default (startup) position
Record: Logs your movements to the default file created when you start the sketch. To use what you will have to do is to use the Close button when you finish whatever it is you wanted to record, then use the Open button and select the file you want to play back. To play back your movements use the Play Back button.
Some suggestions:
As promised here are a few references that you might be interested in:
Solved Problems in Robot Kinematics Using the Robotics Toolbox by Federico Thomas
Denavit-Hartenberg Reference Frame Layout -YouTube
Spong Kinematics, Chapter 3 and 4