Advertisement
Guest User

Untitled

a guest
May 5th, 2011
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.36 KB | None | 0 0
  1. //search for dark red (0), head toward blob
  2. int cam_check = 0;
  3. track_update(); // process the most recent image
  4. printf("Big circles\n");
  5. int c;
  6. int rotations_a = 0;
  7. int rotations_b = 0;
  8. while (cam_check == 0)//cam_check allows to program to exit loop
  9. {
  10.     while (track_count(cube) > 0) //look for cubes
  11.     { // get  x, y for the biggest blob the channel sees
  12.         track_update(); // process the most recent image
  13.         x = track_x(cube,0); y = track_y(cube,0);
  14.         printf("Biggest blob at (%d,%d)\n",x,y);
  15.         if (x > 50 && x < 110) //center in front of cube
  16.         {
  17.             int a = get_motor_position_counter(0);
  18.             track_update(); // process the most recent image
  19.             move(75,75);
  20.             if (!y < 90) //drive toward cube
  21.             {
  22.                 ao();
  23.                 set_servo_position(0, 1100);//close claw
  24.                 int b = get_motor_position_counter(0);//program b value to use in c value formula
  25.                 int c = b - a; //program c value to retrace steps
  26.                 int cam_check = cam_check + 1;//exit while loop
  27.                 printf("Cam Check + 1!\n");
  28.             }
  29.         }
  30.         if (x < 50)
  31.         {
  32.             move(-75,75);
  33.             msleep(150);
  34.             int rotations_b = rotations_b - 1;
  35.             freeze(0); freeze(3);
  36.         }
  37.         if (x < 50)
  38.         {
  39.             move(75,-75);
  40.             msleep(150);
  41.             int rotations_b = rotations_b + 1;
  42.             freeze(0); freeze(3);
  43.         }
  44.     }
  45.     move(75,-75); //turn
  46.     msleep(500); //wait 500 miliseconds
  47.     int rotations_a = rotations_a + 1;
  48.     ao(); //stop motors
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement