org.lejon.util
Class DriveParameters

java.lang.Object
  extended byorg.lejon.util.DriveParameters

public class DriveParameters
extends java.lang.Object

Wrapper class for control parameters of a DD drive. An instance of this class describes the drive's hardware architecture and its behavior regarding the LeJOS motor and sensor control. There is an option to use a PID controller for software-based steering. This is based on the control of the wheels' velocities. If you do not need such control you should set the PID constants to (0,0,0). The 'timeBase' parameter defines the period for position update and steering. It must always be specified. The velocities vector is used to compute the motor power when driving arbitrary curves.


Constructor Summary
DriveParameters(int ticksNominal, float axleLength, float wheelDiameter, float gearRatio, char motorIdLeft, char motorIdRight, int rotSensorIdLeft, int rotSensorIdRight, boolean rotSensorsReverseDirection, boolean motorsReverseDirection, float[] pidConstants, int timeBase, int maxTicksPerTimeBase, int[] velocities)
          Creates a new instance of DriveParameters.
 
Method Summary
 float getAxleLength()
          Returns the length of steering axle of the DD in centimeter.
 float getDiffTicksPerDegree()
          Returns the DTPD constant of the DD.
 int getMaxTicksPerTimeBase()
          Returns the MAX_TICKS_PER_TIMEBASE constant of the drive wich defines the TICKS at power level 7 measured in a period of 'timeBase' under load.
 char getMotorIdLeft()
          Returns the RCX port id of the left motor.
 char getMotorIdRight()
          Returns the RCX port id of the right motor.
 int getMotorModeDirectionBackward()
          Returns the 'aMode' value used in Motor.controlMotor() to let the motor drive its wheel in backward direction.
 int getMotorModeDirectionForward()
          Returns the 'aMode' value used in Motor.controlMotor() to let the motor drive its wheel in forward direction.
 float getPIDConstantKd()
          Returns the damping factor for the PID controller.
 float getPIDConstantKi()
          Returns the integral factor for the PID controller.
 float getPIDConstantKp()
          Returns the proportional factor for the PID controller.
 int getRotSensorIdLeft()
          Returns the RCX port id of the left rotation sensor decremented by 1.
 int getRotSensorIdRight()
          Returns the RCX port id of the right rotation sensor in drives decremented by 1.
 int getRotSensorsCountDirection()
          Returns the sign of the TICKS in rotation sensors when wheel rotate in forward direction of the drive.
 float getTicksPerCentimeter()
          Returns the TPC constant of the DD.
 float getTicksPerDegree()
          Returns the DTPD constant of the DD.
 int getTimeBase()
          Returns the timeBase in milliseconds for periodic control and position update.
 int[] getVelocityMap()
          Returns the velocities vector of the drive.
 boolean isMotorsReverseDirection()
          Returns true if wheels rotate forward when motors rotate backward.
 boolean isRotSensorsReverseDirection()
          Returns true if rotation sensors count down when wheels rotate forward.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DriveParameters

public DriveParameters(int ticksNominal,
                       float axleLength,
                       float wheelDiameter,
                       float gearRatio,
                       char motorIdLeft,
                       char motorIdRight,
                       int rotSensorIdLeft,
                       int rotSensorIdRight,
                       boolean rotSensorsReverseDirection,
                       boolean motorsReverseDirection,
                       float[] pidConstants,
                       int timeBase,
                       int maxTicksPerTimeBase,
                       int[] velocities)
Creates a new instance of DriveParameters.

Parameters:
axleLength - the length of the steering axle in centimeter. This is the distance between the axle points of the left and right wheel.
wheelDiameter - wheel diameter in cm
gearRatio - overall ratio of wheel gear to rotation sensor gear
ticksNominal - ticks of rotation sensor by one turnaround of its shaft
motorIdLeft - port id of left motor on RCX, one of 'A','B','C'
motorIdRight - port Id of right motor on RCX, one of 'A','B','C'
rotSensorIdLeft - port id of left rotation sensor on RCX decremented by 1, one of 0,1,2
rotSensorIdRight - port id of right rotation sensor on RCX decremented by 1, one of 0,1,2
rotSensorsReverseDirection - true if sensors count down when wheels rotate forward
motorsReverseDirection - true if wheels rotate forward when motors rotate backward
pidConstants - list with the 3 PID constants (Kp, Ki, Kd) PID controller
timeBase - period in ms for PID controller and position update
maxTicksPerTimeBase - TICKS per 'timeBase' at power level 7 measured under load
velocities - list of velocities in TICKS at power levels 0,1,...,7 measured in a period of 'timeBase' under load
Method Detail

