Revision 1884
Separated the intersection constants from the turning constants, updated fuctions accordingly.
trunk/code/projects/traffic_navigation/validTurns.h | ||
---|---|---|
4 | 4 |
|
5 | 5 |
#include "lineDrive.h" |
6 | 6 |
|
7 |
//To differenciate between T and Cross Intersections |
|
8 |
#define DOUBLE_C 4 |
|
9 |
#define DOUBLE_T 5 |
|
7 |
/**************************** |
|
8 |
* Intersection Information: 5-bit Integer |
|
9 |
* 3 bits of intersection type |
|
10 |
* 2 bits of entry information |
|
11 |
* |
|
12 |
****************************/ |
|
10 | 13 |
|
14 |
/******************************** |
|
15 |
* Intersection TYPES: |
|
16 |
* |
|
17 |
********************************/ |
|
18 |
|
|
19 |
|
|
20 |
#define INTERSECTION_SINGLE (1 << 2) |
|
21 |
#define INTERSECTION_ON_RAMP (2 << 2) |
|
22 |
#define INTERSECTION_OFF_RAMP (3 << 2) |
|
23 |
#define INTERSECTION_DOUBLE_C (4 << 2) |
|
24 |
#define INTERSECTION_DOUBLE_T (5 << 2) |
|
25 |
|
|
26 |
|
|
27 |
/******************************** |
|
28 |
* Intersection ENTRYPOINTS: |
|
29 |
* |
|
30 |
********************************/ |
|
31 |
|
|
11 | 32 |
//DOUBLE intersection (Cross Intersection) positions |
12 | 33 |
//use T-Junction positions |
13 | 34 |
|
trunk/code/projects/traffic_navigation/validTurns-test.c | ||
---|---|---|
7 | 7 |
int main(){ |
8 | 8 |
/*barcode should be written as crosstype, crosspos. 5 bit integers*/ |
9 | 9 |
|
10 |
/*barcode should be three bits of intersection type and 2 of entrypoint*/ |
|
11 |
|
|
10 | 12 |
dragonfly_init(ALL_ON); |
11 | 13 |
orb1_set_color(YELLOW); |
12 | 14 |
|
trunk/code/projects/traffic_navigation/validTurns.c | ||
---|---|---|
45 | 45 |
return crosstype; |
46 | 46 |
} |
47 | 47 |
int getCrossPos(int barcode, int max){ |
48 |
//@TODO: implement some max checking |
|
48 | 49 |
return (barcode)&3; |
49 | 50 |
} |
50 | 51 |
|
... | ... | |
55 | 56 |
cross_type = getCrossType(barcode); |
56 | 57 |
switch (cross_type) |
57 | 58 |
{ |
58 |
case DOUBLE_C: |
|
59 |
case INTERSECTION_DOUBLE_C:
|
|
59 | 60 |
{ |
60 | 61 |
cross_pos = getCrossPos(barcode, 4); |
61 | 62 |
if (0<=cross_pos && cross_pos<=3) |
... | ... | |
63 | 64 |
break; |
64 | 65 |
} |
65 | 66 |
case DOUBLE: //Implements DOUBLE as DOUBLE_T |
66 |
case DOUBLE_T: |
|
67 |
//@TODO: we really shouldn't use DOUBLE, it's part of another system. but it equals 0, so error checking. |
|
68 |
case INTERSECTION_DOUBLE_T: |
|
67 | 69 |
{ |
68 | 70 |
cross_pos = getCrossPos(barcode, 3); |
69 | 71 |
switch (cross_pos) |
... | ... | |
91 | 93 |
} |
92 | 94 |
break; |
93 | 95 |
} |
94 |
case SINGLE: |
|
96 |
case INTERSECTION_SINGLE:
|
|
95 | 97 |
{ |
96 | 98 |
cross_pos = getCrossPos(barcode, 2); |
97 | 99 |
switch (cross_pos) |
... | ... | |
113 | 115 |
} |
114 | 116 |
break; |
115 | 117 |
} |
116 |
case ON_RAMP: |
|
118 |
case INTERSECTION_ON_RAMP:
|
|
117 | 119 |
{ |
118 | 120 |
cross_pos = getCrossPos(barcode, 3); |
119 | 121 |
switch (cross_pos) |
... | ... | |
135 | 137 |
} |
136 | 138 |
break; |
137 | 139 |
} |
138 |
case OFF_RAMP: |
|
140 |
case INTERSECTION_OFF_RAMP:
|
|
139 | 141 |
{ |
140 | 142 |
cross_pos = getCrossPos(barcode, 3); |
141 | 143 |
switch (cross_pos) |
Also available in: Unified diff