void biofuelblock() {
    turnCCW();
    while(digital(12) == 0) {
        movecenterfast(900);
    }
    movecenterbackwards(800);
    sleep(032342);
    ao();
    turnCW();
    set_servo_position(1,1900);
    while(analog(4) <= 190 && analog(6) <= 190) {
        movecenterslow(500);
    }
    ao();
}
예제 #2
0
//int target_cha_in_chb(int,int, int, int);
int main()
{
int threshold=512;     // set threshold for light conditions
	
	moveforwardslow();
	sleep(0.3);
	ao();
	turnCCW();
	int i;
	for(i = 0; i <=8; i++) {
		cameratrack();
	}
	turnCW();

   /* while(){ //while the luggage carts are in frame, do all this code) 
	while (analog10(1) >= threshold) {
		 moveforewardfast();
	 }
	 ao();
	 sleep(5);//wait until we can cross to other side (15 sec)
	 while (analog10(1) >= threshold) {
		 moveforewardfast();
	 }
	 break; //break the while loop when we are going to knock down towers
 }
 turnCCW();
//tower push
 6y
moveforward();
 sleep(2);
 turnCW();
 turnCW();
moveforward();
sleep(2);
 turnCCW();
 //track, grab, and move backwards
	//insert luggage cart tracker
	
	*/
	
}
int main()
{
//	wait_for_light(7);
	enable_servos();
	set_servo_position(1,2000);
	float threshold=190;     // set threshold for light conditions
	while(analog(4) <= 190 && analog(6) <= 190) {
		movecenterslow(500);
	}
	if(analog(4) >= threshold ||analog(6) >= threshold) {
		ao();
			sleep(.5);
			movecenterslow(400);
			sleep(.2);
		}
		while(analog(4) <= 190 && analog(6) <= 190) {
		movecenterslow(500);
	}
	
	ao();
	turnCCW();
	sleep(1);
	movecenterfast(900);
	sleep(3.2124512516);
	turnCW();
	while(analog(4) <= 190 && analog(6) <= 190) {
		movecenterfast(500);
	}
	ao();
	sleep(8);
			movecenterfast(800);
	sleep(1);
	
	while(analog(4) <= 190) {
		movecenterslow(500);
	}
	ao();
//at this point it has stopped at our side of the center divider
		set_servo_position(1, 1600); //lift up the arms enough so that the robot can still detect the line while clearing the center bump.
	while(analog(4) >= 190 || analog(6) >= 190) 
	{
		movecenterfast(900); //move forward as long as both of the sensors arent over white
	}
	set_servo_position(1,2000);
turnCCW();
	//insert tower tracking function here (possibly move servos to knock over towers
	turnCW();
	turnCW();
	movecenterfast(900);
	sleep(1);
	turnCCW();
	LuggageTrack(); //track and pick up luggage
	movecenterbackwards(600);
	sleep(3);
	ao();
	set_servo_position(1,200);
	movecenterbackwards(400);
	sleep(1);
	ao();
	turnCCW();
	movecenter(600);
	sleep(1.5);
	ao();
	turnCW();
	while(analog(4) <= 190 && analog(6) <= 190) {
		movecenterslow(350);
	}
	ao();
	movecenterslow(200);
	sleep(0.3);
	ao();
	
}	
task autonomous()
{
	if(sensorValue(redBlueSwitch) < SWITCH){
		red = true;
	}
	else{
		red = false;
	}
	if(red){
		motor[hook] = -127;
		wait10Msec(60);
		motor[hook] = 64;
		wait10Msec(200);
		motor[hook] = 0;
		turnCW(159, 127);
		wait10Msec(1);
		move(1.3,127);
		wait10Msec(1);
		turnCCW(161, 127);
		wait10Msec(1);
		move(1.1,127);
		wait10Msec(1);
		move(.7,-127);
		wait10Msec(1);
		turnCW(125,127);
		wait10Msec(1);
		move(1.1,127);
		wait10Msec(1);
		turnCCW(125,127);
		wait10Msec(1);
		move(1.4,127);
		wait10Msec(1);
		move(.7,-127);
		wait10Msec(1);
		turnCCW(45,127);
		wait10Msec(1);
		move(1.5,127);
		wait10Msec(1);
	}
	else{
		motor[hook] = -127;
		wait10Msec(60);
		motor[hook] = 64;
		wait10Msec(200);
		motor[hook] = 0;
		turnCCW(159, 127);
		wait10Msec(1);
		move(1.3,127);
		wait10Msec(1);
		turnCW(161, 127);
		wait10Msec(1);
		move(1.1,127);
		wait10Msec(1);
		move(.7,-127);
		wait10Msec(1);
		turnCCW(125,127);
		wait10Msec(1);
		move(1.1,127);
		wait10Msec(1);
		turnCW(125,127);
		wait10Msec(1);
		move(1.4,127);
		wait10Msec(1);
		move(.7,-127);
		wait10Msec(1);
		turnCW(45,127);
		wait10Msec(1);
		move(1.5,127);
		wait10Msec(1);
	}
}
int main()
{
	//	wait_for_light(7);
	enable_servos();

	set_servo_position(1,1500);
	float threshold=190;     // set threshold for light conditions
	while(analog(4) <= 190 && analog(6) <= 190) {
	movecenterslow(500);
	}
	if(analog(4) >= threshold ||analog(6) >= threshold) {
	ao();
	sleep(.5);
	movecenterfast(700);
	sleep(.1);
	}
	while(analog(4) <= 190 && analog(6) <= 190) {
	movecenterslow(500);
	}
	
	ao();
	turnCCW();
	sleep(1);
	movecenterfast(900);
	sleep(4);
	turnCW();
	while(analog(4) <= 190 && analog(6) <= 190) {
	movecenterfast(500);
	}
	ao();
	sleep(11);
	movecenterfast(900);
	sleep(1);
	while(analog(4) <= 190) {
	movecenterslow(1000);
	}
	ao();
	//at this point it has stopped at our side of the center divider
	//THE LINE DETECTOR PART OF CROSSING CENTER IS NO LONGER NECCESSARY, JUST SET DISTANCE IT
	set_servo_position(1, 300);
	sleep(0.5);	//lift up the arms enough so that the robot can still detect the line while clearing the center bump.
	mav(0,1000);
mav(1,1000); 	//move forward over the center (this needs to be set distance because the arms need to clear the bump and the light sensors are on the arms
	sleep(4.3);
	ao();
	
	//NOW ON OTHER SIDE, IN MIDDLE REGION
	//can run either biofuel blocking code or luggage cart code
	biofuelblock();
	while(digital(12) == 0)
	{
		luggagecartcafe();
		movecenterfast(500);
		sleep(0.4);
	}
		set_servo_position(1,1000);
	sleep(0.75);
	movecenterbackwards(800);
	sleep(3);
	/*set_servo_position(1,1600);
	sleep(0.5);
	turnCCW();
	//insert tower tracking function here (possibly move servos to knock over towers
	//if this was biofuel, andrews code goes here
	sleep(3);
	movecenterfast(800);
	sleep(1);
	ao();
	sleep(3);
	movecenterbackwards(800);
	sleep(1);
	turnCW();
	turnCW();
	sleep(1);
	turnCCW();
	sleep(5);
	ao();
	while(digital(12)==0) {
	movecenterfast(1000);
	}
		/*while(digital(12)==0) {
			LuggageTrack();
		movecenterfast(500);
		sleep(0.5);
		ao();
		}//track and pick up luggage
		set_servo_position(1,950);
	sleep(3);
	movecenterbackwards(500);
	sleep(3);
	ao();
	set_servo_position(1,5);
		sleep(0.7);
	movecenterbackwards(400);
	sleep(1.5);
		turnCCW();
		while(digital(12)==0){
		movecenterfast(600);
	}
	movecenterbackwards(400);
	sleep(0.5);	
	turnCW();
	set_servo_position(1,1900);
	while(analog(4) <= 190 && analog(6) <= 190) {
	movecenterslow(500);
	}
	ao();
	turnCW();
	while(analog(4) <= 190 && analog(6) <= 190) {
	movecenterslow(350);
	}
	ao();
	movecenterslow(200);
	sleep(0.3);
	ao();
	
	/*while (digital(12) == 0)
		{
	LuggageTrack2();
//			if(z=1){
				movecenterfast(600);
		//		sleep(0.5);
//}

}
ao();
set_servo_position(1,950);
movecenterbackwards(500);
	sleep(3);
	ao();
	set_servo_position(1,5);
		sleep(0.7);
	movecenterbackwards(400);
	sleep(1.5);
		turnCCW();
		while(digital(12)==0){
		movecenterfast(600);
	}
	movecenterbackwards(400);
	sleep(0.5);	
	turnCW();
	set_servo_position(1,1900);
	while(analog(4) <= 190 && analog(6) <= 190) {
	movecenterslow(500);
	}
	ao();
	*/
	//Luggagecartcafe();
	sleep(4);
	set_servo_position(1,200);
	while(digital(12) == 0) {
		movecenterfast(600);
	}
	Luggagecartcafe();
}