|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecticommand.navigation.TachoNavigator
icommand.navigation.CompassNavigator
public class CompassNavigator
The CompassPilot class, like its superclass, can keep track of the robot position and the direction angle it faces; It uses a compassPpilot bject to control NXT robot movements.
The position and direction angle values are updated automatically when the movement command returns after the movement is complete and and after stop() command is issued.
However, some commands optionally return immediately, to permit sensor monitoring in the main thread. It is then the programmers responsibility to
call updateXY() when the robot motion is completed. All angles are in degrees, distances in the units used to specify robot dimensions.
As with pilot, the robot must be have two independently controlled drive wheels.
Uses the Compass Sensor to determine the robot heading.
Field Summary | |
---|---|
CompassPilot |
compassPilot
|
Fields inherited from class icommand.navigation.TachoNavigator |
---|
_heading, _left0, _pilot, _right0 |
Constructor Summary | |
---|---|
CompassNavigator(CompassPilot compassPilot)
To use this constructor, you must first create a compass pilot. |
|
CompassNavigator(SensorPort compassPort,
double wheelDiameter,
double trackWidth,
Motor leftMotor,
Motor rightMotor)
Allocates a CompassNavigator objects and its CompassPilot object and initializes it with the proper motors and dimensions. |
|
CompassNavigator(SensorPort compassPort,
double wheelDiameter,
double trackWidth,
Motor leftMotor,
Motor rightMotor,
boolean reverse)
|
Method Summary | |
---|---|
void |
calibrateCompass()
Robot rotates 360 degrees while calibrating the compass sensor |
void |
rotate(double angle,
boolean immediateReturn)
Rotates the NXT robot by a specified angle. |
void |
rotateTo(double angle,
boolean immediateReturn)
Rotates the NXT robot to point in a specific direction. |
void |
stop()
Halts the NXT robot and calculates new x, y coordinates. |
void |
travel(double distance,
boolean immediateReturn)
Moves the NXT robot a specific distance. |
void |
updateHeading()
Direction of robot facing is set equal to the current compass reading |
void |
updateXY()
Updates x,y coordinates; assumes last compass angle was constant during travel |
Methods inherited from class icommand.navigation.TachoNavigator |
---|
angleTo, backward, distanceTo, forward, getAngle, getPilot, getX, getY, goTo, goTo, isMoving, rotate, rotateLeft, rotateRight, rotateTo, setPosition, setSpeed, travel, turn, turn, turn, updatePosition |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public CompassPilot compassPilot
Constructor Detail |
---|
public CompassNavigator(SensorPort compassPort, double wheelDiameter, double trackWidth, Motor leftMotor, Motor rightMotor)
compassPort
- the sensor port connected to the compass sensor e.g SensorPort.S1wheelDiameter
- The diameter of the wheel, usually printed right on the
wheel, in centimeters (e.g. 49.6 mm = 4.96 cm = 1.95 in)trackWidth
- The distance from the center of the left tire to the center
of the right tire, in units of your choicerightMotor
- The motor used to drive the right wheel e.g. Motor.C.leftMotor
- The motor used to drive the left wheel e.g. Motor.A.public CompassNavigator(SensorPort compassPort, double wheelDiameter, double trackWidth, Motor leftMotor, Motor rightMotor, boolean reverse)
public CompassNavigator(CompassPilot compassPilot)
compassPilot
- Method Detail |
---|
public void calibrateCompass()
public void rotateTo(double angle, boolean immediateReturn)
rotateTo
in class TachoNavigator
angle
- The angle to rotate to, in degrees.immediateReturn
- iff true, method returns immediately and the programmer is responsible for calling
updatePosition() before the robot moves again.public void rotate(double angle, boolean immediateReturn)
rotate
in class TachoNavigator
angle
- The angle to rotate to, in degrees.immediateReturn
- iff true, method returns immediately and the programmer is responsible for calling
updatePosition() before the robot moves again.public void travel(double distance, boolean immediateReturn)
travel
in class TachoNavigator
distance
- The positive or negative distance to move the robot, same units as _wheelDiameterimmediateReturn
- iff true, the method returns immediately, in which case the programmer public void stop()
stop
in interface Navigator
stop
in class TachoNavigator
Navigator.forward().
public void updateHeading()
public void updateXY()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |