|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
com.ridgesoft.robotics.DifferentialDriveNavigator
public class DifferentialDriveNavigator
Implements a navigator for a differential-drive robot.
This class is designed to provide simple navigation for a robot that employs a two wheel differnetial-drive design. It steers the robot by applying different power levels to the two wheels or by powering the wheels in reverse directions.
This class relies upon an object that implements the Localizer interface to keep track of the robot's position and heading and two Motor objects to control power to the robot's left and right wheels.
This class extends the Thread class, implementing a thread which carries out navigation commands.
Localizer
,
OdometricLocalizer
,
Motor
,
ContinuousRotationServo
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
DifferentialDriveNavigator(Motor leftMotor,
Motor rightMotor,
Localizer localizer,
int drivePower,
int rotatePower,
float gain,
float goToThreshold,
float rotateThreshold,
int threadPriority,
int period)
Constructs a DifferentialDriveNavigator object. |
Method Summary | |
---|---|
void |
go(float heading)
Drive the robot indefinitely in the direction specified. |
void |
moveTo(float x,
float y)
Move the robot to the specified coordinates. |
void |
moveTo(float x,
float y,
boolean wait)
Move the robot to the specified coordinates. |
void |
moveTo(float x,
float y,
NavigatorListener listener)
Move the robot to the specified coordinates. |
void |
run()
Run method for the navigation thread. |
void |
stop()
Stop the robot. |
void |
turnTo(float heading)
Turn the robot to the specified heading. |
void |
turnTo(float heading,
boolean wait)
Turn the robot to the specified heading. |
void |
turnTo(float heading,
NavigatorListener listener)
Turn the robot to the specified heading. |
Methods inherited from class java.lang.Thread |
---|
activeCount, currentThread, dumpStack, getName, getPriority, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, setDaemon, setName, setPriority, sleep, start, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait |
Constructor Detail |
---|
public DifferentialDriveNavigator(Motor leftMotor, Motor rightMotor, Localizer localizer, int drivePower, int rotatePower, float gain, float goToThreshold, float rotateThreshold, int threadPriority, int period)
leftMotor
- reference to motor object for the left wheel/trackrightMotor
- reference to motor object for the right wheel/tracklocalizer
- reference to a localizer which keeps track of the robot's
positiondrivePower
- average motor power level to use when driving forwardrotatePower
- average motor power level to use when rotating in placegain
- gain to use in the control algorithm that steers the robot
toward the desired heading. The higher the gain the more
agressively the navigator will attempt to eliminate heading
error. Too high a gain will cause the robot to over steer.goToThreshold
- distance threshold the navigator will use to determine if the
robot has reached its destination. Setting this too small will
cause the robot to thrash when it gets close to the
destination. Setting it too large will cause the navigator to
be less precise than necessary.rotateThreshold
- radians threshold value the navigator will use to determine if
the robot is facing in the desired direction. Setting this too
small will cause the robot to thrash around the desired
direction. Setting it too large will cause the navigator to be
less precise than necessary.threadPriority
- priority to use for the navigation threadperiod
- period to use for repeating navigition calculations and
updating motor power levelsMethod Detail |
---|
public void go(float heading)
go
in interface Navigator
heading
- direction in radians to head towardpublic void moveTo(float x, float y)
This method does not return until the robot has reached the destination.
moveTo
in interface Navigator
x
- x coordinate to move toy
- y coordinate to move topublic void moveTo(float x, float y, boolean wait)
moveTo
in interface Navigator
x
- x coordinate to move toy
- y coordinate to move towait
- true if the method should wait for the operation to terminatepublic void moveTo(float x, float y, NavigatorListener listener)
This method returns without waiting for the movement to complete.
moveTo
in interface Navigator
x
- x coordinate to move toy
- y coordinate to move tolistener
- listener to call when the operation terminates, may be nullpublic void run()
run
in interface Runnable
run
in class Thread
public void stop()
stop
in interface Navigator
public void turnTo(float heading)
This method does not return until the robot is facing the new heading.
turnTo
in interface Navigator
heading
- heading to turn to in radianspublic void turnTo(float heading, boolean wait)
turnTo
in interface Navigator
heading
- heading to turn to in radianswait
- true if the method should wait for the operation to terminatepublic void turnTo(float heading, NavigatorListener listener)
This method returns without waiting for the turn to complete.
turnTo
in interface Navigator
heading
- heading to turn to in radianslistener
- listener to call when the operation terminates, may be null
|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |