コード例 #1
0
void calibrate(){
	printf("Bitte setze alle Sensoren auf den schwarzen Streifen \n");
	set_b_button_text("calibrate");
	while(!b_button()){
		printf("left "); 	printf("%i",analog10(LEFT_SENSOR));	printf("\n");
		printf("right ");	printf("%i",analog10(RIGHT_SENSOR));	printf("\n");
		msleep(100);
		display_clear();
	}
	right_blk = analog10(RIGHT_SENSOR);
	left_blk = analog10(LEFT_SENSOR);
	mid_blk =analog10(MIDDLE_SENSOR);
	set_b_button_text("start");
	msleep(500);
	printf("left ");  	printf("%i",left_blk); 	printf("\n");
	
	printf("right "); 	printf("%i",right_blk); 	printf("\n");
	
	printf("middle_black"); 	printf("%i",mid_blk); 	printf("\n");

	while(!b_button()){}
	set_a_button_text("Press-");
	set_b_button_text("-Red-");
	set_c_button_text("-Stop");
}
コード例 #2
0
int main()
{
	
	printf("Hello, World!\n");
	set_a_button_text("Some button a");
	set_b_button_text("That other button");
	set_c_button_text("Useless button");
	create_connect();
	printf("The buttons have been renamed.\n Deal with it.\n Press button 'some button' &\n 'That other button' for beeps.\n 'Useless button' stops the beeps.\n");
	while (side_button() ==0){
		if (a_button() == 1){// can hold for continuous beeps
			printf("beep\n");
			beep();
			msleep(500);
		}
		else if (b_button_clicked() == 1){// must release button
			printf("beep-beep\n");
			beep();
			msleep(300);
			beep();
		}
		else {
			printf("No button pressed.\n");
		}
	}
		printf("I quit");
	create_disconnect();
	return 0;
}
コード例 #3
0
int main()
{
	int i, off=0, on=1, lports[]=LIGHT_PORTS, pcnt, w=40, m=5;
	float s;
	graphics_open(320,240);
	for(i=0;i<256;i+=5) {
		graphics_fill(i,i,i);
		graphics_update();
	}
	SplashBG(320, 240);
	msleep(1000);
	graphics_close();
	pcnt=NPORTS(lports);
	for(i=8;i<16;i++) { // change the digital ports to output
		set_digital_output(i,1);
	}
	srand(time(NULL)); // prime random number generation
	while(1) { 
		table_lights(lports,pcnt,off); // shut off table lights
		setup(); // team setup (light calibration w/time out option)
		// setup done, including any time outs so proceed with judge's setup
		//get_shelf_positions(); // display orange/yellow block set up for judges - 2014
		get_bgal_pod_positions(); // display left-right positions for Botgal & pod - 2015
		set_a_button_text("QUIT");	set_b_button_text("-"); set_c_button_text("-");
		graphics_close();  // close any open graphics
		graphics_open(3*w,62);	
		display_clear();
		display_printf(0,0,"************** BOTBALL 2015 **************");
		display_printf(0,1,"               LIGHTS ON IN");
		display_printf(0,2,"******************************************");
		display_printf(0,9,"      Press QUIT to stop count down");
		if (countdown_sd(5,1,BLUE,YELLOW,m,w)) continue;
		s=seconds();
		// 2015
		table_lights(lports,pcnt,on); // on for 115 seconds	
		display_printf(0,1,"     GAME CLOCK - LIGHTS ON TILL 5");
		if (countdown(120,11,GREEN,BLUE,m,w)) continue;
		// end 2015
		/*
		// 2014	
		table_lights(lports,pcnt,on); // on for 15 seconds	
		display_printf(0,1,"     GAME CLOCK - LIGHTS ON TILL 105");
		if (countdown(120,106,GREEN,BLUE,m,w)) continue;
		table_lights(lports,pcnt,off); // of for 100 seconds	
		display_printf(0,1,"      GAME CLOCK - LIGHTS OFF TILL 5");
		if (countdown(105,11,LTBLUE,RED,m,w)) continue;
		// end 2014
		*/
		if (countdown(10,6,LTORANGE,BLUE,m,w)) continue;
		display_printf(0,1,"     GAME CLOCK - LIGHTS BLINK TILL 0");
		i=5+(seconds()-s);
		if (blinkdown(5,0,RED,YELLOW,m,w,lports,pcnt)) continue;
		display_printf(0,1,"            GAME CLOCK - %d          ",i);
		display_printf(0,9,"          ***** GAME OVER! *****     ");
		table_lights(lports,pcnt,off); // shut off table lights
		msleep(5000); // pause display
	}
	return 0;
}
コード例 #4
0
ファイル: opencv.c プロジェクト: AaronMutchler/rus-botball
void start_buttons() {
	extra_buttons_show();
	set_a_button_text("Image");
	set_b_button_text("Grayscale");
	set_c_button_text("Canny");
	set_x_button_text("HoughLines");
	set_y_button_text("Take picture");
}
コード例 #5
0
void calibrate(){
	printf("Bitte setze alle Sensoren auf den schwarzen Streifen\n");
	set_a_button_text("calibrate");
	while(!digital(BUTTON)){}
	right_blk = analog10(RIGHT_SENSOR);
	left_blk = analog10(LEFT_SENSOR);
	msleep(500);
	printf("left ");
	printf("%i",left_blk);
	printf("\n");
	
	printf("right ");
	printf("%i",right_blk);
	printf("\n");
	set_a_button_text("start");
	while(!digital(BUTTON)){}
	set_a_button_text("A");
	set_b_button_text("stop");
	}
