dLife Home Page

dlife.robot
Class DeltaPositionEffector

java.lang.Object
  extended by java.util.Observable
      extended by dlife.robot.Device
          extended by dlife.robot.DeltaPositionEffector
Direct Known Subclasses:
Khepera3DeltaPositionEffector

public abstract class DeltaPositionEffector
extends Device

Abstract base class for effectors that use odometry to move a robot a specified distance forward or backward or rotate it CW or CCW a specified angle.

Version:
August 25, 2009
Author:
Russell Toris, Dickinson College

Field Summary
 
Fields inherited from class dlife.robot.Device
DEFAULT_GUI_UPDATE_DELAY, DEFAULT_READ_DELAY, myRobot, readCount
 
Constructor Summary
DeltaPositionEffector()
          Creates a new DeltaPositionEffector
 
Method Summary
protected  DeviceDisplay[] createGUIObjects()
          Construct the DeltaPositionController that will be used as the GUI for this DeltaPositionEffector.
 int getAngle()
          Get the current angle setting for this DeltaPositionEffector.
 int getDistance()
          Get the current distance setting for this DeltaPositionEffector.
 double getSpeed()
          Get the current speed setting for this DeltaPositionEffector.
abstract  boolean isDone()
          This method is used to check if a robot is done moving to the specified location or finished rotating.
protected abstract  void moveRobotDistance(int dist, double speed)
          This method must be implemented in a subclass and is responsible for moving the robot a certain distance at a given speed.
 void rotate()
          Repeat the last rotation.
 void rotate(int angle, double speed)
          Rotate a robot by a certain angle.
protected abstract  void rotateRobotAngle(int angle, double speed)
          This method must be implemented in a subclass and is responsible for rotating the rotate by a certain number of degrees at a certain speed.
 void setAngle(int newAngle)
          Set the angle to be rotated in degrees.
 void setDistance(int newDistance)
          Set the distance to be traveled in millimeters.
 void setSpeed(double newSpeed)
          Set the speed for rotation or translation.
 void translate()
          Translate the robot by the distance returned from getDistance() at the speed returned from getSpeed().
 void translate(int distance, double speed)
          Drives a robot forward or backward by a certain distance at a certain speed.
 
Methods inherited from class dlife.robot.Device
freeze, getAutoRead, getGUI, getGUIUpdateDelay, getReadDelay, getRobot, getSensorReadCount, getSensorReadRate, readStateFromRobot, setAutoRead, setGUIUpdateDelay, setReadDelay, setRobot, shutDown, 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
 

Constructor Detail

DeltaPositionEffector

public DeltaPositionEffector()
Creates a new DeltaPositionEffector

Method Detail

translate

public void translate(int distance,
                      double speed)
Drives a robot forward or backward by a certain distance at a certain speed. The distance should be given in millimeters and speed should be a value between -1 and 1. The isDone method will return false until the distance has been covered. If the speed or distance are 0 then isDone will return true immediately. This method invokes an abstract method, moveRobotDistance, which is responsible for making calls to the robot.

Parameters:
distance - the distance to drive in millimeters
speed - the speed to drive

translate

public void translate()
Translate the robot by the distance returned from getDistance() at the speed returned from getSpeed(). Those values will be the values set by setDistance() and setSpeed() or will be the values provided in the most recent call to translate(distance, speed). The isDone method will return false until the distance has been covered. If the speed or distance are 0 then isDone will return true immediately.


rotate

public void rotate(int angle,
                   double speed)
Rotate a robot by a certain angle. The angle should be given in degrees and speed should be a value between -1 and 1. The isDone method will return false until the angled has been covered. If the speed or angle are 0 then isDone will return true immediately. This method invokes an abstract method, rotateRobotAngle, which is responsible for making calls to the robot.

Parameters:
angle - the angle to turn in degrees
speed - the speed to turn

rotate

public void rotate()
Repeat the last rotation. This rotates the robot by the angle returned by getAngle() at the speed returned by getSpeed(). Those values will be the values set by setAngle() and setSpeed() or will be the values provided in the most recent call to rotate(angle, speed). The isDone method will return false until the angled has been covered. If the speed or angle are 0 then isDone will return true immediately.


getDistance

public int getDistance()
Get the current distance setting for this DeltaPositionEffector. This is the distance that will be moved if translate() is called.

Returns:
the current distance setting.

setDistance

public void setDistance(int newDistance)
Set the distance to be traveled in millimeters. Subsequent calls to translate() will travel this distance.

Parameters:
newDistance - the distance to be traveled in millimeters.

getAngle

public int getAngle()
Get the current angle setting for this DeltaPositionEffector. This is the angle that will be rotate if rotate() is called.

Returns:
the current angle setting.

setAngle

public void setAngle(int newAngle)
Set the angle to be rotated in degrees. Subsequent calls to rotate() will rotate through this angle.

Parameters:
newAngle - the angle to be rotated in degrees.

getSpeed

public double getSpeed()
Get the current speed setting for this DeltaPositionEffector. This is the speed at which the robot will translate or rotate if translate() or rotate() are called.

Returns:
the current speed setting.

setSpeed

public void setSpeed(double newSpeed)
Set the speed for rotation or translation. The speed should be in the range [-1...1]. Values outside of that range will be bounded to the range. Subsequent calls to translate() or rotate() will use this speed.

Parameters:
newSpeed - the new speed

createGUIObjects

protected DeviceDisplay[] createGUIObjects()
Construct the DeltaPositionController that will be used as the GUI for this DeltaPositionEffector.

Specified by:
createGUIObjects in class Device
Returns:
an array of DeviceDisplay subclass objects that make up the GUI for this Device.

moveRobotDistance

protected abstract void moveRobotDistance(int dist,
                                          double speed)
This method must be implemented in a subclass and is responsible for moving the robot a certain distance at a given speed. All distances will be given in millimeters and all speeds will be a value between -1 and 1.

Parameters:
dist - the distance in millimeters to drive the robot
speed - the speed at which to drive

rotateRobotAngle

protected abstract void rotateRobotAngle(int angle,
                                         double speed)
This method must be implemented in a subclass and is responsible for rotating the rotate by a certain number of degrees at a certain speed. All speeds will be a value between -1 and 1.

Parameters:
angle - the angle given in degrees
speed - the speed at which to rotate

isDone

public abstract boolean isDone()
This method is used to check if a robot is done moving to the specified location or finished rotating. If the distance or angle being moved or the speed of motion is 0, then this method should return true immediately.

Returns:
if the robot has completed its movement task

dLife Home Page