public class MovePilot extends java.lang.Object implements ArcRotateMoveController
OdometryPoseProvider which has called the
addMoveListener method on this object.stop().isStalled() returns
true , isMoving() returns false,
moveStopped()
is called, and, if a blocking method is executing, that method exits.
The units of measure for travel distance, speed and acceleration are the
units used in specifying the wheel diameter in the
chassis.
Wheel wheel1 = DifferentialChassis.modelWheel(Motor.A, 43.2).offset(-72);
Wheel wheel2 = DifferentialChassis.modelWheel(Motor.D, 43.2).offset(72);
Chassis chassis = new DifferentialChassis(new Wheel[]{wheel1, wheel2});
MovePilot pilot = new MovePilot(chassis);
pilot.setRobotSpeed(30); // cm per second
pilot.travel(50); // cm
pilot.rotate(-90); // degree clockwise
pilot.travel(-50,true); // move backward for 50 cm
while(pilot.isMoving())Thread.yield();
pilot.rotate(-90);
pilot.rotateTo(270);
pilot.stop();
WHEEL_SIZE_EV3, WHEEL_SIZE_NXT1, WHEEL_SIZE_NXT2, WHEEL_SIZE_RCX| Constructor and Description |
|---|
MovePilot(Chassis chassis)
Allocates a Pilot object.
|
MovePilot(double leftWheelDiameter,
double rightWheelDiameter,
double trackWidth,
RegulatedMotor leftMotor,
RegulatedMotor rightMotor,
boolean reverse)
Deprecated.
|
MovePilot(double wheelDiameter,
double trackWidth,
RegulatedMotor leftMotor,
RegulatedMotor rightMotor)
Deprecated.
|
MovePilot(double wheelDiameter,
double trackWidth,
RegulatedMotor leftMotor,
RegulatedMotor rightMotor,
boolean reverse)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMoveListener(MoveListener listener)
Adds a MoveListener that will be notified of all movement events.
|
void |
arc(double radius,
double angle)
Moves the NXT robot along an arc with a specified radius and angle,
after which the robot stops moving.
|
void |
arc(double radius,
double angle,
boolean immediateReturn)
Moves the NXT robot along an arc with a specified radius and angle,
after which the robot stops moving.
|
void |
arcBackward(double radius)
Starts the NXT robot moving backward along an arc with a specified radius.
|
void |
arcForward(double radius)
Starts the NXT robot moving forward along an arc with a specified radius.
|
void |
backward()
Starts the NXT robot moving backwards.
|
void |
forward()
Starts the NXT robot moving forward.
|
double |
getAngularAcceleration()
Returns the acceleration at which the robot accelerates at the start of a move and decelerates at the end of a move.
|
double |
getAngularSpeed()
Returns the value of the rotation speed
|
double |
getLinearAcceleration()
Returns the acceleration at which the robot accelerates at the start of a move and decelerates at the end of a move.
|
double |
getLinearSpeed()
Returns the speed at which the robot will travel forward and backward (and to some extent arcs, although actual arc speed
is slightly less).
|
double |
getMaxAngularSpeed()
returns the maximum value of the rotation speed;
|
double |
getMaxLinearSpeed()
Returns the maximum speed at which this robot is capable of traveling forward and backward.
|
double |
getMinRadius()
The minimum steering radius this vehicle is capable of when traveling in an arc.
|
Move |
getMovement()
Returns the move made since the move started, but before it has completed.
|
boolean |
isMoving()
true if the robot is moving
|
void |
rotate(double angle)
Rotates the NXT robot the specified number of degrees; direction determined by the sign of the parameter.
|
void |
rotate(double angle,
boolean immediateReturn)
Rotates the NXT robot the specified number of degrees; direction determined by the sign of the parameter.
|
void |
rotateLeft() |
void |
rotateRight() |
void |
setAngularAcceleration(double acceleration)
Sets the acceleration at which the robot will accelerate at the start of a move and decelerate at the end of a move.
|
void |
setAngularSpeed(double speed)
sets the rotation speed of the robot (the angular velocity of the rotate()
methods)
|
void |
setLinearAcceleration(double acceleration)
Sets the acceleration at which the robot will accelerate at the start of a move and decelerate at the end of a move.
|
void |
setLinearSpeed(double speed)
Sets the speed at which the robot will travel forward and backward (and to some extent arcs, although actual arc speed
is slightly less).
|
void |
setMinRadius(double radius)
Set the radius of the minimum turning circle.
|
void |
stop()
Halts the NXT robot
|
void |
travel(double distance)
Moves the NXT robot a specific distance.
|
void |
travel(double distance,
boolean immediateReturn)
Moves the NXT robot a specific distance.
|
void |
travelArc(double radius,
double distance)
Moves the NXT robot a specified distance along an arc of specified radius,
after which the robot stops moving.
|
void |
travelArc(double radius,
double distance,
boolean immediateReturn)
Moves the NXT robot a specified distance along an arc of specified radius,
after which the robot stops moving.
|
@Deprecated
public MovePilot(double wheelDiameter,
double trackWidth,
RegulatedMotor leftMotor,
RegulatedMotor rightMotor)
wheelDiameter - Diameter of the tire, in any convenient units (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 wheelDiameter.leftMotor - The left Motor (e.g., Motor.C).rightMotor - The right Motor (e.g., Motor.A).@Deprecated
public MovePilot(double wheelDiameter,
double trackWidth,
RegulatedMotor leftMotor,
RegulatedMotor rightMotor,
boolean reverse)
wheelDiameter - Diameter of the tire, in any convenient units (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 wheelDiameter.leftMotor - The left Motor (e.g., Motor.C).rightMotor - The right Motor (e.g., Motor.A).reverse - If true, the NXT robot moves forward when the motors are running
backward.@Deprecated
public MovePilot(double leftWheelDiameter,
double rightWheelDiameter,
double trackWidth,
RegulatedMotor leftMotor,
RegulatedMotor rightMotor,
boolean reverse)
leftWheelDiameter - Diameter of the left wheel, in any convenient units (diameter in
mm is usually printed on the tire).rightWheelDiameter - Diameter of the right wheel. You can actually fit intentionally
wheels with different size to your robot. If you fitted wheels
with the same size, but your robot is not going straight, try
swapping the wheels and see if it deviates into the other
direction. That would indicate a small difference in wheel size.
Adjust wheel size accordingly. The minimum change in wheel size
which will actually have an effect is given by minChange =
A*wheelDiameter*wheelDiameter/(1-(A*wheelDiameter) where A =
PI/(moveSpeed*360). Thus for a moveSpeed of 25 cm/second and a
wheelDiameter of 5,5 cm the minChange is about 0,01058 cm. The
reason for this is, that different while sizes will result in
different motor speed. And that is given as an integer in degree
per second.trackWidth - Distance between center of right tire and center of left tire, in
same units as wheelDiameter.leftMotor - The left Motor (e.g., Motor.C).rightMotor - The right Motor (e.g., Motor.A).reverse - If true, the NXT robot moves forward when the motors are running
backward.public MovePilot(Chassis chassis)
chassis - A Chassis object describing the physical parameters of the robot.public void setLinearAcceleration(double acceleration)
MoveControllerIf acceleration is set during a move it will not be in used for the current move, it will be in effect with the next move.
setLinearAcceleration in interface MoveControlleracceleration - in chosen units/second^2public double getLinearAcceleration()
MoveControllergetLinearAcceleration in interface MoveControllerpublic void setAngularAcceleration(double acceleration)
RotateMoveControllerIf acceleration is set during a move it will not be in used for the current move, it will be in effect with the next move.
setAngularAcceleration in interface RotateMoveControlleracceleration - in chosen units/second^2public double getAngularAcceleration()
RotateMoveControllergetAngularAcceleration in interface RotateMoveControllerpublic void setLinearSpeed(double speed)
MoveControllersetLinearSpeed in interface MoveControllerspeed - In chosen units per second (e.g. cm/sec)public double getLinearSpeed()
MoveControllergetLinearSpeed in interface MoveControllerpublic double getMaxLinearSpeed()
MoveControllergetMaxLinearSpeed in interface MoveControllerpublic void setAngularSpeed(double speed)
RotateMoveControllersetAngularSpeed in interface RotateMoveControllerspeed - in degrees per secondpublic double getAngularSpeed()
RotateMoveControllergetAngularSpeed in interface RotateMoveControllerpublic double getMaxAngularSpeed()
RotateMoveControllergetMaxAngularSpeed in interface RotateMoveControllerpublic double getMinRadius()
ArcMoveControllergetMinRadius in interface ArcMoveControllerpublic void setMinRadius(double radius)
ArcMoveControllersetMinRadius in interface ArcMoveControllerradius - the radius in degreespublic void forward()
MoveControllerforward in interface MoveControllerpublic void backward()
MoveControllerbackward in interface MoveControllerpublic void travel(double distance)
MoveControllertravel in interface MoveControllerdistance - The positive or negative distance to move the robot.public void travel(double distance,
boolean immediateReturn)
MoveControllertravel in interface MoveControllerdistance - The positive or negative distance to move the robot, in wheel diameter units.immediateReturn - If immediateReturn is true then the method returns immediately.public void arcForward(double radius)
ArcMoveController
If radius is positive, the robot arcs left, and the center of the turning circle is on the left side of the robot.
If radius is negative, the robot arcs right, and the center of the turning circle is on the right side of the robot.
If radius is zero, the robot rotates in place.
Postcondition: Motor speeds are unpredictable.
Note: If you have specified a drift correction in the constructor it will not be applied in this method.
arcForward in interface ArcMoveControllerradius - of the arc path. If positive, the left side of the robot is on the inside of the turn. If negative, the left
side of the robot is on the outside of the turn.public void arcBackward(double radius)
ArcMoveController
If radius is positive, the robot arcs left, and the center of the turning circle is on the left side of the robot.
If radius is negative, the robot arcs right, and the center of the turning circle is on the right side of the robot.
If radius is zero, the robot rotates in place.
Postcondition: Motor speeds are unpredictable.
Note: If you have specified a drift correction in the constructor it will not be applied in this method.
arcBackward in interface ArcMoveControllerradius - of the arc path. If positive, the left side of the robot is on the inside of the turn. If negative, the left
side of the robot is on the outside of the turn.public void arc(double radius,
double angle)
ArcMoveControllerangle degrees along the arc.
If radius is positive, the robot arcs left, and the center of the turning circle is on the left side of the robot.
If radius is negative, the robot arcs right, and the center of the turning circle is on the right side of the robot.
If radius is zero, is zero, the robot rotates in place.
Robot will stop when the degrees it has moved along the arc equals angle.
If angle is positive, the robot will turn to the left (anti-clockwise).
If angle is negative, the robot will turn to the right (clockwise).
If angle is zero, the robot will not move and the method returns immediately.
Postcondition: Motor speeds are unpredictable.
Note: If you have specified a drift correction in the constructor it will not be applied in this method.
arc in interface ArcMoveControllerradius - of the arc path. If positive, the left side of the robot is on the inside of the turn. If negative, the left
side of the robot is on the outside of the turn.angle - The sign of the angle determines the direction of the robot turns: Positive is anti-clockwise, negative is clockwise.ArcMoveController.travelArc(double, double)public void travelArc(double radius,
double distance)
ArcMoveControllerdistance along the arc. The units (inches, cm) for distance
must be the same as the units used for radius.
If radius is positive, the robot arcs left, and the center of the turning circle is on the left side of the robot.
If radius is negative, the robot arcs right, and the center of the turning circle is on the right side of the robot.
If radius is zero, the robot rotates in place
The robot will stop when it has moved along the arc distance units.
If distance is positive, the robot will move travel forwards.
If distance is negative, the robot will move travel backwards.
If distance is zero, the robot will not move and the method returns immediately.
Postcondition: Motor speeds are unpredictable.
travelArc in interface ArcMoveControllerradius - of the arc path. If positive, the left side of the robot is on the inside of the turn. If negative, the left
side of the robot is on the outside of the turn.distance - to travel, in same units as radius. The sign of the distance determines the direction of robot motion. Positive drives the robot forward, negative drives it backward.ArcMoveController.arc(double, double)public void travelArc(double radius,
double distance,
boolean immediateReturn)
ArcMoveControllerimmediateReturn parameter.
The units (inches, cm) for distance should be the same as the units used for radius.
If radius is positive, the robot arcs left, and the center of the turning circle is on the left side of the robot.
If radius is negative, the robot arcs right, and the center of the turning circle is on the right side of the robot.
If radius is zero, the robot rotates in place.
The robot will stop when it has moved along the arc distance units.
If distance is positive, the robot will move travel forwards.
If distance is negative, the robot will move travel backwards.
If distance is zero, the robot will not move and the method returns immediately.
Postcondition: Motor speeds are unpredictable.
travelArc in interface ArcMoveControllerradius - of the arc path. If positive, the left side of the robot is on the inside of the turn. If negative, the left
side of the robot is on the outside of the turn.distance - to travel, in same units as radius. The sign of the distance determines the direction of robot motion. Positive drives the robot forward, negative drives it backward.immediateReturn - If immediateReturn is true then the method returns immediately.ArcMoveController.arc(double, double, boolean)public void rotate(double angle)
RotateMoveControllerrotate in interface RotateMoveControllerangle - The angle to rotate in degrees. A positive value rotates left, a negative value right (clockwise).public void rotate(double angle,
boolean immediateReturn)
RotateMoveControllerrotate in interface RotateMoveControllerangle - The angle to rotate in degrees. A positive value rotates left, a negative value right (clockwise).immediateReturn - If true, method returns immediately, otherwise blocks until rotation is complete.public void rotateLeft()
rotateLeft in interface RotateMoveControllerpublic void rotateRight()
rotateRight in interface RotateMoveControllerpublic void arc(double radius,
double angle,
boolean immediateReturn)
ArcMoveControllerimmediateReturn parameter.
If radius is positive, the robot arcs left, and the center of the turning circle is on the left side of the robot.
If radius is negative, the robot arcs right, and the center of the turning circle is on the right side of the robot.
If radius is zero, is zero, the robot rotates in place.
The robot will stop when the degrees it has moved along the arc equals angle.
If angle is positive, the robot will turn to the left (anti-clockwise).
If angle is negative, the robot will turn to the right (clockwise).
If angle is zero, the robot will not move and the method returns immediately.
Postcondition: Motor speeds are unpredictable.
Note: If you have specified a drift correction in the constructor it will not be applied in this method.
arc in interface ArcMoveControllerradius - of the arc path. If positive, the left side of the robot is on the inside of the turn. If negative, the left
side of the robot is on the outside of the turn.angle - The sign of the angle determines the direction of the robot turns: Positive is anti-clockwise, negative is clockwise.immediateReturn - If immediateReturn is true then the method returns immediately.ArcMoveController.travelArc(double, double, boolean)public void stop()
MoveControllerstop in interface MoveControllerpublic boolean isMoving()
MoveControllerisMoving in interface MoveControllerpublic Move getMovement()
MoveProvidergetMovement in interface MoveProviderpublic void addMoveListener(MoveListener listener)
MoveProvideraddMoveListener in interface MoveProviderlistener - the move listener