root / trunk / code / projects / traffic_navigation / sendGraph.c @ 1988
History | View | Annotate | Download (1.14 KB)
1 |
#include <dragonfly_lib.h> |
---|---|
2 |
#include <wl_basic.h> |
3 |
#include "sendGraph.h" |
4 |
|
5 |
#ifdef SENDGRAPH
|
6 |
|
7 |
int main(void){ |
8 |
|
9 |
dragonfly_init(ALL_ON); |
10 |
wl_basic_init_default(); |
11 |
wl_set_channel(12);
|
12 |
|
13 |
node a; |
14 |
node b; |
15 |
|
16 |
edge aTob; |
17 |
edge bToa; |
18 |
|
19 |
//Create the edges
|
20 |
aTob.to = 'b';
|
21 |
aTob.dist = 25;
|
22 |
|
23 |
bToa.to = 'a';
|
24 |
bToa.dist = 25;
|
25 |
|
26 |
|
27 |
a.outgoingEdges[0] = aTob;
|
28 |
b.outgoingEdges[0] = bToa;
|
29 |
|
30 |
|
31 |
a.type = 1;
|
32 |
a.intNum = 1;
|
33 |
a.numOut = 1;
|
34 |
a.outSeen = 1;
|
35 |
|
36 |
|
37 |
b.type = 1;
|
38 |
b.intNum = 2;
|
39 |
b.numOut = 1;
|
40 |
b.outSeen = 1;
|
41 |
|
42 |
intersections[0] = a;
|
43 |
intersections[1] = b;
|
44 |
|
45 |
while(1){ |
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; |
55 |
} |
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
/*
|
62 |
* Uses wireless to send the graph sructure
|
63 |
* to other robots
|
64 |
*
|
65 |
* @return
|
66 |
*
|
67 |
*/
|
68 |
void sendIntersectionGraph() {
|
69 |
int i;
|
70 |
node_union graph; |
71 |
graph.n.packetType = WGRAPHDATA; |
72 |
|
73 |
for(i=0; i< NUM_FEATURES; i++){ |
74 |
graph.n = intersections[i]; |
75 |
wl_basic_send_global_packet(42, graph.array, 13); |
76 |
// wl_basic_send_global_packet(42, "\r\n", 3);
|
77 |
} |
78 |
} |
79 |
|
80 |
#endif
|