|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectJavaRCX
MultipleIntersectionChooser
public class MultipleIntersectionChooser
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.
| 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 |
|---|
public static final int[] SPOKES
public static int index
SPOKES that keeps track of which spoke is next
| Constructor Detail |
|---|
public MultipleIntersectionChooser()
| Method Detail |
|---|
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.
args - a String[] value, command line arguments (none in our case)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.
triggerState - an int value, the state of the sensors that called this method.
boolean value, whether or not the robot is at an intersection.public static void chooseSpoke()
Given the index ofSPOKESabove and that the robot is at an intersection it will rotate toSPOKES[index]by counting black lines it crosses. This method is thread safe from main, so calls toisIntersection()will not be fired here.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||