Project

General

Profile

Revision 1908

reorganized stuff in intersectData. made new function getTurningIntersect
that can be used to input directly into dan's code. made new functions to get
information about road nodes stored int he intersection database. eventually
should convert it to the node database.

View differences:

trunk/code/projects/traffic_navigation/intersectData.h
10 10
 * Also contains a "feature id": 4 bits in positions 13,14,15,16
11 11
 * 
12 12
 ****************************/
13

  
13 14
 
14 15
 /********************************
16
 *  Feature TYPES:
17
 *
18
 ********************************/
19
#define INTERSECTION_NODE	(0 << 12)
20
#define ROAD_NODE		(1 << 12)
21
 
22
 /********************************
15 23
 *  Intersection TYPES:
16 24
 *
17 25
 ********************************/
......
22 30
#define INTERSECTION_OFF_RAMP 	(2 << 2)
23 31
#define INTERSECTION_DOUBLE_C	(3 << 2)
24 32
#define INTERSECTION_DOUBLE_T	(4 << 2)
25
#define INTERSECTION_ROAD	(5 << 2) /*placeholder for all roads atm, until we come up with a better solution */
33
#define ROAD			(5 << 2) /*placeholder for all roads atm, until we come up with a better solution */
26 34

  
27 35
 /********************************
36
 *  Intersection Types in lineDrive.h:
37
 *
38
 ********************************/
39
#define DOUBLE		0
40
#define SINGLE		1
41
#define ON_RAMP		2
42
#define OFF_RAMP	3
43

  
44
 /********************************
28 45
 *  Turn TYPES:
29 46
 *
30 47
 ********************************/
......
34 51
#define IRIGHT		2
35 52
#define IUTURN		3
36 53

  
54
 /********************************
55
 *  Road TYPES:
56
 *
57
 ********************************/
58
#define ROAD_DOUBLE	0
59
#define ROAD_SINGLE	1
60
#define HIGHWAY		2
37 61

  
38 62
/********************************
39 63
 *  Intersection ENTRYPOINTS:
......
86 110
int IntersectData[NUM_FEATURES];
87 111

  
88 112
void initializeData();
89
void insertIntersection(int key, int featureid, int intersect_type, int intersect_position);
113
void insertNode(int key, int featureid, int node_type, int node_info);
90 114

  
91 115
// Functions to get data from the Database:
92
int getIntersectType(int entry);
93
int getIntersectPos(int entry);
94
int getFeatureId(int entry);
116
int getIntersectType(int key);
117
int getTurningIntersect(int key);
118
int getIntersectPos(int key);
119
int getFeatureId(int key);
95 120
int getTurnIntType(int intersectiontype);
121
int getRoadType(int key);
122
int getRoadInfo(int key);
96 123

  
97 124
#endif
trunk/code/projects/traffic_navigation/main.c
226 226
	//Code to choose path through intersection goes in this while loop
227 227
	//But here's the code to handle wireless while in the intersection...
228 228
	start();
229
	turn(getTurnIntType(getIntersectType(0)), turnDir);
229
	turn(getTurningIntersect(0), turnDir);
230 230
	while(doDrive(200) != FINISHED){
231 231
		dataLength = 0;
232 232
		packet = NULL;
trunk/code/projects/traffic_navigation/intersectData.c
11 11
	//insert all intersections that are in the map.
12 12
	//THIS DATA FOR THE DEMO MAP
13 13
	
14
	insertIntersection(0, 0, INTERSECTION_DOUBLE_C, TMIDDLE);
15
	insertIntersection(1, 1, INTERSECTION_ROAD, TMIDDLE);
16
	insertIntersection(2, 2, INTERSECTION_ROAD, TMIDDLE);
17
	insertIntersection(3, 3, INTERSECTION_ROAD, TMIDDLE);
18
	insertIntersection(4, 4, INTERSECTION_ROAD, TMIDDLE);
14
	insertNode(0, INTERSECTION_NODE, INTERSECTION_DOUBLE_C, TMIDDLE);
15
	insertNode(1, ROAD_NODE, ROAD, ROAD_DOUBLE);
16
	insertNode(2, ROAD_NODE, ROAD, ROAD_DOUBLE);
17
	insertNode(3, ROAD_NODE, ROAD, ROAD_DOUBLE);
18
	insertNode(4, ROAD_NODE, ROAD, ROAD_DOUBLE);
19 19
	return;
20 20
}
21 21

  
......
28 28

  
29 29

  
30 30
// Does nothing if your indmaex is out of bounds.
31
void insertIntersection(int key, int featureid, int intersect_type, int intersect_position){
31
void insertNode(int key, int featureid, int node_type, int node_info){
32 32
//	if (key < sizeof(IntersectData)/sizeof(int))
33 33
	if(key < NUM_FEATURES)
34
	  IntersectData[key] = (featureid << 12) + intersect_type + intersect_position;
34
	  IntersectData[key] = featureid + node_type + node_info;
35 35
	return;
36 36
}
37 37

  
38 38
// Functions to get data from the Database:
39 39
//@TODO:Add some checks to make sure the key is less than NUM_FEATURES
40 40
//	also: figure out what to do when this happens.
41
//	Add checks to see if we call getIntersect...() on intersections
42
//	and getRoad...() on roads.
41 43

  
42 44
int getIntersectType(int key){
43 45
	return (IntersectData[key])&28; // 28 == 11100;
44 46
}
45 47

  
46
int getIntersectPos(int key){
47
	return (IntersectData[key])&3;
48
}
49
int getFeatureId(int key)
50
{
51
	return (IntersectData[key] >> 12)&0xF;
52
}
53
#include "lineDrive.h"
54
int getTurnIntType(int intersectiontype)
55
{
56
	switch(intersectiontype)
48
int getTurningIntersect(int key){
49
	switch(getIntersectType(key))
57 50
	{
58 51
		case INTERSECTION_SINGLE:
59 52
			return SINGLE;
......
65 58
		case INTERSECTION_OFF_RAMP:
66 59
			return OFF_RAMP;
67 60
	}
61
}
68 62

  
63
int getIntersectPos(int key){
64
	return (IntersectData[key])&3;
69 65
}
66
int getFeatureId(int key)
67
{
68
	return (IntersectData[key])&61440;  // 61220 == (15<<12);
69
}
70
int getRoadType(int key){
71
	return (IntersectData[key])&28;  // 28 == 11100;
72
}
73
int getRoadInfo(int key){
74
	return (IntersectData[key])&3;
75
}
76

  

Also available in: Unified diff