|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Navigator
The Navigator interface contains methods for performing basic navigational movements. Normally the Navigator class is instantiated as an object and methods are called on that object. Note: This class will only work for robots using two motors to steer differentially that can rotate within its footprint (i.e. turn on one spot). Modified by Roger Glassey 29 Jan 2007
Method Summary | |
---|---|
float |
angleTo(float x,
float y)
returns the direction angle (degrees) to the point with coordinates (x,y) |
void |
backward()
Moves the NXT robot backward until stop() is called. |
float |
distanceTo(float x,
float y)
returns the distance from robot to the point with coordinates (x,y) . |
void |
forward()
Moves the NXT robot forward until stop() is called. |
float |
getAngle()
Returns the current angle the NXT robot is facing. |
float |
getX()
Returns the current x coordinate of the NXT. |
float |
getY()
Returns the current y coordinate of the NXT. |
void |
goTo(float x,
float y)
Rotates the NXT robot towards the target point and moves the required distance. |
void |
goTo(float x,
float y,
boolean immediateReturn)
Rotates the NXT robot towards the target point and moves the required distance. |
boolean |
isMoving()
returns true iff the robot is moving under power |
void |
rotate(float angle)
Rotates the NXT robot a specific number of degrees in a direction (+ or -).This method will return once the rotation is complete. |
void |
rotate(float angle,
boolean immediateReturn)
Rotates the NXT robot a specific number of degrees in a direction (+ or -). |
void |
rotateLeft()
Rotates the NXT to the left (increasing angle) until stop() is called; |
void |
rotateRight()
Rotates the NXT to the right (decreasing angle) until stop() is called; |
void |
rotateTo(float angle)
Rotates the NXT robot to point in a specific direction. |
void |
rotateTo(float angle,
boolean immediateReturn)
Rotates the NXT robot to point in a specific direction. |
void |
setMoveSpeed(float speed)
set the movement speed of the robot, wheel diameter units/sec |
void |
setPosition(float x,
float y,
float directionAngle)
sets robot location (x,y) and direction angle |
void |
setTurnSpeed(float speed)
sets the rotation speed of the robot in deg/secm when robot is turning in place |
void |
stop()
Halts the NXT robot and calculates new x, y coordinates. |
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 |
updatePosition()
Updates robot location (x,y) and direction angle. |
Method Detail |
---|
float getX()
float getY()
float getAngle()
boolean isMoving()
void setMoveSpeed(float speed)
void setTurnSpeed(float speed)
void forward()
stop().
void backward()
stop().
void stop()
forward().
void setPosition(float x, float y, float directionAngle)
x
- the x coordinate of the roboty
- the y coordinate of the robotdirectionAngle
- the angle the robot is heading, measured from the x axisvoid rotateLeft()
void rotateRight()
void rotate(float angle)
angle
- Angle to rotate in degrees. A positive value rotates left, a negative value right.void rotate(float angle, boolean immediateReturn)
angle
- Angle to rotate in degrees. A positive value rotates left, a negative value right.immediateReturn
- iff true, the method returns immediately, in which case the programmer void rotateTo(float angle)
angle
- The angle to rotate to, in degrees.void rotateTo(float angle, boolean immediateReturn)
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.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, same units as _wheelDiameterimmediateReturn
- iff true, the method returns immediately, in which case the programmer void goTo(float x, float y)
x
- The x coordinate to move to.y
- The y coordinate to move to.void goTo(float x, float y, boolean immediateReturn)
x
- The x coordinate to move to.y
- The y coordinate to move to.immediateReturn
- Indicates whether method should return immediately.float distanceTo(float x, float y)
x
- coordinate of the pointy
- coordinate of the point
float angleTo(float x, float y)
x
- coordinate of the pointy
- coordinate of the point
void updatePosition()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |