Page 98 - The Definitive Guide to Building Java Robots
P. 98
Preston_5564C03.fm Page 79 Wednesday, October 5, 2005 7:21 AM
CHAPTER 3 ■ MOTION 79
and legged robots, I’m going to be working with more than two servos, sometimes up to 12 in
the case of the Extreme Hexapod 2. I’ll also want to have the same level of speed control as I did
with two servos, and also coordinate the moves of more than one servo at the same time.
In this example, I want to focus on making my robot solve higher-level problems like navi-
gation instead of devoting all my code and CPU cycles to managing servo control. Fortunately,
there’s a new servo control on the market with all of those features: the Lynxmotion SSC-32
(see Figure 3-9). This servo controller allows for speed control and timing. We’ll use it when
discussing advanced servo controls and group moves.
Figure 3-9. The Lynxmotion SSC-32 Servo Controller
The Lynxmotion SSC-32 servo controller has 32 output pins compared with the eight pins
of the MiniSSC-II. It also allows the same protocol of communication, so if you create some
code for the MiniSSC, you can reuse it with the SSC-32 and can increase the baud rate to 115,200.
Thus, when we model this controller, we can implement the same SSCProtocol interface, but
because it comes with some other built-in features like grouped and timed moves, we’ll want
to add a new protocol called the GroupMoveProtocol.
Although this protocol is really useful with the LM32, you can also write a class for the MiniSSC
to implement the interface. Then you should be able to use Plug N Play (PnP) hardware without
changing much software.
Using the GroupMoveProtocol is different than the SSCProtocol for three reasons: one,
you can group a number of servos together in a single command instead of sending command
strings to each servo; two, you can input the speed at which you want each channel to move;
and three, you can set the maximum move for the entire channel.
These three features give the GroupMoveProtocol a lot of advantages over the SSCProtocol
and now because we are controlling timing with the controller and not the Thread.sleep()
method, our controller program will need to change as well.
In my class, I want three kinds of methods. The first move will just do what the SSCProtocol
does, except we’ll give the method an extra argument that designates the time to move in milli-
seconds. The second kind of move will be a group move. This will move all servos in the associated
group to the desired position. The third kind of move will determine how to set the groups
and pins.
I’ve included a class diagram of these classes in Figure 3-10.