Revision 1949

View differences:

trunk/code/projects/traffic_navigation/Makefile
11 11
USE_WIRELESS = 1
12 12

  
13 13
# com1 = serial port. Use lpt1 to connect to parallel port.
14
AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
14
AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/tty.usbserial-*'; fi)
15 15

  
16 16
else
17 17
COLONYROOT := ../$(COLONYROOT)
trunk/code/projects/traffic_navigation/main.c
7 7

  
8 8
#include "traffic_navigation.h"
9 9

  
10
	static int state, sign, dataLength, pingWaitTime, turnDir;
11
	static char sendBuffer[PACKET_LENGTH], prevBot, nextBot, id, nextDir, nextPath, intersectionNum;
12
	static unsigned char *packet;
10
>>>>>>> .r1869
11
int main (void) {
13 12

  
14 13
	void enterIntersectionQueue(int sign);
15 14
	void waitInIntersectionQueue();
......
35 34

  
36 35
	sendBuffer[1] = id;
37 36

  
38
	/*
39
	doDrive(200);
40
	turn(DOUBLE, ILEFT);
41
	*/
42
/*	while(1)
43
		doDrive(255);
44
	*/
45
	
37
	state = SHIGHWAY;
38

  
39
	int startLeft = 0, startRight = 0;
40

  
41

  
46 42
	while (1) {
47 43
		/*DTM Finite State Machine*/
48 44
		switch(state){
49 45
		case SROAD:/*Following a normal road*/
46
<<<<<<< .mine
47
			sign = lineFollow(200);
48
=======
50 49
//			sign = lineFollow();
50
>>>>>>> .r1869
51 51
			//other road behaviors
52 52
				//tailgating?
53 53
			//read barcode
......
105 105
			}
106 106
			state = SINTERSECTION;
107 107
			break;
108
		case PASSLEFT:/*Passing left*/
109

  
110
			motor_l_set(FORWARD, 180);
111
			motor_r_set(FORWARD, 250);
112

  
113
			orb_set_color(YELLOW);
114

  
115
			usb_puti(startRight);
116
			usb_puts("\n");
117
			usb_puti(startLeft);
118
			usb_puts("\n");
119
			usb_puts("\n");
120
			usb_puti((encoder_get_x(RIGHT) - startRight) - (encoder_get_x(LEFT) - startLeft));
121
			usb_puts("\n\n");
122

  
123
			//if((encoder_get_x(RIGHT) - startRight) - (encoder_get_x(LEFT) - startLeft) > 200)
124
			if(!onLine())
125
			{
126
				state = FINDLINE;
127
				delay_ms(HALF_SECOND);
128
			}
129
			break;
130
		case PASSRIGHT:/*Passing right*/
131
			break;
132
		case FINDLINE:/*Drive straight until a line is falled*/
133
			motor_l_set(FORWARD, 240);
134
			motor_r_set(FORWARD, 240);
135

  
136
			orb_set_color(RED);
137

  
138
			if(onLine())
139
				orb_set_color(ORB_OFF);
140
				state = SHIGHWAY;
141
			break;
108 142
		default:
109 143
			usb_puts("I got stuck in an unknown state! My state is ");
110 144
			usb_puti(state);

Also available in: Unified diff