lejos.navigation
Class CompassNavigator
java.lang.Object
lejos.navigation.SimpleNavigator
lejos.navigation.CompassNavigator
- All Implemented Interfaces:
- Navigator
public class CompassNavigator
- extends SimpleNavigator
The CompassNavigatort class, like its superclass, can keep track of the robot position and the direction angle it faces. It uses a CompassPilot object 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.
Constructor Summary |
CompassNavigator(CompassPilot pilot)
To use this constructor, you must first create a compass pilot. |
CompassNavigator(CompassSensor compass,
float wheelDiameter,
float trackWidth,
Motor leftMotor,
Motor rightMotor)
|
CompassNavigator(CompassSensor compass,
float wheelDiameter,
float trackWidth,
Motor leftMotor,
Motor rightMotor,
boolean reverse)
|
CompassNavigator(SensorPort compassPort,
float wheelDiameter,
float 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,
float wheelDiameter,
float trackWidth,
Motor leftMotor,
Motor rightMotor,
boolean reverse)
|
Method Summary |
void |
calibrateCompass()
Robot rotates 360 degrees while calibrating the compass sensor |
Methods inherited from class lejos.navigation.SimpleNavigator |
angleTo, backward, distanceTo, forward, getAngle, getPilot, getX, getY, goTo, goTo, isMoving, rotate, rotate, rotateLeft, rotateRight, rotateTo, rotateTo, setMoveSpeed, setPosition, setSpeed, setTurnSpeed, stop, travel, travel, turn, turn, turn, updatePosition |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CompassNavigator
public CompassNavigator(SensorPort compassPort,
float wheelDiameter,
float trackWidth,
Motor leftMotor,
Motor rightMotor)
- Allocates a CompassNavigator objects and its CompassPilot object and initializes it with the proper motors and dimensions.
This is a subclass of SimpleNavigator (see that API for other methods).
The x and y values and the direction angle are all initialized to 0, so if the first move is forward() the robot will run along
the x axis.
- Parameters:
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.
CompassNavigator
public CompassNavigator(SensorPort compassPort,
float wheelDiameter,
float trackWidth,
Motor leftMotor,
Motor rightMotor,
boolean reverse)
CompassNavigator
public CompassNavigator(CompassSensor compass,
float wheelDiameter,
float trackWidth,
Motor leftMotor,
Motor rightMotor,
boolean reverse)
CompassNavigator
public CompassNavigator(CompassSensor compass,
float wheelDiameter,
float trackWidth,
Motor leftMotor,
Motor rightMotor)
CompassNavigator
public CompassNavigator(CompassPilot pilot)
- To use this constructor, you must first create a compass pilot.
- Parameters:
compassPilot
-
calibrateCompass
public void calibrateCompass()
- Robot rotates 360 degrees while calibrating the compass sensor