Revision 1887
forgot to add intersectData.c and .h
trunk/code/projects/traffic_navigation/intersectData.h | ||
---|---|---|
1 |
#ifndef _INTERSECTION_DATABASE_ |
|
2 |
#define _INTERSECTION_DATABASE_ |
|
3 |
|
|
4 |
|
|
5 |
/**************************** |
|
6 |
* Intersection Information: 5-bit Integer |
|
7 |
* 3 bits of intersection type |
|
8 |
* 2 bits of entry information |
|
9 |
* |
|
10 |
****************************/ |
|
11 |
|
|
12 |
/******************************** |
|
13 |
* Intersection TYPES: |
|
14 |
* |
|
15 |
********************************/ |
|
16 |
|
|
17 |
|
|
18 |
#define INTERSECTION_SINGLE (0 << 2) |
|
19 |
#define INTERSECTION_ON_RAMP (1 << 2) |
|
20 |
#define INTERSECTION_OFF_RAMP (2 << 2) |
|
21 |
#define INTERSECTION_DOUBLE_C (3 << 2) |
|
22 |
#define INTERSECTION_DOUBLE_T (4 << 2) |
|
23 |
|
|
24 |
/******************************** |
|
25 |
* Turn TYPES: |
|
26 |
* |
|
27 |
********************************/ |
|
28 |
|
|
29 |
#define ISTRAIGHT 0 |
|
30 |
#define ILEFT 1 |
|
31 |
#define IRIGHT 2 |
|
32 |
#define IUTURN 3 |
|
33 |
|
|
34 |
|
|
35 |
/******************************** |
|
36 |
* Intersection ENTRYPOINTS: |
|
37 |
* |
|
38 |
********************************/ |
|
39 |
|
|
40 |
//DOUBLE intersection (Cross Intersection) positions |
|
41 |
//use T-Junction positions |
|
42 |
|
|
43 |
//DOUBLE intersection (T-Junction) positions |
|
44 |
/* |
|
45 |
TLEFT=======TRIGHT |
|
46 |
|| |
|
47 |
|| |
|
48 |
|| |
|
49 |
TMIDDLE |
|
50 |
*/ |
|
51 |
#define TLEFT 0 |
|
52 |
#define TRIGHT 1 |
|
53 |
#define TMIDDLE 2 |
|
54 |
|
|
55 |
//SINGLE intersection positions |
|
56 |
/* |
|
57 |
/\ |
|
58 |
/||\ |
|
59 |
|| |
|
60 |
SACROSS==========> |
|
61 |
|| |
|
62 |
|| |
|
63 |
|| |
|
64 |
SUP |
|
65 |
*/ |
|
66 |
#define SACROSS 0 |
|
67 |
#define SUP 1 |
|
68 |
|
|
69 |
|
|
70 |
//ON_RAMP and OFF_RAMP intersection positions |
|
71 |
/* |
|
72 |
R_LEFT================R_RIGHT |
|
73 |
|| |
|
74 |
|| |
|
75 |
|| |
|
76 |
R_RAMP |
|
77 |
*/ |
|
78 |
#define R_LEFT 0 |
|
79 |
#define R_RIGHT 1 |
|
80 |
#define R_RAMP 2 |
|
81 |
|
|
82 |
// Global variable for the intersection database. You can change the size here. Size == number of intersections. |
|
83 |
int IntersectData[1]; |
|
84 |
|
|
85 |
void insertIntersection(int barcode, int intersect_type, int intersect_position); |
|
86 |
|
|
87 |
// Functions to get data from the Database: |
|
88 |
int getIntersectType(int barcode); |
|
89 |
int getIntersectPos(int barcode); |
|
90 |
|
|
91 |
#endif |
trunk/code/projects/traffic_navigation/intersectData.c | ||
---|---|---|
1 |
#include "intersectData.h" |
|
2 |
|
|
3 |
/* |
|
4 |
* This function serves to make the code for the intersection database |
|
5 |
* as reuseable as possible. This part initializes the data and is the |
|
6 |
* only one that needs to be rewritten for each map. |
|
7 |
* |
|
8 |
*/ |
|
9 |
|
|
10 |
void initializeData(){ |
|
11 |
//insert all intersections that are in the map. |
|
12 |
insertIntersection(0, INTERSECTION_DOUBLE_C, TMIDDLE); |
|
13 |
return; |
|
14 |
} |
|
15 |
|
|
16 |
/* |
|
17 |
* This function serves to make the code for the intersection database |
|
18 |
* as reuseable as possible. This part creates the implementation of the |
|
19 |
* database that can be copied over for all projects. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
// Does nothing if your indmaex is out of bounds. |
|
25 |
void insertIntersection(int barcode, int intersect_type, int intersect_position){ |
|
26 |
if (barcode < sizeof(IntersectData)/sizeof(int)) |
|
27 |
IntersectData[barcode] = intersect_type + intersect_position; |
|
28 |
return; |
|
29 |
} |
|
30 |
|
|
31 |
// Functions to get data from the Database: |
|
32 |
|
|
33 |
int getIntersectType(int barcode){ |
|
34 |
return (IntersectData[barcode])&28; // 28 == 11100; |
|
35 |
} |
|
36 |
|
|
37 |
int getIntersectPos(int barcode){ |
|
38 |
return (IntersectData[barcode])&3; |
|
39 |
} |
Also available in: Unified diff