Revision 1988
This is a working version of the code for the demo. It works on Bot 7, and partially on Bot 14. Due to the number of changes here, I'll list them by file:
traffic_navigation.h
I added a #define for sendGraph, so its main won't be compiled unless defined. Uncomment the #define line at the top of this file to turn its main on. Make sure you also comment out the #define for main-new. Also, has the new #define for the node wireless packet type.
readSerial.sh
I changed the output to print to stdout, instead of a file.
sendGraph.c
sendGraph.h
I modified the struct that stores and sends node data so it has a wireless packet type (80), and is 1 byte larger to hold it.
validTurns.c
One of the intersections on the map was placed incorrectly, and the robot drives off the line if it gets there. I added 2 if statements to control how the robot turns if it is at that intersection. The intersection has barcode numbers 13 and 16.
Makefile
I changed the target to main-new because that was what I was testing. If you're testing something else, make sure you change this line.
main-new.c
I changed the speed at which the robot drives at. I lowered it from 200 to 180, although this value depends on which bot it was used on. I also changed all of Alex's #ifdef debugging code into #define that takes up less space and makes the code look cleaner.
sendGraph.c | ||
---|---|---|
2 | 2 |
#include <wl_basic.h> |
3 | 3 |
#include "sendGraph.h" |
4 | 4 |
|
5 |
#ifdef SENDGRAPH |
|
6 |
|
|
5 | 7 |
int main(void){ |
6 | 8 |
|
7 | 9 |
dragonfly_init(ALL_ON); |
... | ... | |
40 | 42 |
intersections[0] = a; |
41 | 43 |
intersections[1] = b; |
42 | 44 |
|
45 |
while(1){ |
|
43 | 46 |
sendIntersectionGraph(); |
47 |
orb1_set_color(BLUE); |
|
48 |
delay_ms(500); |
|
49 |
sendIntersectionGraph(); |
|
50 |
orb1_set_color(YELLOW); |
|
51 |
delay_ms(500); |
|
52 |
} |
|
53 |
|
|
54 |
return 0; |
|
44 | 55 |
} |
45 | 56 |
|
46 | 57 |
|
... | ... | |
57 | 68 |
void sendIntersectionGraph() { |
58 | 69 |
int i; |
59 | 70 |
node_union graph; |
71 |
graph.n.packetType = WGRAPHDATA; |
|
60 | 72 |
|
61 | 73 |
for(i=0; i< NUM_FEATURES; i++){ |
62 | 74 |
graph.n = intersections[i]; |
63 |
wl_basic_send_global_packet(42, graph.array, 12);
|
|
64 |
wl_basic_send_global_packet(42, "\n", 1);
|
|
75 |
wl_basic_send_global_packet(42, graph.array, 13);
|
|
76 |
// wl_basic_send_global_packet(42, "\r\n", 3);
|
|
65 | 77 |
} |
66 | 78 |
} |
79 |
|
|
80 |
#endif |
Also available in: Unified diff