Esempio n. 1
0
int init()// move the grabber motors to the start position.
{
motor(1,-100); // move motor 1 at -100%
motor(3,-100); // move motor 3 at -100%
msleep(500); // stop moving the motors after .5 seconds
set_create_distance(0); // initializes the distance accumulation to start at 0
set_create_total_angle (0); // initializes the angle accumulation to start at 0
ao(); // stop all motors
return 0;
}
Esempio n. 2
0
/*goes forward for distance*/
void forward_for(int distance, int speed) {
  set_create_distance(0);

  while (get_create_distance() < distance ) {
    create_drive_direct(speed,speed);
    printf("value is %d", get_create_distance());
    msleep(100);
  }

  create_drive_direct(0,0);
}
Esempio n. 3
0
int main()
{
    create_connect();
    enable_servos();
    set_create_total_angle(0);
    set_create_distance(0);

    WhichSide();
    CenterCamera();
    Lift();
}
Esempio n. 4
0
void testDrive(){
	float time1, time2;
	set_create_distance(0);
	printf("//Press Black Button to start/stop drive\n");
	while(!black_button());	time1 = seconds();
	create_drive_straight(-50);
	printf("drive(50);\t");
	sleep(2.0);
	while(!black_button());	time2 = seconds();
	stop();
	printf("sleep(%f);\t//move %dmm",time2-time1,get_create_distance(0));
	done = 1;
}
int main()
{
	create_connect();
	create_full();
	float sec = seconds();
	set_create_distance(0);
	create_drive_distance(50, get_pot_reading(1, 1, 50), FORWARDS);
	printf("distance traveled = %i, time = %f\n", get_create_distance(), seconds() - sec);
	//sleep(2);
	//create_spin_degrees(90, 300, LEFT);
	//printf("%d\n", i);
	create_disconnect();
	return 0;
}
Esempio n. 6
0
void main(){
	int X = 0;
	create_connect();
	set_create_distance(0);
	set_create_total_angle(0);
	enable_servos();
	armPosBlockStack1();
	clawStack1();
/*	create_drive(-500,-380);
	sleep(2.3);
	create_stop();
}
*/  
//	writeToFile();
	printf("%f",seconds());
	while(1) //black_button
	{
		if (a_button()){
			testDrive();
		}
		if (b_button()){
			testDetectPVC();
		}
		if (up_button()){
			
		}
		if (down_button()){
			testTurnAdjust();
		}
		if (left_button()){
			testTurnCCW();
		}
		if (right_button()){
			testTurnCW();
		}	
	}
}
int main()
{
	set_each_analog_state(0,0,0,1,0,0,0,0);// This line sets analog ports to be pullup (0) or floating (1)
	create_connect();
	enable_servos();
	set_create_total_angle(0);
	set_create_distance(0);
	//AUO=start_process(ArmUpOpen);
	ArmUp();
	set_servo_position(
	sleep(3);
	CenterCamera();
	create_drive_straight(-200);
	while(digital(8) != 1)
	{}
	create_stop();
	sleep(1);
	ArmDownClose();
	sleep(3);
	beep();
	create_drive_straight(200);
	sleep(2);
	create_stop();
}
Esempio n. 8
0
//main stuff haha
int main()
{
  int claw = 1;     //claw port
  int arm = 0;      //arm port
  create_connect();  
  printf("create connected"); 
  set_create_total_angle(0);
  //create setup

  turn_for(10, -200); //Turns the create around
  
  //does some important stuff
  create_drive_direct(-100, -100);
  set_servo_position(claw, 1561);
  enable_servos();
  msleep(300);

  set_servo_position(arm, 1850); //arm down
  msleep(500);
  set_servo_position(claw, 1000);
  msleep(500);
  set_servo_position(arm, 1643); //grabs ball
  msleep(500);

  turn_for(36, 200); //spins onto first black path to line follow later
  msleep(500);

  forward_for(50, -100); //moves forward onto the black line

  line_follow(blackThresh , 212); //starts following the black line
  set_servo_position(claw, 1561); //drops ball
  //dropped ball already
  msleep(400);

  forward_for(500, 100); //back it up back it up

  set_servo_position(arm, 245); //holds the arm up
  msleep(100);
  set_create_distance(0);
  set_create_total_angle(0);

  while (get_create_total_angle() > -10) { //spins itself onto the angle of other black line
    create_spin_CW(200);
  }

  create_spin_CW(0); //stops spinning
  msleep(1500);

  create_drive_direct(-200, -200); //goes onto the black line to line follow later
  msleep(1000);

  create_drive_direct(0,0); //stops itself
  msleep(500);

  set_create_total_angle(0);
  while (get_create_total_angle() > -3) { //angles itself a little bit
    create_spin_CW(200);
  }
  create_spin_CW(0); //stops spinning
  msleep(400);

  create_drive_direct(-200, -200); //Drives forward a little bit to the next black line
  msleep(1500);
  create_drive_direct(0,0);

 set_create_total_angle(0);
  while (get_create_total_angle() > -7) { //Angles itself so it can drive in the middle
    create_spin_CW(200);
  }

  create_spin_CW(0); //stops spinning

  create_drive_direct(-230,-230); //Drives itself into the middle lane
  msleep(4000);

  create_drive_direct(0,0); //Reset stuff
  set_create_total_angle(0);

  while(analog(0) < blackThresh) { //Align itself using line following in the middle lane
     create_spin_CW(50);
     printf("Value is %d \n", analog(0));

     if(digital(0) >= blackThresh) {
      printf("I have found the middle black line!");
      create_spin_CW(1); //Angle itself so it is exactly on the black line
     }
  }

  create_spin_CW(0); //resets something for some reason why is this here?


  set_servo_position(claw, 1561); //grabs the red cube
  msleep(200);
  set_servo_position(arm, 1984);
  msleep(500);
  set_servo_position(claw, 1144);
  msleep(500);

  return 0;
}
int resetd()
{
	set_create_distance(0);
}