Page 100 - The Definitive Guide to Building Java Robots
P. 100
Preston_5564C03.fm Page 81 Wednesday, October 5, 2005 7:21 AM
CHAPTER 3 ■ MOTION 81
Example 3-11. GroupMoveProtocol.java
package com.scottpreston.javarobot.chapter3;
public interface GroupMoveProtocol {
public static final String CMD_TERM = "\r";
/**
* This is the SSC Constructor Mode w/500 default speed
* @param ch - channel 0-31
* @param pos - position 0-255
*/
public void sscCmd(int ch, int pos) throws Exception;
/**
* This is the native constructor mode.
* @param ch - channel 0-31
* @param pos - position 0-255
* @param spd - speed in ms
* @param tm = time to move in milliseconds
*
*/
public void cmd(int ch, int pos, int spd) throws Exception;
/**
*
* @param time - length in milliseconds to move
* @throws Exception
*/
public void move(int time) throws Exception;
}
Because the LM32 takes commands for timing and we can group servos together, we will
have to do much less in our class, and our timings will look smoother and more fluid.
Code Objectives
The objective here is to implement the GroupMoveProtocol for the LM32.
Code Discussion
One of the benefits of a nice object language is code reuse. Notice that I just extend the SSC
class, so this class will do the same thing as a standard MiniSSC-II.