|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Pilot
The Pilot interface forms a common set of functions an implementation must offer in order to be used by higher level navigation classes. The Pilot hides the details of the robots physical construction and the required control algorithms from the rest of this package.
Method Summary | |
---|---|
void |
arc(float radius)
Starts the NXT robot moving along an arc with a specified radius. |
void |
arc(float radius,
float angle)
Moves the NXT robot along an arc with a specified radius and angle, after which the robot stops moving. |
void |
arc(float radius,
float angle,
boolean immediateReturn)
Moves the NXT robot along an arc with a specified radius and angle, after which the robot stops moving. |
void |
backward()
Starts the NXT robot moving backward . |
void |
forward()
Starts the NXT robot moving forward. |
float |
getAngle()
angle of rotation of the robot since last call to reset. |
float |
getMoveMaxSpeed()
|
float |
getMoveSpeed()
|
float |
getTravelDistance()
distance traveled since the last call to reset. |
float |
getTurnMaxSpeed()
|
float |
getTurnSpeed()
|
boolean |
isMoving()
true if the robot is moving |
void |
reset()
Reset traveled distance and rotated angle. |
void |
rotate(float angle)
Rotates the NXT robot the specified number of degrees; direction determined by the sign of the parameter. |
void |
rotate(float angle,
boolean immediateReturn)
Rotates the NXT robot the specifed number of degress; direction determined by the sign of the parameter. |
void |
setMoveSpeed(float speed)
Sets the movement speed of the robot. |
void |
setSpeed(int speed)
Deprecated. in 0.8, use setTurnSpeed() and setMoveSpeed(). The method was deprecated, as this it requires knowledge of the robots physical construction, which this interface should hide! |
void |
setTurnSpeed(float speed)
Sets the turning speed of the robot. |
void |
steer(float turnRate)
Starts the robot moving along a curved path. |
void |
steer(float turnRate,
float angle)
Moves the robot along a curved path through a specified turn angle. |
void |
steer(float turnRate,
float angle,
boolean immediateReturn)
Moves the robot along a curved path for a specified angle of rotation. |
void |
stop()
Halts the NXT robot |
void |
travel(float distance)
Moves the NXT robot a specific distance. |
void |
travel(float distance,
boolean immediateReturn)
Moves the NXT robot a specific distance. |
void |
travelArc(float radius,
float distance)
Moves the NXT robot a specified distance along an arc mof specified radius, after which the robot stops moving. |
void |
travelArc(float radius,
float distance,
boolean immediateReturn)
Moves the NXT robot a specified distance along an arc of specified radius, after which the robot stops moving. |
Method Detail |
---|
void forward()
void backward()
void stop()
boolean isMoving()
void setMoveSpeed(float speed)
speed
- The speed in wheel diameter units per second.float getMoveSpeed()
float getMoveMaxSpeed()
void setTurnSpeed(float speed)
speed
- The speed in degree per second.float getTurnSpeed()
float getTurnMaxSpeed()
void setSpeed(int speed)
speed
- The speed of the drive motor(s) in degree per second.void travel(float distance)
distance
- The positive or negative distance to move the robot.void travel(float distance, boolean immediateReturn)
distance
- The positive or negative distance to move the robot, in wheel diameter units.immediateReturn
- If immediateReturn is true then the method returns immediately.void rotate(float angle)
angle
- The angle to rotate in degrees. A positive value rotates left, a negative value right (clockwise).void rotate(float angle, boolean immediateReturn)
angle
- The angle to rotate in degrees. A positive value rotates left, a negative value right (clockwise).immediateReturn
- If immediateReturn is true then the method returns immediatelyfloat getAngle()
float getTravelDistance()
void steer(float turnRate)
arc(float radius)
method except it uses a ratio of motor
speeds to determine the curvature of the path and therefore has the ability to drive straight. This makes
it usrful for line following applications.
The turnRate
specifies the sharpness of the turn, between -200 and +200.
The turnRate
is used to calculate the ratio of inner wheel speed to outer wheel speed as a percent.
Formula: ratio = 100 - abs(turnRate)
.
When the ratio is negative, the outer and inner wheels rotate in
opposite directions.
If turnRate
is positive, the center of the turning circle is on the left side of the robot.
If turnRate
is negative, the center of the turning circle is on the right side of the robot.
If turnRate
is zero, the robot travels in a straight line
Examples of how the formula works:
steer(0)
-> inner and outer wheels turn at the same speed, travel straight
steer(25)
-> the inner wheel turns at 75% of the speed of the outer wheel, turn left
steer(100)
-> the inner wheel stops and the outer wheel is at 100 percent, turn left
steer(200)
-> the inner wheel turns at the same speed as the outer wheel - a zero radius turn.
Note: If you have specified a drift correction in the constructor it will not be applied in this method.
turnRate
- If positive, the left side of the robot is on the inside of the turn. If negative,
the left side is on the outside.void steer(float turnRate, float angle)
arc(float radius , float angle)
method except it uses a ratio of motor
speeds to determine the curvature of the path and therefore has the ability to drive straight. This makes
it useful for line following applications. This method does not return until the robot has
completed moving angle
degrees along the arc.turnRate
specifies the sharpness of the turn, between -200 and +200.steer(float turnRate)
The robot will stop when the degrees it has moved along the arc equals angle
.
If angle
is positive, the robot will move travel forwards.
If angle
is negative, the robot will move travel backwards.
If angle
is zero, the robot will not move and the method returns immediately.
Note: If you have specified a drift correction in the constructor it will not be applied in this method.
turnRate
- If positive, the left side of the robot is on the inside of the turn. If negative,
the left side is on the outside.angle
- The angle through which the robot will rotate. If negative, robot traces the turning circle backwards.void steer(float turnRate, float angle, boolean immediateReturn)
arc(float radius, float angle, boolean immediateReturn)
method except it uses a ratio of motor
speeds to speeds to determine the curvature of the path and therefore has the ability to drive straight.
This makes it useful for line following applications. This method has the ability to return immediately
by using the immediateReturn
parameter set to true.
The turnRate
specifies the sharpness of the turn, between -200 and +200.
For details about how this paramet works, see steer(float turnRate)
The robot will stop when the degrees it has moved along the arc equals angle
.
If angle
is positive, the robot will move travel forwards.
If angle
is negative, the robot will move travel backwards.
If angle
is zero, the robot will not move and the method returns immediately.
Note: If you have specified a drift correction in the constructor it will not be applied in this method.
turnRate
- If positive, the left side of the robot is on the inside of the turn. If negative,
the left side is on the outside.angle
- The angle through which the robot will rotate. If negative, robot traces the turning circle backwards.immediateReturn
- If immediateReturn is true then the method returns immediately and your code MUST call
updatePostion() when the robot has stopped. Otherwise, the robot position is lost.void arc(float 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 arc(float)
method can not drive a straight line, which makes
it impractical for line following. A better solution for line following is
steer(float)
, which uses proportional steering and can drive straight lines and arcs.
Postcondition: Motor speeds are unpredictable.
Note: If you have specified a drift correction in the constructor it will not be applied in this method.
radius
- 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.steer(float)
void arc(float radius, float angle)
angle
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.
The arc(float)
method can not drive a straight line, which makes
it impractical for line following. A better solution for line following is
steer(float)
, which uses proportional steering and can drive straight lines and arcs.
Robot will stop when the degrees it has moved along the arc equals angle
.
If angle
is positive, the robot will move travel forwards.
If angle
is negative, the robot will move travel backwards.
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.
radius
- 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 robot motion. Positive drives the robot forward, negative drives it backward.steer(float, float)
,
travelArc(float, float)
void arc(float radius, float angle, boolean immediateReturn)
immediateReturn
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 arc(float, float, boolean)
method can not drive a straight line, which makes
it impractical for line following. A better solution for line following is
steer(float, float, boolean)
, which uses proportional steering and can drive straight lines and arcs.
The robot will stop when the degrees it has moved along the arc equals angle
.
If angle
is positive, the robot will move travel forwards.
If angle
is negative, the robot will move travel backwards.
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.
radius
- 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 robot motion. Positive drives the robot forward, negative drives it backward.immediateReturn
- If immediateReturn is true then the method returns immediately and your code MUST call
updatePostion() when the robot has stopped. Otherwise, the robot position is lost.steer(float, float, boolean)
,
travelArc(float, float, boolean)
void travelArc(float radius, float distance)
distance
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 travelArc(float, float)
method can not drive a straight line, which makes
it impractical for line following. A better solution for line following is
steer(float)
, which uses proportional steering and can drive straight lines and arcs.
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.
Note: If you have specified a drift correction in the constructor it will not be applied in this method.
radius
- 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.steer(float, float)
,
arc(float, float)
void travelArc(float radius, float distance, boolean immediateReturn)
immediateReturn
parameter.
The units (inches, cm) for distance
should be the same as the units used for radius
.
Warning: Your code must call updatePostion() when the robot has stopped,
otherwise, the robot position is lost.
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 travelArc(float, float, boolean)
method can not drive a straight line, which makes
it impractical for line following. A better solution for line following is
steer(float, float, boolean)
, which uses proportional steering and can drive straight lines and arcs.
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.
Note: If you have specified a drift correction in the constructor it will not be applied in this method.
radius
- 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 and your code MUST call
updatePostion() when the robot has stopped. Otherwise, the robot position is lost.steer(float, float, boolean)
,
arc(float, float, boolean)
void reset()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |