Page 80 - The Definitive Guide to Building Java Robots
P. 80
Preston_5564C03.fm Page 61 Wednesday, October 5, 2005 7:21 AM
CHAPTER 3 ■ MOTION 61
Figure 3-6. A class diagram of classes in section 3.2
Code Objectives
The objective in this section is to provide basic movements: forward, reverse, pivotRight,
pivotLeft, and stop.
Code Discussion
I’ll start off this section by writing a basic differential drive class, called BasicDiffDrive. The
fields of this class have a single instance field, ssc, for the MiniSSC class, which controls the
servos and provides their functionality. I also have two constants that represent the hardware
connections for the left and right wheels. The remaining fields are used to keep state for the
servo positions for constant or various speeds.