コード例 #6
0
void get_bgal_pod_positions()
{
	// screen size (scols,srows), box size (bxcols,bxcols), separator m pixels
	// random block positions p1, p2 set by function picks
	int srows=120,scols=160, bpos, ppos;
	graphics_close(); // close any existing graphics window
	display_clear();  // prep screen
	set_a_button_text("COUNTDOWN");	set_b_button_text("-"); set_c_button_text("-");
	graphics_open(scols,srows);
	graphics_fill(WHITE);
	bpos=rand()%2;
	if (bpos==0) ppos=1;
	else ppos=0;	
	// draw field
	graphics_rectangle(3,3,157,117,BLACK);        // outline
	graphics_rectangle(3,3,70,50,BLACK);          // quads
	graphics_rectangle(90,3,157,50,BLACK);
	graphics_rectangle(3,70,70,117,BLACK);
	graphics_rectangle(90,70,157,117,BLACK);
	graphics_rectangle_fill(70,3,90,50,LTBROWN);         // mesa
	graphics_rectangle(70,3,90,50,BLACK);
	graphics_rectangle_fill(70,70,90,117,LTBROWN);
	graphics_rectangle(70,70,90,117,BLACK); 
	graphics_rectangle_fill(72,50,88,70,LTGRAY);  // caldera
	graphics_rectangle(72,50,88,70,BLACK);
	graphics_rectangle_fill(20,3,25,50,TEAL);     // lines
	graphics_rectangle_fill(135,3,140,50,TEAL);
	graphics_rectangle_fill(20,70,25,117,PINK);
	graphics_rectangle_fill(135,70,140,117,PINK);	
	if (bpos==0) { 
		draw_bg(73,13,0.2);
		graphics_rectangle_fill(74,87,86,102,GREEN);
	}
	else {
		draw_bg(73,82,0.2);
		graphics_rectangle_fill(74,18,86,32,GREEN);
	}
	graphics_update();
	
	display_printf(2,0,"Set Botgal and Botpod ");
	
	while(a_button()==0);
	while(a_button()==1); // debounce
}
コード例 #7
0
ファイル: lego_v5.c プロジェクト: mvwicky/SBHS2013
int main()
{
	msleep(2500);
	set_analog_pullup(ET_s , 0); 
	extra_buttons_show(1); // show three extra buttons
	set_a_button_text("COORDS"); // set the text of various buttons
	set_b_button_text("POM SIZE");
	set_c_button_text("BOTGUY SIZE");
	set_x_button_text("CUBE SIZE"); 

	lego.left.port = 0; // set motor ports
	lego.right.port = 2;
	
	camera_open(LOW_RES);
	camera_update();
	while (a_button() == 0) // press the a button to set the coordinates
	{
		camera_update();
		target.green.x = get_object_center(0 , 0).x; // sets target coordinates (x)
		target.green.y = get_object_center(0 , 0).y; // sets target coordinates (y)
		printf("(%d , %d)\n" , target.green.x , target.green.y);
		msleep(10);
	}
	while (b_button() == 0)
	{
		camera_update();
		target.green.size = get_object_area(0 , 0);
		target.orange.size = get_object_area(1 , 0);
		printf("Orange Size = %d" , target.orange.size);
		printf(" Green Size = %d\n" , target.green.size);
	}
	enable_servo(arm_servo); 
	enable_servo(push_servo);
	enable_servo(basket_servo);
	set_servo_position(arm_servo , ARM_UP);
	set_servo_position(push_servo , P_DOWN);
	set_servo_position(basket_servo , B_UP);
	printf("(%d , %d)\n" , target.green.x , target.green.y);
	while(a_button() == 0)
	{
		printf("%d , %d , %d\n" , get_left() , get_middle() , get_right());
	}
	while (1) // line follow until poms are seen
	{
		blob_update();
		t_line_follow();
		if (current.orange.size > target.orange.size && current.green.size > target.green.size)
			break;
	}
	blob_update(); 
	get_pom(); // pick up a pom
	pom_push(); // push it into the basket
	while (1) // turn to next pom
	{
		blob_update();
		mav(lego.left.port , 300); 
		mav(lego.right.port , -300);
		msleep(10);
		if (current.green.size > target.green.size)
			break;
	}
	blob_update();
	get_pom(); // pick up pom
	pom_push(); // push it into the basket
	avoid_cubeguy(); // avoid the cube or botguy
	avoid_booster();
	while (1)
	{
		blob_update();
		t_line_follow();
		if (current.orange.size > target.orange.size && current.green.size > target.green.size)
			break;
	}
	blob_update();
	pom_push();
	while (1)
	{
		blob_update();
		mav(lego.left.port , 300);
		mav(lego.right.port , -300);
		msleep(10);
		if (current.green.size > target.green.size)
			break;
	}
	blob_update();
	get_pom();
	pom_push();
	avoid_cubeguy();
	int start_time = seconds();
	int t;
	while (1)
	{
		t_line_follow();
		if (seconds() < start_time + t)
			break;
	}
	while (1)
	{

	}
}
コード例 #8
0
ファイル: main.c プロジェクト: tonyxue/KIPR-debug-interface
int main()
{
	int m1=0,m2=3,pageno=0;
	double createDriveTime;
	printf("Start!\n");
	extra_buttons_show();
	while (1)
	{
		while (pageno == 0)
		{
			set_a_button_text("Forward");
			set_b_button_text("Backward");
			set_c_button_text("All Off");
			set_x_button_text("OpenHand");
			set_y_button_text("CloseHand");
			set_z_button_text("Create Page");
			
			if (a_button_clicked())
			{
				printf("Moving forward...\n");
				motor(m1,100);
				motor(m2,100);
				while (!c_button_clicked())
				{
					msleep(1);
				}
				ao();
			}
			if (b_button_clicked())
			{
				printf("Moving backward...\n");
				motor(m1,-100);
				motor(m2,-100);
				while (!c_button_clicked())
				{
					msleep(1);
				}
				ao();
			}
			if (x_button_clicked())
			{
				enable_servo(3);
				set_servo_position(3,0);
				msleep(300);
				disable_servo(3);
			}
			if (y_button_clicked())
			{
				enable_servo(3);
				set_servo_position(3,1300);
				msleep(300);
				disable_servo(3);
			}
			if (z_button_clicked())
			{
				pageno=1;
				create_connect();
			}
		}

		while (pageno == 1)
		{
			set_a_button_text("Create Fwd");
			set_b_button_text("Create Bwd");
			set_c_button_text("Stop");
			set_x_button_text("Turn R");
			set_y_button_text("Turn L");
			set_z_button_text("M S Page");
			
			if (a_button_clicked())
			{
				createDriveTime = 0;
				printf("Create Moving forward w/ spd 100...\n");
				create_drive_straight(100);
				createDriveTime = seconds();
				while (!c_button_clicked())
				{
					msleep(1);
				}
				create_stop();
				printf("Time: %f seconds\n",seconds() - createDriveTime );
			}
			if (b_button_clicked())
			{
				createDriveTime = 0;
				printf("Create Moving backward w/ spd 100...\n");
				create_drive_straight(-100);
				createDriveTime = seconds();
				while (!c_button_clicked())
				{
					msleep(1);
				}
				create_stop();
				printf("Time: %f seconds\n",seconds() - createDriveTime );
			}
			if (x_button_clicked())
			{
				create_drive(-50,0);
				while (!c_button_clicked())
				{
					msleep(1);
				}
				create_stop();
			}
			if (y_button_clicked())
			{
				create_drive(50,0);
				while (!c_button_clicked())
				{
					msleep(1);
				}
				create_stop();
			}
			if (z_button_clicked())
			{
				pageno=0;
				create_disconnect();
			}
		}
	}
	
	return 0;
}
コード例 #9
0
ファイル: main.c プロジェクト: joshua71697/LosAltos15-0636
int main()
{
	set_a_button_text("pipe jumping");
	set_b_button_text("center drive");
	set_c_button_text("testing");
	int strategy;
	WAIT(a_button()||b_button()||c_button());
	if(a_button())
	{
		strategy=PIPE_JUMP;
	}
	else if(b_button())
	{
		strategy=CENTER_DRIVE;
	}
	else//c
	{
		WAIT(side_button());
		msleep(1000);
		set_servo_position(TRIBBLE_ARM, TA_DOWN);
		set_servo_position(TRIBBLE_CLAW, TC_OPEN);
		set_servo_position(BLOCK_CLAW, BC_START);
		set_servo_position(BASKET_ARM, BA_DOWN);
		enable_servos();
		msleep(2000);
		forward(20, 60);
		return 0;
		//set_up_drive();//gets the servos and stuff in driving position
		//test_driving();
		reset_buttons();
		set_up_drive();
		printf("press black button to begin\n");
		WAIT(side_button());
		printf("starting in 2 seconds...\n");
		msleep(2000);
		back_line_follow_time(60, 5000);
		return 9001;
	}
	WAIT(!a_button()&&!b_button());
	set_a_button_text("light start");//only gets here if running one of the real code options
	set_b_button_text("no ls");
	set_c_button_text("-");
	boolean l_s=false;//whether or not is doing light start
	WAIT(a_button()||b_button());
	if(a_button())//if b, does nothing-->l_s already false
		l_s=true;
	reset_buttons();
	if(strategy==PIPE_JUMP)
		set_up_jump();
	else//drive
		set_up_drive();
	if(l_s)
	{
		light_start(LIGHT_SENSOR);
	}
	else//no light start
	{
		printf("press black button when ready\n");
		WAIT(side_button());
		printf("starting in 2 seconds...\n");
		msleep(2000);
	}
	shutdownin(239.5);
	start();//timing
	if(strategy==PIPE_JUMP)
	{
		ready_to_jump();
		time_drive(-90, -90, 1300);//jump!
		servo_set(TRIBBLE_ARM, TA_UP,.3);//move the claw up so it can square up
		time_drive(-50, -50, 1500);//get towards the pipe
		physical_squareup(false);//square up on the back
		time_drive(50, 50, 2500);//go back towards the other wall
		physical_squareup(true);//square up on the front
		time_drive(-50, -50, 1000);//get back to the center
		right(87, 0, 50);//turn towards the edge
		time_drive(-60, -60, 1500);//move towards edge
		physical_squareup(false);//square up on the outside of the field
		tribble_claw_drop();//drop the claw-->plow position
		time_drive(68, 60, 1100);//arc into the wall to wall follow to the blocks
		//forward(5.25, 60);//move to block position
		grab_blocks();//grab the blocks...
		forward(20, 60);//plow the tribbles!
		servo_set(TRIBBLE_CLAW, TC_CLOSE, .7);//close claw to catch tribbles
		servo_set(TRIBBLE_ARM, TA_UP, 1);//put the arm up to get across the center
		forward(20, 60);//get across the center
		servo_set(TRIBBLE_ARM, TA_START, .5);//push into the ground so the claw doesn't jump
		servo_set(TRIBBLE_CLAW, TC_OPEN, .8);//back into plow position
		servo_set(TRIBBLE_ARM, TA_DOWN, .1);//back to drive position
		msleep(250);
		forward(7, 60);//get to dumping location
		nowstr("first dump started at");
		drive_dump();//dump...
		forward(7, 60);//replow the tribbles (maybe get a few extra)
		back(2, 60);//get to optimal grab location
		tribble_claw_dump();//put the tribbles in the basket
		back(5, 60);//back to dump location
		tribble_claw_drop();//put the claw back down
		drive_dump();//dump again
		nowstr("first dump finished at");
		//forward(15, 60);//plow the second set of tribbles, get to block location
		time_drive(66, 60, 3000);//arc towards the right wall to make sure it follows the right wall
		grab_blocks();//grab the blocks...
		forward(8, 60);//plow the remaining tribbles
		servo_set(TRIBBLE_CLAW, TC_CLOSE, .4);//grab the tribbles
		servo_set(TRIBBLE_ARM, TA_DUMP, 1);//raise the arm (to allow it to square up)
		time_drive(60, 60, 1500);//get towards the wall
		physical_squareup(true);//and square up on it
		msleep(200);
		back_line_follow(35.8, 60);//back up to the dumping location
		servo_set(TRIBBLE_ARM, TA_DOWN, .5);//put the arm down to get it out of the way
		nowstr("second dump started at");
		drive_dump();//dump
		tribble_claw_dump();//put the tribbles in the basket
		tribble_claw_drop();//
		drive_dump();//dump again
		nowstr("second dump finished at");
		servo_set(TRIBBLE_CLAW, TC_PART_OPEN, .3);//get the claw up and out of the way
		servo_set(TRIBBLE_ARM, TA_UP, .3);
		back(6, 60);//back up to get the caught tribbles
		servo_set(TRIBBLE_ARM, TA_START, .3);//put the claw back down
		servo_set(TRIBBLE_CLAW, TC_OPEN, .5);//
		servo_set(TRIBBLE_ARM, TA_DOWN, .1);//
		forward(38, 60);//push the tribbles (get any that went way down the field)
		back(2, 60);//tribbles near edge of claw
		tribble_claw_dump();
		servo_set(TRIBBLE_CLAW, TC_CLOSE, .3);//close the claw, just for good measure
		back_line_follow(30, 60);//get back to the dumping location
		servo_set(TRIBBLE_ARM, TA_DOWN, .5);//get the arm out of the way
		nowstr("third dump started at");
		drive_dump();
		nowstr("third dump finished at");
		back_line_follow(17, 60);//get back across the center
		right(180, 0, 50);//turn around
		tribble_claw_drop();//put the claw down...
		forward(25, 60);//and plow!
		back(2, 60);//optimal grab location
		tribble_claw_dump();//well duh...
		servo_set(TRIBBLE_CLAW, TC_CLOSE, .3);//close the claw for good measure
		time_drive(60, 60, 1500);//move towards the wall
		physical_squareup(true);//and square up on it
		back_line_follow(35.8, 60);//back up to the dumping location
		servo_set(TRIBBLE_ARM, TA_DOWN, .5);//get the claw out of the way
		nowstr("fourth dump started at");
		drive_dump();//dump stuff
		move_block_arm(BLA_MID);//get the block arm back out of the way
		servo_set(BASKET_ARM, BA_UP, 1);//put the basket back up
		time_drive(-50, -50, 1500);//one last chance to dump (stay there just cause...you never know)
	}
	else//drive strategy
	{
		forward(38, 90);//get towards the center
		right(90, 0, 70);//turn towards the middle of the gap
		forward(17, 90);//get through the gap and to the black tape
		left(85, 0, 70);//turn parallel to the black tape
		servo_set(TRIBBLE_ARM, TA_JUMP, .4);//get the claw into plow position
		servo_set(TRIBBLE_CLAW, TC_PART_OPEN, .4);//
		servo_set(TRIBBLE_ARM, TA_DOWN, .4);//
		servo_set(TRIBBLE_CLAW, TC_OPEN, .4);//
	}
	nowstr("finished at");
	return 42;
}
コード例 #10
0
void wait_for_light(int light_port_)
{
	int xBut, l_on_, l_off_, l_mid_, t, OK = 0;
	float s;
	xBut = get_extra_buttons_visible();
	set_extra_buttons_visible(0);
	set_a_button_text("-");
	set_c_button_text("-");
	set_analog_pullup(light_port_, 1);
	while (!OK) {
		set_b_button_text("Light is On");
		display_clear();
		display_printf (0, 0, "CALIBRATE: sensor port #%d", light_port_);
		display_printf(0, 1, "   press button when light is on");
		while(b_button_clicked() == 0) {
			l_on_ = analog10 (light_port_);
			display_printf(0,1,"   light on value is = %d        ", l_on_);
			msleep(50);
		}
		l_on_ = analog10(light_port_); /* sensor value when light is on */

		set_b_button_text("Light is Off");

		display_printf(0,1,"   light on value is = %d        ", l_on_);
		msleep(200);
		beep();

		display_printf(0,2,"   press button when light off");
		while(b_button_clicked() == 0) {
			l_off_ = analog10(light_port_);
			display_printf(0,3,"   light off value is = %d         ", l_off_);
			msleep(50);
		}
		l_off_ = analog10(light_port_); /* sensor value when light is off */

		display_printf(0,3,"   light off value is = %d         ", l_off_);
		msleep(200);

		if((l_off_ - l_on_) >= 60) { /* bright = small values */
			OK = 1;
			l_mid_ = (l_on_ + l_off_) / 2;
			display_printf(0, 5, "Good Calibration!");
			display_printf(0, 7, "Diff = %d:  WAITING", l_off_ - l_on_);
			while(analog10(light_port_) > l_mid_);
		} else {
			s = seconds();
			display_printf(0,7,"BAD CALIBRATION");
			if(l_off_ < 512){
				display_printf(0,8,"   Add Shielding!!");
				msleep(5000);
			} else {
				display_printf(0,8,"   Aim sensor!!");
				msleep(5000);
			}
		}
	}
	set_extra_buttons_visible(xBut);
	set_a_button_text("A");
	set_b_button_text("B");
	set_c_button_text("C");
}