getTicksPerCentimeter

public float getTicksPerCentimeter()
Returns the TPC constant of the DD.

Returns:
the TICKS per centimeter [TICKS/cm]

getDiffTicksPerDegree

public float getDiffTicksPerDegree()
Returns the DTPD constant of the DD. This defines the amount of differential TICKS between the same rotating wheels needed to turn the drive's steering axle about 1 degree about a centre at distance of 'axleLength'/2.

Returns:
the TICKS per degree [TICKS/deg]

getTicksPerDegree

public float getTicksPerDegree()
Returns the DTPD constant of the DD. This defines the amount of TICKS the opposite rotating wheels have to travel to turn the drive's steering axle about 1 degree in place.

Returns:
the TICKS per degree [TICKS/deg]

getAxleLength

public float getAxleLength()
Returns the length of steering axle of the DD in centimeter.

Returns:
the axle length [cm]

getMotorIdLeft

public char getMotorIdLeft()
Returns the RCX port id of the left motor.

Returns:
the motor id

getMotorIdRight

public char getMotorIdRight()
Returns the RCX port id of the right motor.

Returns:
the motor id

getRotSensorIdLeft

public int getRotSensorIdLeft()
Returns the RCX port id of the left rotation sensor decremented by 1. (i.e. 0, 1 or 2)

Returns:
the sensor id

getRotSensorIdRight

public int getRotSensorIdRight()
Returns the RCX port id of the right rotation sensor in drives decremented by 1. (i.e. 0, 1 or 2)

Returns:
the sensor id

isRotSensorsReverseDirection

public boolean isRotSensorsReverseDirection()
Returns true if rotation sensors count down when wheels rotate forward.

Returns:
sensor direction flag

isMotorsReverseDirection

public boolean isMotorsReverseDirection()
Returns true if wheels rotate forward when motors rotate backward.

Returns:
motor direction flag

getPIDConstantKp

public float getPIDConstantKp()
Returns the proportional factor for the PID controller.

Returns:
Kp

getPIDConstantKi

public float getPIDConstantKi()
Returns the integral factor for the PID controller.

Returns:
Ki

getPIDConstantKd

public float getPIDConstantKd()
Returns the damping factor for the PID controller.

Returns:
Kd

getTimeBase

public int getTimeBase()
Returns the timeBase in milliseconds for periodic control and position update.

Returns:
the time base [ms]

getMaxTicksPerTimeBase

public int getMaxTicksPerTimeBase()
Returns the MAX_TICKS_PER_TIMEBASE constant of the drive wich defines the TICKS at power level 7 measured in a period of 'timeBase' under load.

Returns:
max ticks per time base

getVelocityMap

public int[] getVelocityMap()
Returns the velocities vector of the drive. This is a mapping from power levels (0,1,...,7) to TICKS measured in a period of 'timeBase' under load.

Returns:
list of 8 velocities [TICKS/timeBase]

getMotorModeDirectionForward

public int getMotorModeDirectionForward()
Returns the 'aMode' value used in Motor.controlMotor() to let the motor drive its wheel in forward direction.

Returns:
motor mode for forward direction

getMotorModeDirectionBackward

public int getMotorModeDirectionBackward()
Returns the 'aMode' value used in Motor.controlMotor() to let the motor drive its wheel in backward direction.

Returns:
motor mode for backward direction

getRotSensorsCountDirection

public int getRotSensorsCountDirection()
Returns the sign of the TICKS in rotation sensors when wheel rotate in forward direction of the drive.

Returns:
sign of TICKS when wheels rotate forward