Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## lejos.navigation
Interface Navigator

All Known Implementing Classes:
  TachoNavigator

    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

Version:
  0.2 - Jan-2007
Author:
  Brian Bagnall

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` | `setPosition(float x, float y, float directionAngle)` sets robot location (x,y) and direction angle
`void` | `setSpeed(int speed)` sets the motor speed of the robot, in degrees/second.
`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

### getX

    float getX()

  Returns the current x coordinate of the NXT. Note: At present it will only give an updated reading when the NXT is stopped.

  Returns:
    float Present x coordinate.

### getY

    float getY()

  Returns the current y coordinate of the NXT. Note: At present it will only give an updated reading when the NXT is stopped.

  Returns:
    float Present y coordinate.

### getAngle

    float getAngle()

  Returns the current angle the NXT robot is facing. Note: At present it will only give an updated reading when the NXT is stopped.

  Returns:
    float directionAngle in degrees.

### isMoving

    boolean isMoving()

  returns true iff the robot is moving under power

### setSpeed

    void setSpeed(int speed)

  sets the motor speed of the robot, in degrees/second.

### forward

    void forward()

  Moves the NXT robot forward until stop() is called.

  See Also:
    `stop().`

### backward

    void backward()

  Moves the NXT robot backward until stop() is called.

  See Also:
    `stop().`

### stop

    void stop()

  Halts the NXT robot and calculates new x, y coordinates.

  See Also:
    `forward().`

### setPosition

    void setPosition(float x,
                     float y,
                     float directionAngle)

  sets robot location (x,y) and direction angle

  Parameters:
    `x` - the x coordinate of the robot
    `y` - the y coordinate of the robot
    `directionAngle` - the angle the robot is heading, measured from the x axis

### rotateLeft

    void rotateLeft()

  Rotates the NXT to the left (increasing angle) until stop() is called;

### rotateRight

    void rotateRight()

  Rotates the NXT to the right (decreasing angle) until stop() is called;

### rotate

    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.

  Parameters:
    `angle` - Angle to rotate in degrees. A positive value rotates left, a negative value right.

### rotate

    void rotate(float angle,
                boolean immediateReturn)

  Rotates the NXT robot a specific number of degrees in a direction (+ or -). If immediateReturn is true, method returns immediately and your code MUST call updatePostion() when the robot has stopped. Otherwise, the robot position is lost.

  Parameters:
    `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
    is responsible for calling updatePosition() before the robot moves again.

### rotateTo

    void rotateTo(float angle)

  Rotates the NXT robot to point in a specific direction. It will take the shortest path necessary to point to the desired angle.

  Parameters:
    `angle` - The angle to rotate to, in degrees.

### rotateTo

    void rotateTo(float angle,
                  boolean immediateReturn)

  Rotates the NXT robot to point in a specific direction. It will take the shortest path necessary to point to the desired angle. If immediateReturnis true, method returns immidiately and your code MUST call updatePostion() when the robot has stopped. Otherwise, the robot position is lost.

  Parameters:
    `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.

### travel

    void travel(float distance)

  Moves the NXT robot a specific distance. A positive value moves it forward and a negative value moves it backward. Method returns when movement is done.

  Parameters:
    `distance` - The positive or negative distance to move the robot.

### travel

    void travel(float distance,
                boolean immediateReturn)

  Moves the NXT robot a specific distance. A positive value moves it forwards and a negative value moves it backwards. If immediateReturnis true, method returns immidiately and your code MUST call updatePostion() when the robot has stopped. Otherwise, the robot position is lost.

  Parameters:
    `distance` - The positive or negative distance to move the robot, same units as _wheelDiameter
    `immediateReturn` - iff true, the method returns immediately, in which case the programmer
    is responsible for calling updatePosition() before the robot moves again.

### goTo

    void goTo(float x,
              float y)

  Rotates the NXT robot towards the target point and moves the required distance.

  Parameters:
    `x` - The x coordinate to move to.
    `y` - The y coordinate to move to.

### goTo

    void goTo(float x,
              float y,
              boolean immediateReturn)

  Rotates the NXT robot towards the target point and moves the required distance.

  Parameters:
    `x` - The x coordinate to move to.
    `y` - The y coordinate to move to.
    `immediateReturn` - Indicates whether method should return immediately.

### distanceTo

    float distanceTo(float x,
                     float y)

  returns the distance from robot to the point with coordinates (x,y) .

  Parameters:
    `x` - coordinate of the point
    `y` - coordinate of the point
  Returns:
    the distance from the robot current location to the point

### angleTo

    float angleTo(float x,
                  float y)

  returns the direction angle (degrees) to the point with coordinates (x,y)

  Parameters:
    `x` - coordinate of the point
    `y` - coordinate of the point
  Returns:
    the direction angle to the point (x,y) from the NXT. Rotate to this angle to head toward it.

### updatePosition

    void updatePosition()

  Updates robot location (x,y) and direction angle. Called by stop, and movement commands that terminate when complete. Must be called after a command that returns immediatly, but after robot movement stops, and before another movement method is called.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD