dLife Home Page

dlife.robot
Class DifferentialDriveEffector

java.lang.Object
  extended by java.util.Observable
      extended by dlife.robot.Device
          extended by dlife.robot.DifferentialDriveEffector
Direct Known Subclasses:
FinchDifferentialDrive, HemissonDifferentialDrive, Khepera2DifferentialDrive, Khepera3DifferentialDrive, PioneerDifferentialDrive, ScribblerDifferentialDrive

public abstract class DifferentialDriveEffector
extends Device

Abstract base class for the effector controlling the motion of robots with differential drive system.

A NOTE ON DYNAMICS: Wheel speeds are mechanically limited and thus are bounded to [-1...1]. When converting from rotation and translation specifications to wheel speeds, if any value falls outside of that range then both values are scaled proportionately such that they both fall within the range. Thus, the values returned from a call to getRotation or getTranslation may not return the same value that was specified in the call to rotate, translate or move. Similarly, if the wheel speeds are set directly using the setWheelSpeeds method, then the values returned from getRotation and getTranslation may not lie within [-1...1] bounds imposed on move, rotate and translate.

The conversion from rotation and translation to wheel speeds and vice versa is done based on an approximation of the induced motion as being infinitesimal and independent in both the forward and rotational directions. Also, the wheel base of the robot is taken to be 1. Under this approximation:

dX/dt = (vR + vL) / 2

dTheta/dt = (vR - vL)

Similarly, to compute wheel velocities from translation (dX/dt) and rotation (dTheta/dt) values:

vL = dX/dt - 1/2 * dTheta/dt

vR = dX/dt + 1/2 * dTheta/dt

Version:
Apr 14, 2007
Author:
Grant Braught, Dickinson College

Field Summary
protected  double vL
           
protected  double vR
           
 
Fields inherited from class dlife.robot.Device
DEFAULT_GUI_UPDATE_DELAY, DEFAULT_READ_DELAY, myRobot, readCount
 
Constructor Summary
DifferentialDriveEffector()
          Construct a new DifferentialDriveEffector.
DifferentialDriveEffector(boolean autoRead)
          Construct a new DifferentialDriveEffector with or without an AutoReadTimer running.
DifferentialDriveEffector(int readDelay, int guiDelay, boolean autoRead)
          Construct a new DifferentialDriveEffector with the specified settings for the readDelay, guiDelay and autoRead.
 
Method Summary
protected  DeviceDisplay[] createGUIObjects()
          Get the object that is the GUI controller for this DifferentialDriveEffector.
 void freeze()
          Stop the motion of the Robot controlled by this DifferentialDriveEffector.
 double getLeftWheelSpeed()
          Get the current rotational speed of the left wheel.
 double getRightWheelSpeed()
          Get the current rotational speed of the right wheel.
 double getRotation()
          Get the current rate of rotation of the robot about its center axis.
 double getTranslation()
          Get the current rate of translation of the robot.
 void move(double tSpeed, double rSpeed)
          This method should cause the robot to move with a combination of translation and rotation along a curved trajectory.
 void rotate(double speed)
          This method will cause the robot to rotate in place at the specified fraction of its maximum speed.
protected abstract  void setRobotWheelSpeeds(double left, double right)
          All concrete sub-classes must implement this method such that it sends the appropriate command to the robot such that the wheels will turn with the specified relative speeds.
 void setWheelSpeeds(double left, double right)
          Set the rotational speeds of the left and right wheels of the robot.
 void shutDown()
          Stop the motion of the robot and invoke the superclass shutDown method.
 void translate(double speed)
          This method will cause the robot to move straight forward or backward at the specified fraction of its maximum speed.
 
Methods inherited from class dlife.robot.Device
getAutoRead, getGUI, getGUIUpdateDelay, getReadDelay, getRobot, getSensorReadCount, getSensorReadRate, readStateFromRobot, setAutoRead, setGUIUpdateDelay, setReadDelay, setRobot, startAutoReadTimer, startUp, stopAutoReadTimer
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vL

protected double vL

vR

protected double vR
Constructor Detail

DifferentialDriveEffector

public DifferentialDriveEffector()
Construct a new DifferentialDriveEffector. This constructor enables the AutoReadTimer by default.


DifferentialDriveEffector

public DifferentialDriveEffector(boolean autoRead)
Construct a new DifferentialDriveEffector with or without an AutoReadTimer running.


DifferentialDriveEffector

public DifferentialDriveEffector(int readDelay,
                                 int guiDelay,
                                 boolean autoRead)
Construct a new DifferentialDriveEffector with the specified settings for the readDelay, guiDelay and autoRead.

Parameters:
readDelay - the delay between attempts to read the wheel speeds from the robot.
guiDelay - the delay between updates to the GUI display.
autoRead - whether or not to start the autoread timer for this DifferentialDriveEffector.
Method Detail

translate

public void translate(double speed)
This method will cause the robot to move straight forward or backward at the specified fraction of its maximum speed. Positive values for speed indicate forward translations and negative values indicate backward translation.

This is a convenience method for the call move(speed, 0.0). The values of speed should be in the range [-1...1]. Values outside of that range are bounded to the range.

Parameters:
speed - the speed at which to move.

rotate

public void rotate(double speed)
This method will cause the robot to rotate in place at the specified fraction of its maximum speed. Positive values speed indicate CCW rotation and negative values indicate CW rotation.

This is a convenience method for the call move(0.0, speed). The values of speed should be in the range [-1...1]. Values outside of that range are bounded to the range.

Parameters:
speed - the speed at which to rotate.

move

public void move(double tSpeed,
                 double rSpeed)
This method should cause the robot to move with a combination of translation and rotation along a curved trajectory. The speed of rotation and translation should have the same interpretation as in the translate and rotate methods.

Parameters:
tSpeed - the speed at which to translate.
rSpeed - the speed at which to rotate.

freeze

public void freeze()
Stop the motion of the Robot controlled by this DifferentialDriveEffector.

Specified by:
freeze in class Device

shutDown

public void shutDown()
Stop the motion of the robot and invoke the superclass shutDown method.

Overrides:
shutDown in class Device

getTranslation

public double getTranslation()
Get the current rate of translation of the robot.

Returns:
the robot's current rate of translation.

getRotation

public double getRotation()
Get the current rate of rotation of the robot about its center axis.

Returns:
the robot's current rate of rotation.

setWheelSpeeds

public void setWheelSpeeds(double left,
                           double right)
Set the rotational speeds of the left and right wheels of the robot. The speed values should be in the range [-1...1] with -1 being full speed backwards and +1 being full speed forward. Values outside of that range will be scaled such that both values fall within the range, with the larger value being scaled to (+-)1.0.

This method invokes the protected abstract method setRobotWheelSpeeds, which is responsible for issuing the command to the robot that will cause its wheels to move.

Parameters:
left - the rotational speed of the left wheel.
right - the rotational speed of the right wheel.

setRobotWheelSpeeds

protected abstract void setRobotWheelSpeeds(double left,
                                            double right)
All concrete sub-classes must implement this method such that it sends the appropriate command to the robot such that the wheels will turn with the specified relative speeds. The speed values should be in the range [-1...1] with -1 being full speed backwards and +1 being full speed forward. Values outside of that range will be truncated to the range. If the subclass does not read the wheel speeds back from the robot then this method must also set the inherited vL and vR fields to the wheel speeds. If the subclass does read the wheel speeds back then the readStateFromRobot method must set these values. If the values are changed in this method then the subclass should also invoke setChanged and notifyObservers.

Parameters:
left - the rotational speed of the left wheel.
right - the rotational speed of the right wheel.

getLeftWheelSpeed

public double getLeftWheelSpeed()
Get the current rotational speed of the left wheel. The speed value returned is in the range [-1...1] with -1 being full speed backwards and +1 being full speed forward.

Returns:
the rotational speed of the left wheel.

getRightWheelSpeed

public double getRightWheelSpeed()
Get the current rotational speed of the right wheel. The speed value returned is in the range [-1...1] with -1 being full speed backwards and +1 being full speed forward.

Returns:
the rotational speed of the right wheel.

createGUIObjects

protected DeviceDisplay[] createGUIObjects()
Get the object that is the GUI controller for this DifferentialDriveEffector.

Specified by:
createGUIObjects in class Device
Returns:
the DeviceDisplay for this DifferentialDriveEffector.

dLife Home Page