cork.device.control
Class PolynomicDrive

java.lang.Object
  |
  +--cork.device.control.PolynomicDrive
All Implemented Interfaces:
Device, Motor

public class PolynomicDrive
extends java.lang.Object
implements Motor

A Polynomic Drive (a word I just invented off the top of my head) is a drive with independant drove groups. e.g. a tanks treads can both move forward, both backward, or in opposit directions.

The drives works in pairs of motors that are assumed to be on opposit sides.

REMEMBER: Because the actual hardware can be hooked up in any way, it is impossible for the software to know the configuration ahead of time. For this reason, the concepts of right, left, forward and backward are abstract concepts only. Also, all direction information is referenced by the left side, so the right side does the opposit (except during a rotate). By all means adjust your hardware to match if you like, but it is not required for operation of the device.

Version:
0.1.0
Author:
Brill Pappin

Fields inherited from interface cork.device.Motor
DIRECTION_FORWARD, DIRECTION_REVERSE
 
Constructor Summary
PolynomicDrive()
          Constructor for the PolynomicDrive object
 
Method Summary
 int addMotorPair(Motor left, Motor right)
          Adds another motor.
 java.lang.String getDeviceDestription()
          Gets the destription attribute of the Device object
 java.lang.String getDeviceName()
          Gets the title attribute of the Device object
 int getDirection()
          Returns the direction attribute of the entire drive system.
 int getDirection(int index)
          Returns the direction attribute of the specified pair index.
 int getSpeed()
          Gets the *average* speed of all motors in the drive system.
 int getSpeed(int index)
          Gets the speed attribute of the specified group.
 boolean isMotor(Motor motor)
          Checks to see if a Motor has already been bound..
 void removeMotorPair(int index)
          Removes the motor.
 void rotate(int index, int direction)
          Causes the two specified groups to move in opposit directions.
 void setDirection(int direction)
          Sets the direction attribute of all the motors.
 void setDirection(int direction, int index)
          Sets the direction attribute of the motors in the specified group.
 void setSpeed(int speed)
          Sets the speed attribute for all motors.
 void setSpeed(int speed, int index)
          Sets the speed attribute of the motors in the specified group.
 int size()
          Returns the number of groups in the drive system.
 void start()
          Starts all motors.
 void start(int index)
          Starts the motors in the specified group.
 void stop()
          Stops the motors.
 void stop(int index)
          Stops the motors in the specified group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolynomicDrive

public PolynomicDrive()
Constructor for the PolynomicDrive object
Since:
0.1.0
Method Detail

addMotorPair

public int addMotorPair(Motor left,
                        Motor right)
Adds another motor.
Parameters:
left - The feature to be added to the MotorPair attribute
right - The feature to be added to the MotorPair attribute
Returns:
index int the index of the motor pair.
Since:
0.1.0

removeMotorPair

public void removeMotorPair(int index)
Removes the motor.
Parameters:
index - Description of Parameter
Since:
0.1.0

start

public void start(int index)
Starts the motors in the specified group.
Parameters:
index - Description of Parameter
Since:
0.1.0

stop

public void stop(int index)
Stops the motors in the specified group.
Parameters:
index - Description of Parameter
Since:
0.1.0

start

public void start()
Starts all motors.
Specified by:
start in interface Motor
Since:
0.1.0

stop

public void stop()
Stops the motors.
Specified by:
stop in interface Motor
Since:
0.1.0

size

public int size()
Returns the number of groups in the drive system.
Returns:
int the number of groups.
Since:
0.1.0

rotate

public void rotate(int index,
                   int direction)
Causes the two specified groups to move in opposit directions.
Parameters:
direction - int the direction from the Motor interface that the "left side" will move in. The "right side" motor will automatically rotate in the opposit direction.
index - int the pair index to rotate.
Since:
0.1.0

isMotor

public boolean isMotor(Motor motor)
Checks to see if a Motor has already been bound..
Parameters:
motor - cork.device.Motor the motor to look for.
Returns:
boolean true if the specified motor has already been bound, false otherwise.
Since:
0.1.0

getDirection

public int getDirection(int index)
Returns the direction attribute of the specified pair index.
Parameters:
index - int the pair index to get teh direction for.
Returns:
int the direction ID of the left side. Because of the nature of the drive, the right side will physically be going in the opposite direction, but we think of it as going in the same direction because it is opposit the left side and will move the device in a line.
Since:
0.1.0

getSpeed

public int getSpeed(int index)
Gets the speed attribute of the specified group.
Parameters:
index - Description of Parameter
Returns:
int The speed value or -1 to indicate that the motors are not going the same speed.
Since:
0.1.0

getDirection

public int getDirection()
Returns the direction attribute of the entire drive system. This is only meaningful when all drives are going in the same *relative* direction.
Specified by:
getDirection in interface Motor
Returns:
int the direction all motors are turning, or -1 if not all motors are turning in the same relative direction.
Since:
0.1.0

getSpeed

public int getSpeed()
Gets the *average* speed of all motors in the drive system.
Specified by:
getSpeed in interface Motor
Returns:
int The average speed value
Since:
0.1.0

getDeviceName

public java.lang.String getDeviceName()
Gets the title attribute of the Device object
Specified by:
getDeviceName in interface Device
Returns:
The title value
Since:
0.1.0

getDeviceDestription

public java.lang.String getDeviceDestription()
Gets the destription attribute of the Device object
Specified by:
getDeviceDestription in interface Device
Returns:
The destription value
Since:
0.1.0

setDirection

public void setDirection(int direction,
                         int index)
Sets the direction attribute of the motors in the specified group.
Parameters:
direction - int the direction id from the Motor interface.
index - The new direction value
Since:
0.1.0

setSpeed

public void setSpeed(int speed,
                     int index)
Sets the speed attribute of the motors in the specified group.
Parameters:
speed - int The new speed value
index - The new speed value
Since:
0.1.0

setDirection

public void setDirection(int direction)
Sets the direction attribute of all the motors.
Specified by:
setDirection in interface Motor
Parameters:
direction - int the direction id from the Motor interface.
Since:
0.1.0

setSpeed

public void setSpeed(int speed)
Sets the speed attribute for all motors.
Specified by:
setSpeed in interface Motor
Parameters:
speed - int The new speed value
Since:
0.1.0