Revision 1891
Merged highway code into main to test switching states between intersection and highway. Highway code doesn't behave as it should, but I may be calling it wrong. Switching states is currently based on button1, until bar codes get integrated. State switches are weird, and don't aways go into the correct state or wait for the button.
main.c | ||
---|---|---|
26 | 26 |
sign = 0; |
27 | 27 |
|
28 | 28 |
//Test code |
29 |
state = SHIGHWAY;
|
|
29 |
state = SROAD;
|
|
30 | 30 |
|
31 | 31 |
sendBuffer[1] = id; |
32 |
/* |
|
32 |
|
|
33 | 33 |
doDrive(255); |
34 | 34 |
turn(DOUBLE, ILEFT); |
35 | 35 |
|
36 |
while(1) |
|
36 |
/* while(1)
|
|
37 | 37 |
doDrive(255); |
38 |
*/ |
|
38 | 39 |
|
39 |
*/ |
|
40 | 40 |
while (1) { |
41 | 41 |
/*DTM Finite State Machine*/ |
42 | 42 |
switch(state){ |
... | ... | |
75 | 75 |
wl_basic_send_global_packet(42, sendBuffer, PACKET_LENGTH); |
76 | 76 |
orb1_set_color(ORANGE); |
77 | 77 |
while(1){ |
78 |
stop(); |
|
78 | 79 |
sign = doDrive(255); |
79 | 80 |
if((sign >= 0) || button1_click()){ |
80 |
if(0){ |
|
81 |
start(); |
|
82 |
if(1){ |
|
81 | 83 |
state = SHIGHWAY; |
82 | 84 |
break; |
83 | 85 |
}else{ |
... | ... | |
88 | 90 |
} |
89 | 91 |
break; |
90 | 92 |
case SHIGHWAY:/*On highway*/ |
91 |
// usb_puts("HIGHWAY\r\n"); |
|
92 |
if(button1_click()) highwayStart(); |
|
93 |
highwayFSM(); |
|
94 |
// sign = lineFollow(); |
|
95 |
//highway behaviors |
|
96 |
//merging |
|
97 |
//passing |
|
98 |
//read barcode |
|
93 |
orb1_set_color(CYAN); |
|
94 |
while(!button1_click()){ |
|
95 |
highwayFSM(); |
|
96 |
} |
|
97 |
state = SINTERSECTION; |
|
99 | 98 |
break; |
100 | 99 |
default: |
101 | 100 |
usb_puts("I got stuck in an unknown state! My state is "); |
... | ... | |
251 | 250 |
*/ |
252 | 251 |
} |
253 | 252 |
} |
254 |
} |
|
253 |
} |
Also available in: Unified diff