Page 114 - The Definitive Guide to Building Java Robots
P. 114
Preston_5564C03.fm Page 95 Wednesday, October 5, 2005 7:21 AM
CHAPTER 3 ■ MOTION 95
The arm in the next example will have one more servo than the Lynxmotion 5 Axis arm
above. This arm will have a total of six servos to control, and because this time I want to eliminate
the jerky movement, I will use the LM32 controller and class.
The arm will have the following degrees of freedom shown in Table 3-1.
Table 3-1. Arm Servos and Descriptions
Servo Name Function
Shoulder Rotation Servo This rotates the arm left and right around its base.
(Shoulder left-right)
Shoulder Elevation Servo This moves the upper arm up and down next to its base.
(Shoulder up-down)
Elbow Servo This move the elbow up and down relative to both its base
appendage to wrist appendage. (Bicep - Triceps)
Wrist Servo This moves the wrist up and down relative to its elbow.
(Forearm)
Gripper Rotation Servo This rotates the gripper left and right the same way that your
wrist turns left and right. (Wrist)
Gripper Servo This opens and closes the gripper. (Fingers)
Code Objectives
The objectives here are the following:
• To model the human arm the best we can so that it’s fluid and does not require a lot
of coding.
• To write an application class similar to what we did with the basic arm.
Code Discussion
Before I create the ComplexArm class, I need to keep more information available than just the
position of an arm and its pin number. To store this information, I extended the ServoPosition
class and added three additional fields: min, max, and neutral. This additional information will
come in handy when moving six servos since we are moving slowly from one position to another
over a certain amount of time. I also need to use these data structures because the LM32 uses
a string of servo positions per command rather than sending them out individually. (See
Example 3-17.)