Revision 1876

View differences:

trunk/code/projects/traffic_navigation/highways.h
1
#ifndef HIGHWAYS_H
2
#define HIGHWAYS_H
3

  
4
void driveHighway(void);
5

  
6

  
7
#define COUNT_MAX 5
8
#define PASS_DISTANCE 100
9
#endif
trunk/code/projects/traffic_navigation/validTurns.h
1 1
#ifndef _VALID_TURNS_
2 2
#define _VALID_TURNS_
3 3

  
4
#include "lineFollow.h"
5
#include "lineDrive.h"
4
#include "../linefollowing/lineFollow.h"
5
#include "../linefollowing/lineDrive.h"
6 6

  
7 7
//To differenciate between T and Cross Intersections
8 8
#define DOUBLE_C	4
trunk/code/projects/traffic_navigation/highways.c
1
#include "highways.h"
2
#include "lineDrive.h"
3
#include <dragonfly_lib.h>
4
extern int state[5];
5
static int count =0;
6
static long average = 0;
7

  
8
void driveHighway( void ){
9
	doDrive(200);
10
	int range = range_read_distance(IR2);
11
	usb_puti(range);
12
	usb_puts(" : ");
13
	usb_puti(average);
14
        usb_puts("\r\n");
15
	if(range == -1){
16
		return;
17
	}
18
        
19
	count ++;
20
	average += range;
21
	if(count >= COUNT_MAX){
22
		if(state[0] != MERGELEFT){
23
			orb1_set_color(ORANGE);
24
			if(average / COUNT_MAX < PASS_DISTANCE){
25
				merge(ILEFT);
26
				usb_puts("MERGE \r\n");	
27
			}
28
		}
29
		count =0;
30
		average = 0;
31
	}
32
	//else orb1_set_color(GREEN);
33
}
34

  
trunk/code/projects/traffic_navigation/main.c
12 12
	int state, sign, dataLength, pingWaitTime;
13 13
	char sendBuffer[PACKET_LENGTH], prevBot, nextBot, id, nextDir, nextPath, intersectionNum;
14 14
	unsigned char *packet;
15

  
15
	
16 16
	/* Initialize the dragonfly boards, the xbee, encoders, lineFollowing */
17 17
	dragonfly_init(ALL_ON);
18 18
	xbee_init();
19 19
	encoders_init();
20
//	lineDrive_init();
20
	lineDrive_init();
21 21
	rtc_init(SIXTEENTH_SECOND, NULL);	
22 22
	wl_basic_init_default();
23 23
	wl_set_channel(13);
......
26 26
	sign = 0;
27 27
	
28 28
	//Test code
29
	state = SROAD;
29
	state = SHIGHWAY;
30 30

  
31 31
	sendBuffer[1] = id;
32 32

  
......
208 208
			}
209 209
			break;
210 210
		case SHIGHWAY:/*On highway*/
211
//			sign = lineFollow();
212
			//highway behaviors
213
				//merging
214
				//passing
215
			//read barcode
211
			driveHighway();
216 212
			break;
217 213
		default:
218 214
			usb_puts("I got stuck in an unknown state! My state is ");

Also available in: Unified diff