| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectrcx.josx.robotics.RotationNavigator
public class RotationNavigator
The RotationNavigator class contains methods for performing basic navigational
 movements. This class uses two rotation sensors to monitor the wheels of the
 differential drive. For this class to work properly, the rotation sensors
 should record positive (+) values when the wheels move forward, and negative (-)
 values when the wheels move backward. This class also assumes the Motor.forward()
 command will cause the drive wheels to move in a forward direction.
 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).
| Field Summary | 
|---|
| Fields inherited from interface rcx.josx.platform.rcx.SensorConstants | 
|---|
| BOOLEAN_VALUE, CANONICAL_VALUE, RAW_VALUE, SENSOR_MODE_ANGLE, SENSOR_MODE_BOOL, SENSOR_MODE_DEGC, SENSOR_MODE_DEGF, SENSOR_MODE_EDGE, SENSOR_MODE_PCT, SENSOR_MODE_PULSE, SENSOR_MODE_RAW, SENSOR_TYPE_LIGHT, SENSOR_TYPE_RAW, SENSOR_TYPE_ROT, SENSOR_TYPE_TEMP, SENSOR_TYPE_TOUCH | 
| Constructor Summary | |
|---|---|
| RotationNavigator(float wheelDiameter,
                  float driveLength,
                  float ratio)Overloaded RotationNavigator constructor that assumes the following: Left motor = Motor.A Right motor = Motor.C Left rotation sensor = Sensor.S1 Right rotation sensor = Sensor.S3 | |
| RotationNavigator(float wheelDiameter,
                  float driveLength,
                  float ratio,
                  Motor leftMotor,
                  Motor rightMotor,
                  Sensor leftRot,
                  Sensor rightRot)Allocates a RotationNavigator object and initializes if with the proper motors and sensors. | |
| 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 -). | 
|  void | stop()Halts the RCX robot and calculates new x, y coordinates. | 
|  void | travel(int dist)Moves the RCX robot a specific distance. | 
| Methods inherited from class java.lang.Object | 
|---|
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public RotationNavigator(float wheelDiameter,
                         float driveLength,
                         float ratio,
                         Motor leftMotor,
                         Motor rightMotor,
                         Sensor leftRot,
                         Sensor rightRot)
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, in centimeters.ratio - The ratio of sensor rotations to wheel rotations.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.rightRot - Sensor used to read rotations from the right wheel. e.g. Sensor.S3leftRot - Sensor used to read rotations from the left wheel. e.g. Sensor.S1
public RotationNavigator(float wheelDiameter,
                         float driveLength,
                         float ratio)
wheelDiameter - The diameter of the wheel, usually printed right on the
 wheel, in centimeters (e.g. 49.6 mm = 4.96 cm)axleLength - The distance from the center of the left tire to the center
 of the right tire, in centimeters.ratio - The ratio of sensor rotations to wheel rotations.| Method Detail | 
|---|
public float getX()
getX in interface Navigatorpublic float getY()
getY in interface Navigatorpublic float getAngle()
getAngle in interface Navigatorpublic void rotate(float angle)
rotate in interface Navigatorangle - Angle to rotate in degrees. A positive value rotates left, a negative value right.public void gotoAngle(float angle)
gotoAngle in interface Navigatorangle - The angle to rotate to, in degrees.
public void gotoPoint(float x,
                      float y)
gotoPoint in interface Navigatorx - The x coordinate to move to.y - The y coordinate to move to.public void travel(int dist)
travel in interface Navigatordist - The positive or negative distance to move the robot (in centimeters).public void forward()
forward in interface NavigatorNavigator.stop().public void backward()
backward in interface NavigatorNavigator.stop().public void stop()
stop in interface NavigatorNavigator.forward().| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||