Robotic Arm Fundamentals
Figure 6. The rotational position of the
base is also easy to calculate.
to such a problem is to
isolate all the motor related
commands to a single
module. Let’s see how that
might work.
Assume we have
a subroutine called
MoveArm that performs
the task of moving the arm
based on the value of
three variables: Base,
Elbow, and Shoulder.
If any of these variables
contain a zero, then that
joint will not move when the subroutine is called. If one or
more of these variables contain a number (such as 1 or -1),
then the associated joint will move that many degrees (in this
case, one degree) either forward or backward, depending on
the sign of the number.
Furthermore, we will assume the MoveArm subroutine
somehow reads sensors (in the case of DC motors) or
keeps track of the current joint positions (for stepper or
servomotors) and places the current angle for each joint in
the variables ElbowAngle and ShoulderAngle. Changing
one line of code in the simulation lets it emulate how the
elbow motor is mounted (as discussed earlier) so you can
experiment with both configurations.
The subroutine MoveArm also assumes the
variable InHand is zero if no object is being held or is
a number from 1 to 3 to indicate which block the hand
holds. This variable could be set by code that keeps track
of where the objects are or by analyzing camera data as
mentioned earlier.
Before calling MoveArm, your code can set the variable
Vac to true or false to make the arm pick up or release
objects (the simulator won’t let you release an object unless
the end-effector is near the work surface).
As stated earlier, the details of how this subroutine
operates for a real arm will depend on the motors used, as
well as the type of ports and the buffering circuitry. Since
this article is about programming the arm itself and not
about building a motor interface, we will assume the subroutine MoveArm already exists. This works out perfectly for our
simulated arm because we provide a MoveArm subroutine
that works exactly as described above.
Notice the power of the above principle. Using this
strategy, anyone can learn how to program an arm no matter
what motors it might eventually use or even if it never exists
at all. Then later, if a real arm becomes available, all the
same code can be used with it if an appropriate MoveArm
is written.
At this point, we are ready to begin programming.
All we need is an interesting application – something
complex enough to be fun and challenging, but yet not too
complex since this is an introductory article. After careful
thought, this is the chosen application.
Figure 7. This 3D simulated arm was written
with RobotBASIC.
A = arcTan(S/(L/2))
We still need the values for both L and S in order to
calculate A. The value of S can be calculated using the
Pythagorean theorem:
S = Sqrt((L/2)2 + C2)
This means we can determine the angles to use for
the shoulder and elbow joints if we know the distance from
the arm’s base to our destination point (L). Normally the
destination point for our arm would be in terms of an X, Y
coordinate as shown in Figure 6. Notice we again have a
right triangle so that the distance L can be calculated using
the Pythagorean theorem. Also, in the same manner as
before, we can calculate the angle of the base.
These calculations may seem complex but they are easily
implemented in any language that has the appropriate math
functions. The important thing is that it is easy (at least for
our simplified arm) to calculate the angles for the base,
shoulder, and elbow needed for any x,y position on the
working surface. Since our simplified model does not stack
blocks to any appreciable height (the blocks are made of thin
paper or cardboard), these calculations will work for isolated
blocks or stacked blocks anywhere on the work surface.
Enter The Matrix
The x,y positions of objects to be manipulated could be
chosen manually or from images from a web cam mounted
above the work surface. RobotBASIC has vision commands
that make it easy to import web cam images and extract
position data for objects of specified colors.
We realize that many people might want to experiment
with an arm of this type, especially if they did not have to
build or buy the arm. To that end, we have used RobotBASIC
to implement a simulation of a 3D arm identical in operation
to this one. Figure 7 shows a screenshot of the simulated
arm. In the simulation, the x,y coordinates of four locations
have been manually specified.
Normally, if we are programming a real arm there will be
significant changes to the code depending on the types of
motors and sensors used for the construction. One solution
42 SERVO 05.2009