Class MultipleIntersectionChooser

java.lang.Object
  extended by JavaRCX
      extended by MultipleIntersectionChooser

public class MultipleIntersectionChooser
extends JavaRCX

MultipleIntersectionChooser.java
 Given: multiple intersections to choose from and an ordering of spoke numbers to take at successive intersections.
 The robot when determining it is at an intersection, will turn left a bit, then rotate clockwise starting(inclusive)at 12:00
 counting spokes. When it hits the nth spoke it resumes intersection finder behavior.
 Once done with iterating through array of spokes, the program terminates.
 Can optionally change code to reset index to 0 if you hit the end of the array to allow continuous looping.
 

Since:
1.0

Field Summary
static int index
          The index of SPOKES that keeps track of which spoke is next
static int[] SPOKES
          The order of spokes to take as robot comes to different intersections.
 
Fields inherited from class JavaRCX
ALL, CENTER_ONLY, CENTER_RIGHT, DARK, L_ROTATION, LEFT_CENTER, LEFT_ONLY, LEFT_RIGHT, NONE, POWER, R_ROTATION, RIGHT_ONLY, state, watcher
 
Constructor Summary
MultipleIntersectionChooser()
           
 
Method Summary
static void chooseSpoke()
          Given the index of SPOKES above and that the robot is at an intersection it will rotate to SPOKES[index] by counting black lines it crosses.
static boolean isIntersection(int triggerState)
          Determines whether at an intersection or not.
static void main(java.lang.String[] args)
          Runs forever taking appropriate motor actions for each state it is in.
 
Methods inherited from class JavaRCX
initialize, lost, powerOff
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPOKES

public static final int[] SPOKES
The order of spokes to take as robot comes to different intersections. Change values in this array to change the ordering of spokes taken at successive intersections.


index

public static int index
The index of SPOKES that keeps track of which spoke is next

Constructor Detail

MultipleIntersectionChooser

public MultipleIntersectionChooser()
Method Detail

main

public static void main(java.lang.String[] args)
Runs forever taking appropriate motor actions for each state it is in.
 While loops within some statements attempt to fine tune the robot so it is back on the line in the CENTER_ONLY state.

Parameters:
args - a String[] value, command line arguments (none in our case)

isIntersection

public static boolean isIntersection(int triggerState)
Determines whether at an intersection or not.  
 This method is thread safe because it is called from within main, so no call to isIntersection() will occur here.
 The watcher thread has no effect on anything here, it only goes back into effect when execution returns to the main.

Parameters:
triggerState - an int value, the state of the sensors that called this method.
Returns:
a boolean value, whether or not the robot is at an intersection.

chooseSpoke

public static void chooseSpoke()
Given the index of SPOKES above and that the robot is at an intersection
 it will rotate to SPOKES[index] by counting black lines it crosses.
 This method is thread safe from main, so calls to isIntersection() will not be fired here.