Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //search for dark red (0), head toward blob
- int cam_check = 0;
- track_update(); // process the most recent image
- printf("Big circles\n");
- int c;
- int rotations_a = 0;
- int rotations_b = 0;
- while (cam_check == 0)//cam_check allows to program to exit loop
- {
- while (track_count(cube) > 0) //look for cubes
- { // get x, y for the biggest blob the channel sees
- track_update(); // process the most recent image
- x = track_x(cube,0); y = track_y(cube,0);
- printf("Biggest blob at (%d,%d)\n",x,y);
- if (x > 50 && x < 110) //center in front of cube
- {
- int a = get_motor_position_counter(0);
- track_update(); // process the most recent image
- move(75,75);
- if (!y < 90) //drive toward cube
- {
- ao();
- set_servo_position(0, 1100);//close claw
- int b = get_motor_position_counter(0);//program b value to use in c value formula
- int c = b - a; //program c value to retrace steps
- int cam_check = cam_check + 1;//exit while loop
- printf("Cam Check + 1!\n");
- }
- }
- if (x < 50)
- {
- move(-75,75);
- msleep(150);
- int rotations_b = rotations_b - 1;
- freeze(0); freeze(3);
- }
- if (x < 50)
- {
- move(75,-75);
- msleep(150);
- int rotations_b = rotations_b + 1;
- freeze(0); freeze(3);
- }
- }
- move(75,-75); //turn
- msleep(500); //wait 500 miliseconds
- int rotations_a = rotations_a + 1;
- ao(); //stop motors
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement