예제 #1
0
void move_until_line() {
	create_drive(100, FORWARDS);
	while (get_create_rfcliff_amt() > CREATE_THRESHOLD) {
		display_printf(0, 0, "%4i", get_create_rfcliff_amt());
	}
	create_stop();
}
예제 #2
0
/* 
 * General routine for creating a volume. Mainly for use by concat, mirror,
 * raid5 and stripe commands.
 */
void
create_volume(int argc, char **argv, char *verb)
{
	struct gctl_req *req;
	const char *errstr;
	char buf[BUFSIZ], *drivename, *volname;
	int drives, flags, i;
	off_t stripesize;

	flags = 0;
	drives = 0;
	volname = NULL;
	stripesize = 262144;

	/* XXX: Should we check for argument length? */

	req = gctl_get_handle();
	gctl_ro_param(req, "class", -1, "VINUM");

	for (i = 1; i < argc; i++) {
		if (!strcmp(argv[i], "-f")) {
			flags |= GV_FLAG_F;
		} else if (!strcmp(argv[i], "-n")) {
			volname = argv[++i];
		} else if (!strcmp(argv[i], "-v")) {
			flags |= GV_FLAG_V;
		} else if (!strcmp(argv[i], "-s")) {
			flags |= GV_FLAG_S;
			if (!strcmp(verb, "raid5"))
				stripesize = gv_sizespec(argv[++i]);
		} else {
			/* Assume it's a drive. */
			snprintf(buf, sizeof(buf), "drive%d", drives++);

			/* First we create the drive. */
			drivename = create_drive(argv[i]); 
			if (drivename == NULL)
				goto bad;
			/* Then we add it to the request. */
			gctl_ro_param(req, buf, -1, drivename);
		}
	}

	gctl_ro_param(req, "stripesize", sizeof(off_t), &stripesize);

	/* Find a free volume name. */
	if (volname == NULL)
		volname = find_name("gvinumvolume", GV_TYPE_VOL, GV_MAXVOLNAME);

	/* Then we send a request to actually create the volumes. */
	gctl_ro_param(req, "verb", -1, verb);
	gctl_ro_param(req, "flags", sizeof(int), &flags); 
	gctl_ro_param(req, "drives", sizeof(int), &drives);
	gctl_ro_param(req, "name", -1, volname);
	errstr = gctl_issue(req);
	if (errstr != NULL)
		warnx("creating %s volume failed: %s", verb, errstr);
bad:
	gctl_free(req);
}
예제 #3
0
void testArc(){
	float time1, time2;
	cbc_display_clear();
	set_create_total_angle(0);
	printf("//Press Black Button to start/stop arc\n");
	while(black_button()) while(!black_button()){}
		time1 = seconds();
	create_drive(-100,-580);
	while(!black_button());	time2 = seconds();	stop();
	printf("%fsecs\t %dmm\n",time2-time1,get_create_distance(0));
	while(!black_button());
	clawSB();
	armPosSB();
	printf("\npress A for too far, B for not far enough, Black for just right\n");
	while(!done){
		if(a_button()){
			arc_value = arc_value-5;
			done = 1;
		}
		if(b_button()){
			arc_value = arc_value+5;
			done = 1;
		}
		if(black_button()) done = 1;
	}
	printf("arc = %d",arc_value);
    printf("press black button to exit");
	while(!black_button());
}
예제 #4
0
void create_virtual_bump(int speed, int direction) {
	create_drive(speed, direction);
	while (create_get_sensor(CURRENT) > CURRENT_THRESHOLD) {
		//msleep(20);
	}
	create_stop();
}
예제 #5
0
/*
 * Class:     cbccore_low_Create
 * Method:    create_drive
 * Signature: (II)V
 */
JNIEXPORT void JNICALL Java_cbccore_low_Create_create_1drive(JNIEnv *env, jobject obj, jint speed, jint radius)
{
#ifdef CBC
    create_drive(speed, radius);
#else
    printf("Java_cbccore_low_Create_create_1drive stub\n");
#endif
}
예제 #6
0
void part6(){
	driveAtMmFor(500,.5);
	turn(90);
	create_drive(-500,250);
	run_for(1.0,armPosBlockStack1);
	create_drive(-500,-520);
		run_for(.5,clawStack2);
		run_for(2.0,armPosBlockStack2);
	detectPVC();
	turn(-90);
	blockStack3();
	//wtf is this.
	/*create_drive_straight(-500); // move towards pvc
	sleep(2.5);
	create_stop();
	driveAtMmFor(50, 1);*/
}
예제 #7
0
void part5(){
	//seed, JosephMCgee:
	driveAtMmFor(500,.5);
	turnFast(-90);
	driveAtMmFor(-500,.5);
	create_drive(-500,520);
		run_for(2.6, clawGrab);
	create_drive(-500,-350);
		run_for(1.9,armPosBlockGrab);
		armPosBlockGrab();
	detectPVC();
	timeLapse();
	driveAtMmFor(250,1.00);//run_for(1.5, armPosBlockStack1);//drive bd to align create to blocks3, while simultaneously lifting arm above blocks
	turn(90);//turn towards blocks3
	armPosBlockGrab(); //arm in grab pos
	clawGrab();
	driveAtMmFor(-500,.4);//drive towards blocks
	detectBlock();//detect and slowly approch blocks.
	grabBlocks();//grab blocks procedure
}
예제 #8
0
// script to trace an arc of radius rad until deg is reach
// NOTE: if the turn is not in the direction of deg, the arc won't end
void create_script_arc(int rad, int deg, int speed) { // rad in mm, degrees, vel in mm/sec
    int sangle, dangle;
    create_angle();
    sangle=gc_total_angle;
    dangle=sangle+deg;
    create_drive(rad,speed);
    if(deg>0){
        while(gc_total_angle<dangle)create_angle();
    }
    else{
        while(gc_total_angle>dangle)create_angle();
    }
    create_stop();
}
예제 #9
0
void move_until_bump(int speed, int direction, int port) {
	create_drive(speed, direction);
	while (!digital(port));
	create_stop();
}
예제 #10
0
void move_until_line_old() {
	create_drive(100, FORWARDS);
	while (analog10(BLACK_LINE_SENSOR) < THRESHOLD);
	create_stop();
}
예제 #11
0
void CenterCamera() //CAMERA MUST BE AT CENTER OF CREATE, POINTING Right RESPECT TO CREATE
{
	track_update();
	if (track_x (0,0) > 81)
	{
		create_drive_straight(-200);
		while (track_x (0,0) > 81)	//WHAT TRACK # IS RED? MAKE SURE IT DOESNT DETECT BOTGUY
		{
			track_update();
		}
		create_stop();
		drivemm(inchestomm(4.9), 1);
		set_create_total_angle(0);
		create_drive(101.3,1);  //uses int. does it round?
		sleep(2.057252314);
		create_stop();
		get_create_total_angle(.1);
		printf("asdb");
		if (get_create_total_angle(.1) != 90)
		{
			set_create_total_angle(get_create_total_angle(.1) - 90);
			printf("%f\n",get_create_total_angle(.1));
			if (get_create_total_angle(.1) > 0) //CCW ADDS TO TOTAL ANGLE
			{
				create_spin_CW(100);
				while (get_create_total_angle(.1) < 0);
				{
					printf("aeqweqw");
				}
				create_stop();
			}
			if (get_create_total_angle(.1) < 0)
			{
				create_spin_CCW(100);
				while (get_create_total_angle(.1) > 0);
				{
					printf("BBBB");
				}
				create_stop();
			}
		}
	}
	/* (track_x (0,0) < 79)
	{
	create_drive_straight(200);
	while (track_x (0,0) < 79)
	{
	track_update();
	}
	create_stop();
	beep();
	set_create_distance(0);
	drivemm(-inchestomm(5), 1);
	create_drive(206.972051,1);
	sleep(1);
	create_stop();
	create_drive_straight(-200);
	while(digital(8 == 0))
	{
	}
	create_stop();
	}*/
}
예제 #12
0
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;
}