BOTBALL codes
//This program was designed by our team before the BOTBALL Regional
//Tournament 2013, Carnegie Mellon University in Qatar
iRobot Create
// Created on Thu March 21 2013
//Port 1 Up Value = 1350
//Port 1 Down Value = 0
//Port 3 Up Value = 763
//Port 3 Down Value = 2047
int main()
{ speedtest.qa
enable_servos(); // Servos are enabled
set_servo_position(1,1350); // sets servo up so that we can hold PVC
set_servo_position(3,763); // ^^^^^^^^^^^^^^^^^^^^^^
int linefollow = 7; // declaring line foolow as 7
printf("BEST OF LUCK!!!!!");
create_connect(); // connecting to create
wait_for_light(3); // waiting for light
shut_down_in(117); // shut downs in 117 seconds
while(analog10(linefollow)<512){ //while line not detected
create_drive_direct(150,150); // move forward
}
create_stop(); // stop when line detected
printf("found line");
create_drive_direct(200,200); // moves into the launch area
msleep(1000); // for 1 second
create_drive_direct(100,-100); // turns
msleep(500); //
create_stop(); // create stops
msleep(80000); // sleeps till the other bot comes
create_drive_direct(100,100); // moves forward to collect objects
msleep(3000); // for 3 seconds
create_drive_direct(-100,-100); // comes back a little so that it can get right into the transporter
msleep(150);
set_servo_position(1,0); // sets servo down so that it can get all the peices inside
set_servo_position(3,2047); // other servo%^^^^^^^^^^^
disable_servos(); // disables servo
create_disconnect();
printf("did we win");
return 0;
}
DemoBot
int main()
{
int rport=7, leftmtr=0, rghtmtr=3; // identify port and motors
int threshold=512; // set threshold for light conditions
int botguybump = 10;
int high=100,low=-10; // set wheel powers for arc radius
printf("Line following: position robot on tape\n");
//wait_for_light(3);
//shut_down_in(115);
while(digital(botguybump) == 0){ // stop if button is pressed
while (analog10(rport) > threshold) { // continue until not dark
motor(leftmtr,high); motor(rghtmtr,low); // arc left
if (digital(botguybump) == 0) break; } // or button pressed
while (analog10(rport) <= threshold){ // continue until dark
motor(leftmtr,low); motor(rghtmtr,high); // arc right
if (digital(botguybump) == 0) break; } // or button pressed
}
motor(leftmtr,-25); //just turns a bit to ensure it is on the white and not on the black
motor(rghtmtr,25);
msleep(500);
while(analog10(rport) < threshold){ //now as it is on the white, it can keep spinning until it sees the black line.
motor(rghtmtr,50);
motor(leftmtr,-50);
}
motor(leftmtr,100); //now, the robot is on the edge of the line, which means, it is not parallel to the wall. so we give this small turn
motor(rghtmtr,-100);
msleep(47);
motor(rghtmtr,100); //it just goes straight
motor(leftmtr,100);
msleep(3500);
motor(leftmtr,100); //takes a 90 degree turn
motor(rghtmtr,-100);
msleep(900);
motor(leftmtr,100); // moves a bit forward.
motor(rghtmtr,100);
msleep(2500);
motor(leftmtr,100); //turns 90 degrees to face the interior of the launch area
motor(rghtmtr,-100);
msleep(900);
motor(leftmtr,100); //moves into the launch area
motor(rghtmtr,100);
msleep(1700);
motor(leftmtr,-100); //since there is nothing blocking the container in the front. all it has to do is come back outside the launch area, leaving all the things inside.
motor(rghtmtr,-100);
msleep(1850);
ao(); // stop because program over
printf("Did we do it ?????");
return 0;
}