Project

General

Profile

Revision 1867

Added by Jeff Cooper over 13 years ago

fixed priya's bugs, left her questionable sytlistic choices

View differences:

trunk/code/projects/traffic_navigation/main.c
9 9
#include "../linefollowing/lineDrive.h"
10 10

  
11 11

  
12

  
12 13
/*States*/
13 14
#define SROAD 0
14 15
#define SINTERSECTION 10
trunk/code/projects/traffic_navigation/validTurns.c
42 42
	if( barcode == NOBARCODE ) return -1;
43 43
	cross_type = getCrossType(barcode);
44 44
	switch (cross_type)
45
	case DOUBLE_C
46 45
	{
47
		cross_pos = getCrossPos(barcode, 4);
48
		if (0<=cross_pos && cross_pos<=3)
49
		return randomNumGen(4);
50
	break;
51
	}
52
	case DOUBLE_T
53
	{
54
		cross_pos = getCrossPos(barcode, 3);
55
		switch (cross_pos)
56
		case TLEFT
46
		case DOUBLE_C:
57 47
		{
58
			int turn_type = getTurnType();
59
			if (turn_type == ILEFT) turn_type = ISTRAIGHT;
60
			return turn_type;	
48
			cross_pos = getCrossPos(barcode, 4);
49
			if (0<=cross_pos && cross_pos<=3)
50
			return randomNumGen(4);
61 51
		break;
62 52
		}
63
		case TRIGHT
53
		case DOUBLE_T:
64 54
		{
65
			int turn_type = getTurnType();
66
			if (turn_type == IRIGHT) turn_type = ISTRAIGHT;
67
			return turn_type;			
68
		break;
55
			cross_pos = getCrossPos(barcode, 3);
56
			switch (cross_pos)
57
			{
58
				case TLEFT:
59
				{
60
					int turn_type = getTurnType();
61
					if (turn_type == ILEFT) turn_type = ISTRAIGHT;
62
					return turn_type;	
63
				break;
64
				}
65
				case TRIGHT:
66
				{
67
					int turn_type = getTurnType();
68
					if (turn_type == IRIGHT) turn_type = ISTRAIGHT;
69
					return turn_type;			
70
				break;
71
				}
72
				case TMIDDLE:
73
				{
74
					int turn_type = getTurnType();
75
					if (turn_type == ISTRAIGHT) turn_type = IUTURN;
76
					return turn_type;
77
				break;
78
				}
79
				default:
80
					return -1;
81
			}
82
			break;
69 83
		}
70
		case TMIDDLE
84
		case SINGLE:
71 85
		{
72
			int turn_type = getTurnType();
73
			if (turn_type == ISTRAIGHT) turn_type = IUTURN;
74
			return turn_type;
86
			cross_pos = getCrossPos(barcode, 2);
87
			switch (cross_pos)
88
			{
89
				case SACROSS:
90
				{
91
					int turn_type = getTurnType();
92
					if (turn_type == IRIGHT || turn_type == IUTURN) turn_type = ISTRAIGHT;
93
					return turn_type;	
94
				break;
95
				}
96
				case SUP:
97
				{
98
					int turn_type = getTurnType();
99
					if (turn_type == ILEFT || turn_type == IUTURN) turn_type = ISTRAIGHT;
100
					return turn_type;			
101
				break;
102
				}
103
				default:
104
					return -1;
105
			}
75 106
		break;
76 107
		}
77
		default return -1;
78
	break;
79
	}
80
	case SINGLE
81
	{
82
		cross_pos = getCrossPos(barcode, 2);
83
		switch (cross_pos)
84
		case SACROSS
108
		case ON_RAMP:
85 109
		{
86
			int turn_type = getTurnType();
87
			if (turn_type == IRIGHT || turn_type == IUTURN) turn_type = ISTRAIGHT;
88
			return turn_type;	
110
			cross_pos = getCrossPos(barcode, 3);
111
			switch (cross_pos)
112
			{
113
				case R_LEFT:
114
				{
115
					int turn_type = getTurnType();
116
					if (turn_type == ILEFT || turn_type == IUTURN) turn_type = ISTRAIGHT;
117
					return turn_type;	
118
				break;
119
				}
120
				case R_RIGHT:
121
				{
122
					int turn_type = getTurnType();
123
					if (turn_type == IRIGHT || turn_type == IUTURN) turn_type = ISTRAIGHT;
124
					return turn_type;			
125
				break;
126
				}
127
				default:
128
					return -1;
129
			}
89 130
		break;
90 131
		}
91
		case SUP
132
		case OFF_RAMP:
92 133
		{
93
			int turn_type = getTurnType();
94
			if (turn_type == ILEFT || turn_type == IUTURN) turn_type = ISTRAIGHT;
95
			return turn_type;			
134
			cross_pos = getCrossPos(barcode, 3);
135
			switch (cross_pos)
136
			{
137
				case R_LEFT:
138
				{
139
					int turn_type = ISTRAIGHT;
140
					return turn_type;	
141
				break;
142
				}
143
				case R_RIGHT:
144
				{
145
					int turn_type = ISTRAIGHT;
146
					return turn_type;			
147
				break;
148
				}
149
				case R_RAMP:
150
				{
151
					int turn_type = getTurnType();
152
					if (turn_type == ISTRAIGHT || turn_type == IUTURN) turn_type = ILEFT;
153
					return turn_type;
154
				break;
155
				}
156
				default:
157
					return -1;
158
			}
96 159
		break;
97 160
		}
98
		default return -1;	
99
	break;
100
	}
101
	case ON_RAMP
102
	{
103
		cross_pos = getCrossPos(barcode, 3);
104
		switch (cross_pos)
105
		case R_LEFT
106
		{
107
			int turn_type = getTurnType();
108
			if (turn_type == ILEFT || turn_type == IUTURN) turn_type = ISTRAIGHT;
109
			return turn_type;	
110
		break;
111
		}
112
		case R_RIGHT
113
		{
114
			int turn_type = getTurnType();
115
			if (turn_type == IRIGHT || turn_type == IUTURN) turn_type = ISTRAIGHT;
116
			return turn_type;			
117
		break;
118
		}
119
		default return -1;	
120
	break;
121
	}
122
	case OFF_RAMP
123
	{
124
		cross_pos = getCrossPos(barcode, 3);
125
		switch (cross_pos)
126
		case R_LEFT
127
		{
128
			int turn_type = ISTRAIGHT;
129
			return turn_type;	
130
		break;
131
		}
132
		case R_RIGHT
133
		{
134
			int turn_type = ISTRAIGHT;
135
			return turn_type;			
136
		break;
137
		}
138
		case R_RAMP
139
		{
140
			int turn_type = getTurnType();
141
			if (turn_type == ISTRAIGHT || turn_type == IUTURN) turn_type = ILEFT;
142
			return turn_type;
143
		break;
144
		}
145
		default return -1;	
146
	break;
147
	}
148
	default return -1;
161
	default:
162
		return -1;
149 163
}
164
}

Also available in: Unified diff