|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlejos.navigation.TachoNavigator
lejos.navigation.CompassNavigator
public class CompassNavigator
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.
Field Summary |
---|
Fields inherited from class lejos.navigation.TachoNavigator |
---|
_heading, _left0, _pilot, _right0 |
Constructor Summary | |
---|---|
CompassNavigator(CompassPilot compassPilot)
To use this constructor, you must first create a compass pilot. |
|
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 |
void |
rotate(float angle,
boolean immediateReturn)
Rotates the NXT robot by a specified angle. |
void |
rotateTo(float 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(float 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 lejos.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 |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait |
Constructor Detail |
---|
public CompassNavigator(SensorPort compassPort, float wheelDiameter, float 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, float wheelDiameter, float trackWidth, Motor leftMotor, Motor rightMotor, boolean reverse)
public CompassNavigator(CompassSensor compass, float wheelDiameter, float trackWidth, Motor leftMotor, Motor rightMotor, boolean reverse)
public CompassNavigator(CompassPilot compassPilot)
compassPilot
- Method Detail |
---|
public void calibrateCompass()
public void rotateTo(float angle, boolean immediateReturn)
rotateTo
in interface Navigator
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(float angle, boolean immediateReturn)
rotate
in interface Navigator
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(float distance, boolean immediateReturn)
travel
in interface Navigator
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 |