Class JavaRCX

java.lang.Object
  extended by JavaRCX
Direct Known Subclasses:
LineFollower

public class JavaRCX
extends java.lang.Object

JavaRCX.java 
 Contains basic methods and variables common to all robot objectives.

Since:
1.0

Field Summary
static int ALL
          All sensors dark.
static int CENTER_ONLY
          Center sensor dark.
static int CENTER_RIGHT
          Center and right sensors dark.
static int DARK
          The level at which readings are considered black by the light sensor (<=DARK)
static int L_ROTATION
          Counter variable used to estimate how far the robot should turn left when lost
static int LEFT_CENTER
          Left and center sensors dark.
static int LEFT_ONLY
          Left sensor dark.
static int LEFT_RIGHT
          Left and right sensors dark.
static int NONE
          No sensors dark.
static int POWER
          Power level of the motors.
static int R_ROTATION
          Counter variable used to estimate how far the robot should turn right when lost
static int RIGHT_ONLY
          Right sensor dark.
static int state
          Which state the sensors of the robot are in - possible values are constants below.
static LightWatcher watcher
          A separate background thread that reads values from the light sensors and updates the state variable.
 
Constructor Summary
JavaRCX()
           
 
Method Summary
static void initialize()
           Precondition: State must start at CENTER_ONLY.
static void lost()
          When the state NONE occurs this method will scan to the left for L_ROTATION then scan farther to the right R_ROTATION.
static void powerOff()
          Exit program with 5 second delay.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

state

public static int state
Which state the sensors of the robot are in - possible values are constants below.


watcher

public static LightWatcher watcher
A separate background thread that reads values from the light sensors and updates the state variable.


NONE

public static final int NONE
No sensors dark.

See Also:
Constant Field Values

LEFT_ONLY

public static final int LEFT_ONLY
Left sensor dark.

See Also:
Constant Field Values

CENTER_ONLY

public static final int CENTER_ONLY
Center sensor dark.

See Also:
Constant Field Values

RIGHT_ONLY

public static final int RIGHT_ONLY
Right sensor dark.

See Also:
Constant Field Values

LEFT_CENTER

public static final int LEFT_CENTER
Left and center sensors dark.

See Also:
Constant Field Values

LEFT_RIGHT

public static final int LEFT_RIGHT
Left and right sensors dark.

See Also:
Constant Field Values

CENTER_RIGHT

public static final int CENTER_RIGHT
Center and right sensors dark.

See Also:
Constant Field Values

ALL

public static final int ALL
All sensors dark.

See Also:
Constant Field Values

DARK

public static final int DARK
The level at which readings are considered black by the light sensor (<=DARK)

See Also:
Constant Field Values

POWER

public static final int POWER
Power level of the motors.
 Try More experimentation with power levels and how much better light sensors are able 
 to read at different speeds of the motor.

See Also:
Constant Field Values

R_ROTATION

public static final int R_ROTATION
Counter variable used to estimate how far the robot should turn right when lost

See Also:
Constant Field Values

L_ROTATION

public static final int L_ROTATION
Counter variable used to estimate how far the robot should turn left when lost

See Also:
Constant Field Values
Constructor Detail

JavaRCX

public JavaRCX()
Method Detail

lost

public static void lost()
When the state NONE occurs this method will scan to the left for L_ROTATION 
 then scan farther to the right R_ROTATION.
 This will ultimately cause the robot to do a 360 unless it hits a black line at some point. 


initialize

public static void initialize()
 Precondition: State must start at CENTER_ONLY.
 Activates the sensors, sets up motor power,starts light sensor thread.


powerOff

public static void powerOff()
Exit program with 5 second delay.