orbotix.robot.base
Class DriveAlgorithm

java.lang.Object
  extended by orbotix.robot.base.DriveAlgorithm
Direct Known Subclasses:
JoyStickDriveAlgorithm, RCDriveAlgorithm, TiltDriveAlgorithm

public abstract class DriveAlgorithm
extends java.lang.Object

Abstract class that defines the behavior for drive algorithms that converts input coordinates to a heading and angle for a device.


Nested Class Summary
static interface DriveAlgorithm.OnConvertListener
          Interface for listener to receive conversion notifications.
 
Field Summary
 double adjustedHeading
          The calculated heading adjusted for any heading offset present
 double[] deadZoneDelta
          The deltas in the input coordinates around the stopped position that is still considered zero speed.
 double heading
          The calculated heading
 double headingOffset
          The heading offset (in degrees) used to correct the heading to the adjustedHeading.
static int MAX_COORDINATES
          Maximum number of input coordinates.
 double speed
          The calculated speed
 double speedScale
          A scale factory between 0.0 to 1.0 to limit the speed
 double[] stopPosition
          The point in the input coordinates that is considered the stopped position.
 
Constructor Summary
DriveAlgorithm()
           
 
Method Summary
abstract  void convert(double coord1, double coord2, double coord3)
          Converts the input coordinates into a heading and speed.
 void setOnConvertListener(DriveAlgorithm.OnConvertListener listener)
          Method to register an OnConvertListener.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_COORDINATES

public static final int MAX_COORDINATES
Maximum number of input coordinates.

See Also:
Constant Field Values

heading

public double heading
The calculated heading


headingOffset

public double headingOffset
The heading offset (in degrees) used to correct the heading to the adjustedHeading. This is a relative offset based on the original "forward" direction (of the device, not the robot) set during a calibration.


adjustedHeading

public double adjustedHeading
The calculated heading adjusted for any heading offset present


speed

public double speed
The calculated speed


speedScale

public double speedScale
A scale factory between 0.0 to 1.0 to limit the speed


stopPosition

public double[] stopPosition
The point in the input coordinates that is considered the stopped position.


deadZoneDelta

public double[] deadZoneDelta
The deltas in the input coordinates around the stopped position that is still considered zero speed.

Constructor Detail

DriveAlgorithm

public DriveAlgorithm()
Method Detail

setOnConvertListener

public void setOnConvertListener(DriveAlgorithm.OnConvertListener listener)
Method to register an OnConvertListener.

Parameters:
listener - A OnConvertListener object.

convert

public abstract void convert(double coord1,
                             double coord2,
                             double coord3)
Converts the input coordinates into a heading and speed. Input coordinates are dependent on the method used, for example, they can be accelerometer coordinates or a point in a view.

Parameters:
coord1 - First coordinate in the input coordinates.
coord2 - Second coordinate in the input coordinates.
coord3 - Third coordinate in the input coordinates.