Revision 1894
Fixed directions and array indexes to match.
collision_avoid.c | ||
---|---|---|
3 | 3 |
* - Actually Test this stuff. Especially the intersection rotating thing. and the parts marked sketchy. |
4 | 4 |
* - Integrate into main.c |
5 | 5 |
* - In the intersection queue in main.c, allow bots to skip each other (since this code allows it). |
6 |
*/ |
|
6 |
* |
|
7 |
* |
|
8 |
* IMMEDIATE TODO: FIX dir1 and dir3 relation to array indexes |
|
9 |
* make first_hop work. <-- THIS SHOULD BE FIXED |
|
10 |
|
|
11 |
*/ |
|
7 | 12 |
#include "collision_avoid.h" |
8 | 13 |
#include "traffic_navigation.h" |
9 | 14 |
static unsigned int my_path = 0; |
15 |
static unsigned int first_hop = 0; |
|
10 | 16 |
static char intersection = 0; |
11 | 17 |
|
12 | 18 |
/* Dir0 |
... | ... | |
16 | 22 |
* [6 ][2 ] |
17 | 23 |
* Dir2 |
18 | 24 |
*/ |
25 |
/* Dir0 |
|
26 |
* [0 ][4 ] |
|
27 |
*Dir1 [5][8 ][9 ][3] Dir3 |
|
28 |
* [1][11][10][7] |
|
29 |
* [6 ][2 ] |
|
30 |
* Dir2 |
|
31 |
*/ |
|
19 | 32 |
void ca_EnterIntersection(char intersectionNum, char fromDir, char nextDir){ |
20 | 33 |
/* Generic turn model condenses all turns into either: |
21 | 34 |
* - a right turn from dir0 to dir1 |
... | ... | |
74 | 87 |
new_path | temp; |
75 | 88 |
} |
76 | 89 |
my_path = new_path; |
90 |
firsthop = |
|
77 | 91 |
} |
78 | 92 |
void ca_ExitIntersection(){ |
79 | 93 |
mypath = 0; |
... | ... | |
106 | 120 |
usb_puts("CA ERROR: You didn't call ca_Process with a WCOLLISIONAVOID type packet (CA_E2)\n"); |
107 | 121 |
if(recieve[1] < 0) |
108 | 122 |
usb_puts("CA ERROR: Recieved Packet indicates sending bot has a negative ID. (CA_E3)\n"); |
109 |
if(recieve[2] < 0)
|
|
110 |
usb_puts("CA ERROR: Recieved Packet indicates intersectionhas a negative ID. (CA_E4)\n");
|
|
123 |
if(recieve[2] != intersection)
|
|
124 |
usb_puts("CA ERROR: Recieved Packet's intersection doesn't match the intersection CA is operating on in this Bot.. (CA_E4)\n");
|
|
111 | 125 |
#endif |
112 | 126 |
if(*(recieve+3) & my_path != 0){ /* Sketchy Code */ |
113 | 127 |
#ifdef DEBUG_CA |
Also available in: Unified diff