public class CompassPilot extends DifferentialPilot
PoseProvider.getPose()
Modifier and Type | Class and Description |
---|---|
(package private) class |
CompassPilot.Regulator
inner class to regulate heading during travel move
Proportional control of steering ; error is an average of heading change
from tacho counts and from compass change
|
Modifier and Type | Field and Description |
---|---|
protected byte |
_direction |
protected float |
_distance |
protected float |
_estimatedHeading |
protected float |
_heading |
protected float |
_heading0 |
protected boolean |
_traveling |
protected DirectionFinder |
compass |
protected CompassPilot.Regulator |
regulator |
_left, _leftDegPerDistance, _outside, _right, _rightDegPerDistance, _type
WHEEL_SIZE_EV3, WHEEL_SIZE_NXT1, WHEEL_SIZE_NXT2, WHEEL_SIZE_RCX
Constructor and Description |
---|
CompassPilot(DirectionFinder compass,
float wheelDiameter,
float trackWidth,
RegulatedMotor leftMotor,
RegulatedMotor rightMotor)
Allocates a CompasPilot object, and sets the physical parameters of the NXT robot.
|
CompassPilot(DirectionFinder compass,
float wheelDiameter,
float trackWidth,
RegulatedMotor leftMotor,
RegulatedMotor rightMotor,
boolean reverse)
Allocates a CompasPilot object, and sets the physical parameters of the NXT robot.
|
Modifier and Type | Method and Description |
---|---|
void |
calibrate()
Rotates the robot 360 degrees while calibrating the compass
resets compass zero to heading at end of calibration
|
float |
getAngleIncrement()
Returns the change in robot heading since the last call of reset()
normalized to be within -180 and _180 degrees
|
DirectionFinder |
getCompass()
Return the compass
|
float |
getCompassHeading()
Method returns the current compass heading
|
float |
getHeading()
Returns direction of desired robot facing
|
float |
getHeadingError()
Determines the difference between actual compass direction and desired heading in degrees
|
boolean |
isTraveling()
returns returns true if the robot is travelling for a specific distance;
|
protected float |
normalize(float angle) |
void |
reset()
Resets tacho count for both motors.
|
void |
resetCartesianZero() |
void |
rotate(float angle)
Rotates the NXT robot through a specific angle; Rotates left if angle is positive, right if negative,
Returns when angle is reached.
|
void |
rotate(float angle,
boolean immediateReturn)
robot rotates to the specified compass heading;
|
void |
setHeading(float angle)
sets direction of desired robot facing in degrees
|
void |
stop()
Stops the robot soon after the method is executed.
|
protected void |
stopNow() |
void |
travel(float distance)
Moves the NXT robot a specific distance;
A positive distance causes forward motion; negative distance moves backward. |
void |
travel(float distance,
boolean immediateReturn)
Moves the NXT robot a specific distance.
|
addMoveListener, arc, arc, arcBackward, arcForward, backward, forward, getAngularAcceleration, getAngularSpeed, getLinearAcceleration, getLinearSpeed, getMaxAngularSpeed, getMaxLinearSpeed, getMaxRotateSpeed, getMinRadius, getMovement, getMovementIncrement, getTurnRate, isMoving, isStalled, movementActive, movementStart, quickStop, rotate, rotate, rotateLeft, rotateRight, setAngularAcceleration, setAngularSpeed, setLinearAcceleration, setLinearSpeed, setMinRadius, steer, steer, steer, steerBackward, steerPrep, travel, travel, travelArc, travelArc
protected DirectionFinder compass
protected CompassPilot.Regulator regulator
protected float _heading
protected float _estimatedHeading
protected boolean _traveling
protected float _distance
protected byte _direction
protected float _heading0
public CompassPilot(DirectionFinder compass, float wheelDiameter, float trackWidth, RegulatedMotor leftMotor, RegulatedMotor rightMotor)
compass
- : a compass sensor;wheelDiameter
- Diameter of the tire, in any convenient units. (The diameter in mm is usually printed on the tire).trackWidth
- Distance between center of right tire and center of left tire, in same units as wheelDiameterleftMotor
- rightMotor
- public CompassPilot(DirectionFinder compass, float wheelDiameter, float trackWidth, RegulatedMotor leftMotor, RegulatedMotor rightMotor, boolean reverse)
compass
- : a compass sensor;wheelDiameter
- Diameter of the tire, in any convenient units. (The diameter in mm is usually printed on the tire).trackWidth
- Distance between center of right tire and center of left tire, in same units as wheelDiameterleftMotor
- rightMotor
- reverse
- if true of motor.forward() drives the robot backwardspublic boolean isTraveling()
public DirectionFinder getCompass()
public float getAngleIncrement()
getAngleIncrement
in class DifferentialPilot
public float getHeading()
public float getCompassHeading()
public void setHeading(float angle)
public void calibrate()
public void resetCartesianZero()
public float getHeadingError()
public void travel(float distance, boolean immediateReturn)
distance
- The positive or negative distance to move the robot, same units as _wheelDiameterimmediateReturn
- iff true, the method returns immediately.public void travel(float distance)
distance
- of robot movement. Unit of measure for distance must be same as wheelDiameter and trackWidthpublic void rotate(float angle, boolean immediateReturn)
immediateReturn
- - if true, method returns immediately.
Robot stops when specified angle is reached or when stop() is calledpublic void rotate(float angle)
angle
- degrees. Positive angle rotates to the left (clockwise); negative to the right. public void reset()
DifferentialPilot
reset
in class DifferentialPilot
protected void stopNow()
public void stop()
stop
in interface MoveController
stop
in class DifferentialPilot
protected float normalize(float angle)