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
Class TachoNavigator

    java.lang.Object
      lejos.navigation.TachoNavigator

All Implemented Interfaces:
  Navigator

    public class TachoNavigator

extends Object
implements Navigator

The TachoNavigator class can keep track of the robot position and the direction angle it faces; It uses a pilot object to control NXT robot movements.
The position and direction angle values are updated automatically when the movement command returns after the movement is complete and and after stop() command is issued. However, some commands optionally return immediately, to permit sensor monitoring in the main thread. It is then the programmers responsibility to call updatePosition() when the robot motion is completed. All angles are in degrees, distances in the units used to specify robot dimensions. As with pilot, the robot must be have two independently controlled drive wheels.

Field Summary
`Pilot` | `pilot`

Constructor Summary
`TachoNavigator(float wheelDiameter, float driveLength)` Overloaded TachoNavigator constructor that assumes the following: Left motor = Motor.A Right motor = Motor.C
`TachoNavigator(float wheelDiameter, float trackWidth, Motor leftMotor, Motor rightMotor)` Allocates a Navigator object and initializes it with the proper motors.
`TachoNavigator(float wheelDiameter, float trackWidth, Motor leftMotor, Motor rightMotor, boolean reverse)`
`TachoNavigator(Pilot pilot)`

Method Summary
`float` | `angleTo(float x, float y)` returns the direction angle (degrees) to point with coordinates (x,y)
`void` | `backward()` Moves the NXT robot backward until stop() is called.
`float` | `distanceTo(float x, float y)` 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 (x,y) and moves the required distance.
`void` | `goTo(float x, float y, boolean immediateReturn)` Rotates the NXT robot towards the target point (x,y) 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 -).
`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` | `turn(float radius)` Moves the NXT robot in a circular path with a specified radius.
`void` | `turn(float radius, int angle)` Moves the NXT robot in a circular path through a specific angle; If waitForCompletion is true, returns when angle is reached.
`void` | `turn(float radius, int angle, boolean immediateReturn)` Moves the NXT robot in a circular path through a specific angle; If waitForCompletion is true, returns when angle is reached.
`void` | `updatePosition()` Updates robot location (x,y) and direction angle.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait`

Field Detail

### pilot

    public Pilot pilot

Constructor Detail

### TachoNavigator

    public TachoNavigator(float wheelDiameter,
                          float trackWidth,
                          Motor leftMotor,
                          Motor rightMotor)

  Allocates a Navigator object and initializes it with the proper motors. The x and y values and the direction angle are all initialized to 0, so if the first move is forward() the robot will run along the x axis.

  Parameters:
    `wheelDiameter` - The diameter of the wheel, usually printed right on the wheel, in centimeters (e.g. 49.6 mm = 4.96 cm = 1.95 in)
    `trackWidth` - The distance from the center of the left tire to the center of the right tire, in units of your choice
    `rightMotor` - The motor used to drive the right wheel e.g. Motor.C.
    `leftMotor` - The motor used to drive the left wheel e.g. Motor.A.

### TachoNavigator

    public TachoNavigator(float wheelDiameter,
                          float trackWidth,
                          Motor leftMotor,
                          Motor rightMotor,
                          boolean reverse)

### TachoNavigator

    public TachoNavigator(Pilot pilot)

### TachoNavigator

    public TachoNavigator(float wheelDiameter,
                          float driveLength)

  Overloaded TachoNavigator constructor that assumes the following:
  Left motor = Motor.A Right motor = Motor.C

  Parameters:
    `wheelDiameter` - The diameter of the wheel, usually printed right on the wheel, in centimeters (e.g. 49.6 mm = 4.96 cm)
    `driveLength` - The distance from the center of the left tire to the center of the right tire,

Method Detail

### getX

    public float getX()

  Returns the current x coordinate of the NXT.

  Specified by:
    `getX` in interface `Navigator`
  Returns:
    float Present x coordinate.

### getY

    public 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.

  Specified by:
    `getY` in interface `Navigator`
  Returns:
    float Present y coordinate.

### getAngle

    public 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.

  Specified by:
    `getAngle` in interface `Navigator`
  Returns:
    float Angle in degrees.

### setPosition

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

  sets robot location (x,y) and direction angle

  Specified by:
    `setPosition` in interface `Navigator`
  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

### setSpeed

    public void setSpeed(int speed)

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

  Specified by:
    `setSpeed` in interface `Navigator`

### forward

    public void forward()

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

  Specified by:
    `forward` in interface `Navigator`
  See Also:
    `Navigator.stop().`

### backward

    public void backward()

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

  Specified by:
    `backward` in interface `Navigator`
  See Also:
    `Navigator.stop().`

### stop

    public void stop()

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

  Specified by:
    `stop` in interface `Navigator`
  See Also:
    `Navigator.forward().`

### isMoving

    public boolean isMoving()

  returns true iff the robot is moving under power

  Specified by:
    `isMoving` in interface `Navigator`

### travel

    public void travel(float distance)

  Moves the NXT robot a specific distance. A positive value moves it forwards and a negative value moves it backwards. The robot position is updated atomatically when the method returns.

  Specified by:
    `travel` in interface `Navigator`
  Parameters:
    `distance` - The positive or negative distance to move the robot, same units as _wheelDiameter

### travel

    public 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.

  Specified by:
    `travel` in interface `Navigator`
  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.

### rotateLeft

    public void rotateLeft()

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

  Specified by:
    `rotateLeft` in interface `Navigator`

### rotateRight

    public void rotateRight()

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

  Specified by:
    `rotateRight` in interface `Navigator`

### rotate

    public void rotate(float angle)

  Rotates the NXT robot a specific number of degrees in a direction (+ or -).

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

### rotate

    public void rotate(float angle,
                       boolean immediateReturn)

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

  Specified by:
    `rotate` in interface `Navigator`
  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

    public 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.

  Specified by:
    `rotateTo` in interface `Navigator`
  Parameters:
    `angle` - The angle to rotate to, in degrees.

### rotateTo

    public 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.

  Specified by:
    `rotateTo` in interface `Navigator`
  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.

### goTo

    public void goTo(float x,
                     float y)

  Rotates the NXT robot towards the target point (x,y) and moves the required distance. Method returns when target point is reached, and the robot position is updated;

  Specified by:
    `goTo` in interface `Navigator`
  Parameters:
    `x` - The x coordinate to move to.
    `y` - The y coordinate to move to.

### goTo

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

  Rotates the NXT robot towards the target point (x,y) and moves the required distance. Method returns when target point is reached, and the robot position is updated;

  Specified by:
    `goTo` in interface `Navigator`
  Parameters:
    `x` - The x coordinate to move to.
    `y` - The y coordinate to move to.
    `immediateReturn` - iff true, method returns immediately

### distanceTo

    public float distanceTo(float x,
                            float y)

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

  Specified by:
    `distanceTo` in interface `Navigator`
  Parameters:
    `x` - coordinate of the point
    `y` - coordinate of the point
  Returns:
    the distance from the robot current location to the point

### angleTo

    public float angleTo(float x,
                         float y)

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

  Specified by:
    `angleTo` in interface `Navigator`
  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

    public 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.

  Specified by:
    `updatePosition` in interface `Navigator`

### turn

    public void turn(float radius)

  Moves the NXT robot in a circular path with a specified radius.
  The center of the turning circle is on the right side of the robot iff parameter radius is negative;
  Postcondition: motor speed is NOT restored to previous value;

  Parameters:
    `radius` - is the radius of the circular path. If positive, the left wheel is on the inside of the turn. If negative, the left wheel is on the outside.

### turn

    public void turn(float radius,
                     int angle)

  Moves the NXT robot in a circular path through a specific angle; If waitForCompletion is true, returns when angle is reached.
  The center of the turning circle is on the right side of the robot iff parameter radius is negative. Robot will stop when total rotation equals angle. If angle is negative, robot will move travel backwards.

  Parameters:
    `radius` - radius of the turning circle
    `angle` - the angle by which the robot heading changes, + or -

### turn

    public void turn(float radius,
                     int angle,
                     boolean immediateReturn)

  Moves the NXT robot in a circular path through a specific angle; If waitForCompletion is true, returns when angle is reached.
  The center of the turning circle is on the right side of the robot iff parameter radius is negative. Robot will stop when total rotation equals angle. If angle is negative, robot will move travel backwards.

  Parameters:
    `radius` - see turn(turnRage, angle)
    `immediateReturn` - iff true, the method returns immediately, in which case the programmer
    is responsible for calling updatePosition() before the robot moves again.

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