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

## josx.robotics
Class TimingNavigator

    java.lang.Object
      josx.robotics.TimingNavigator

All Implemented Interfaces:
  Navigator

    public class TimingNavigator

extends Object
implements Navigator

The Navigator class contains methods for performing basic navigational movements. Normally the Navigator class is instantiated as an object and methods are called on that object. It can also be extended by your robot code, but the constructor method will need to be overwritten if you do this. 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).

Version:
  1.4 17-Feb-2002
Author:
  Brian Bagnall

Constructor Summary
`TimingNavigator(Motor right, Motor left, float timeOneMeter, float timeRotate)` Allocates a Navigator object and initializes if with the left and right wheels.

Method Summary
`void` | `backward()` Moves the RCX robot backward until stop() is called.
`void` | `forward()` Moves the RCX robot forward until stop() is called.
`float` | `getAngle()` Returns the current angle the RCX robot is facing.
`float` | `getX()` Returns the current x coordinate of the RCX.
`float` | `getY()` Returns the current y coordinate of the RCX.
`void` | `gotoAngle(float angle)` Rotates the RCX robot to point in a certain direction.
`void` | `gotoPoint(float x, float y)` Rotates the RCX robot towards the target point and moves the required distance.
`void` | `rotate(float angle)` Rotates the RCX robot a specific number of degrees in a direction (+ or -).This method will return once the rotation is complete.
`void` | `setMomentumDelay(short delay)` A variable that adds extra time to each rotation.
`void` | `stop()` Halts the RCX robot and calculates new x, y coordinates.
`void` | `travel(int distance)` Moves the RCX robot a specific distance.

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

Constructor Detail

### TimingNavigator

    public TimingNavigator(Motor right,
                           Motor left,
                           float timeOneMeter,
                           float timeRotate)

  Allocates a Navigator object and initializes if with the left and right wheels. The x and y values will each equal 0 (cm's) on initialization, and the starting angle is 0 degrees, so if the first move is forward() the robot will run along the x axis.
  Note: If you find your robot is going backwards when you tell it to go forwards, try rotating the wires to the motor ports by 90 degrees.

  Parameters:
    `right` - The motor used to drive the right wheel e.g. Motor.C.
    `left` - The motor used to drive the left wheel e.g. Motor.A.
    `timeOneMeter` - The number of seconds it takes your robot to drive one meter (e.g. 2.0 seconds is normal for a fast robot, 5 seconds for a slower robot).
    `timeRotate` - The number of seconds it takes your robot to rotate 360 degrees. (e.g. 0.646 is normal for a small axle length, 2.2 for a larger axle length)

Method Detail

### setMomentumDelay

    public void setMomentumDelay(short delay)

  A variable that adds extra time to each rotation. This gives the robot more time to overcome momentum when starting a rotation. Proper use of this variable increases accuracy dramatically.
  Note: The use of this method also causes the timeRotate variable (supplied in the constructor) to be recalculated. This method assumes the time to rotate 360 degrees also includes the delay in overcoming momentum, so this method subtracts delay from timeRotate.

### getX

    public float getX()

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

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

### getY

    public float getY()

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

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

### getAngle

    public float getAngle()

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

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

### rotate

    public void rotate(float angle)

  Rotates the RCX robot a specific number of degrees in a direction (+ or -).This method will return once the rotation is complete.

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

### gotoAngle

    public void gotoAngle(float angle)

  Rotates the RCX robot to point in a certain direction. It will take the shortest path necessary to point to the desired angle. Method returns once rotation is complete.

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

### gotoPoint

    public void gotoPoint(float x,
                          float y)

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

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

### travel

    public void travel(int distance)

  Moves the RCX robot a specific distance. A positive value moves it forwards and a negative value moves it backwards. Method returns when movement is done.

  Specified by:
    `travel` in interface `Navigator`
  Parameters:
    `distance` - The positive or negative distance to move the robot (in centimeters).

### forward

    public void forward()

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

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

### backward

    public void backward()

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

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

### stop

    public void stop()

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

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

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