Project

General

Profile

Revision 1999

Refactored main_new timings so that bots travel through intersections more
fluidly

View differences:

main-new.c
1
#define MAIN_NEW
1 2
/*
2 3
 * main.c for Traffic Navigation
3 4
 * Runs the highest level behavior for the Dynamic Traffic Navigation (DTN) SURG
......
5 6
 * Author: Colony Project, CMU Robotics Club
6 7
 */
7 8

  
8
#define MAIN_NEW
9

  
10 9
#include "traffic_navigation.h"
11 10
#include "../linefollowing/lineDrive.h"
12 11
#define ORB_INTERSECTION
......
138 137
			rtc_reset(); //reset rtc for timeout wait for reply
139 138
			done = false;
140 139
			char retried = 0;
141
			while(rtc_get() < 16 && !done){//waits for a reply, otherwise assumes it is first in queue
140
			while(rtc_get() < 8 && !done){//waits for a reply, otherwise assumes it is first in queue
142 141
				int ret = wirelessPacketHandle(SINTERSECTION_ENTER);
143
				if(rtc_get() > 12 && !retried){//by now all resolvs should be done from bots that arrived earlier...
142
				if(rtc_get() > 6 && !retried){//by now all resolvs should be done from bots that arrived earlier...
144 143
					ORB2_DBG_CLR(PURPLE);
145 144
					enterIntersection();
146 145
					retried = 1;
......
174 173
			rtc_reset();
175 174
			done = false;
176 175
			retried = 0;
177
			while(rtc_get() < 9 && !done){
176
			while(rtc_get() < 4 && !done){
178 177
				int ret = wirelessPacketHandle(SINTERSECTION_ENTER_RESOLV);
179 178
				switch (ret) {
180 179
					case KRESOLVINGENTER:
......
206 205
				//resolving but never have seen a bot with lower
207 206
				//priority than us. after the 6/16ths sec
208 207
				//timeout, assume we are first.
209
				} else if(!done && resolvPrevBotID == (char) -2 && rtc_get() > 6){
208
				} else if(!done && resolvPrevBotID == (char) -2 && rtc_get() > 2){
210 209
					//send a intersection reply to myself to
211 210
					//trigger other bots to enter queue.
212 211
					sendBuffer[0] = WINTERSECTIONREPLY;
......
253 252
			//hack to make sure bot that just left intersection is
254 253
			//really out of the intersection.
255 254
			rtc_reset();
256
			while(rtc_get() < 4 && done){//wait one second
255
			while(rtc_get() < 2 && done){//wait one second
257 256
				wirelessPacketHandle(state);
258 257
			}
259 258

  

Also available in: Unified diff