Revision 1610
Updated counting robots to work for circle formation. Movement is problematic.
circle.c | ||
---|---|---|
21 | 21 |
|
22 | 22 |
/* |
23 | 23 |
TODO: |
24 |
Check BOM more often and before final stop |
|
25 |
Make BOM check more comprehensively |
|
24 |
Used: Bots 1, 7 |
|
25 |
16 Performed Badly |
|
26 |
12 worked ok as beacon, not well as edge |
|
27 |
|
|
28 |
Fix orient code so the bot does not toggle back and forth when it tries to turn |
|
29 |
|
|
26 | 30 |
Use the center bot to check distances |
27 |
Count them ("spam" method)
|
|
31 |
Done--> Count them ("spam" method)
|
|
28 | 32 |
Use beacon to find relative positions |
29 | 33 |
Beacon tells them how to move to be at the right distance |
30 | 34 |
*done*Wireless communication, initialization |
... | ... | |
148 | 152 |
for(int i = 0; i<num; i++) |
149 | 153 |
{ |
150 | 154 |
orb_set_color(ORB_OFF); |
151 |
delay_ms(500);
|
|
155 |
delay_ms(200);
|
|
152 | 156 |
orb_set_color(RED); |
153 |
delay_ms(500);
|
|
157 |
delay_ms(200);
|
|
154 | 158 |
} |
155 | 159 |
orb_set_color(ORB_OFF); |
156 | 160 |
} |
... | ... | |
178 | 182 |
|
179 | 183 |
int state = EDGE; |
180 | 184 |
int beacon_State=0; |
181 |
int NUM_ROBOTS=2;
|
|
182 |
int robotsRecieved=0;
|
|
185 |
int waitingCounter=0;
|
|
186 |
int robotsReceived=0;
|
|
183 | 187 |
if(wheel()<100) |
184 | 188 |
{ |
185 | 189 |
state=EDGE; |
... | ... | |
190 | 194 |
} |
191 | 195 |
|
192 | 196 |
int distance=1000; // how far away to stop. |
193 |
int onefoot=300, speed=200; // one foot is 490 for bot 1; one foot is 200 for bot6
|
|
197 |
int onefoot=300, speed=250; // one foot is 490 for bot 1; one foot is 200 for bot6
|
|
194 | 198 |
|
195 | 199 |
while(1) |
196 | 200 |
{ |
... | ... | |
268 | 272 |
beacon_State=2; |
269 | 273 |
break; |
270 | 274 |
case 2: // find out how many robots there are |
275 |
waitingCounter++; |
|
271 | 276 |
orb_set_color(ORANGE); |
272 | 277 |
packet_data=wl_basic_do_default(&data_length); |
273 | 278 |
if(packet_data!=0 && data_length>=2 && packet_data[0]==CIRCLE_ACTION_ACK) |
274 | 279 |
{ |
275 | 280 |
orb_set_color(WHITE); |
276 | 281 |
if(used[packet_data[1]]==0){ //only add to robots seen if you haven't gotten an ACK from this robot |
277 |
robotsRecieved++;
|
|
282 |
robotsReceived++;
|
|
278 | 283 |
used[packet_data[1]]=1; |
279 | 284 |
} |
280 | 285 |
} |
281 |
if(robotsRecieved==NUM_ROBOTS)
|
|
286 |
if(waitingCounter >= 1500){
|
|
282 | 287 |
beacon_State=3; |
288 |
//blink(robotsReceived); |
|
289 |
} |
|
283 | 290 |
break; |
284 | 291 |
case 3: |
292 |
orb_set_color(PURPLE); |
|
285 | 293 |
send_buffer[0]=CIRCLE_ACTION_DONE; |
286 | 294 |
wl_basic_send_global_packet(42,send_buffer,2); |
287 | 295 |
break; |
Also available in: Unified diff