text
stringlengths
0
715
// function to draw all objects found
void drawObjects( vision &v, vex::color c, bool clearScreen ) {
if( clearScreen ) {
Brain.Screen.setPenColor( vex::color::black );
Brain.Screen.drawRectangle( screen_origin_x, screen_origin_y, screen_width, screen_height, vex::color::black );
}
for(int i=0;i<v.objectCount;i++)
drawObject( v.objects[i], c );
}
void autonomousProgramTask(void) {
auton = true;
//wait until inertial is calibrated
while (Inertial.isCalibrating()) {
wait(30, msec);
printControllerSetup();
Controller1.Screen.print("Calibrating Inertial");
}
float timerValue = Brain.Timer.value();
//run the autonomous program based on the autonType variable
//Auton 0: Testing Auton
if (autonType == 0) {
aTurn(90);
}
else if (autonType == 1) { //Auton 1: AWP (mostly) autonomous, near side,
//start out by lowering intake and scraper
Scraper.set(true);
Intake.spin(reverse, 5, volt);
//get triball out of match load zone
aTurn(35);
Scraper.set(false);
driveDistance = 153;
turnPID(true);
Intake.stop();
//shove alliance triball preload into goal
wait(100, msec);
Intake.spin(forward, 11, volt);
wait(70, msec);
aDriveFor(40, 100);
aDriveFor(80, 800);
aDriveFor(40, 300);
Intake.stop();
wait(200, msec);
//back up and drive to the elevation bar
aDrive(-1000);
aTurn(-135);
wait(100, msec);
aDrive(1110);
driveDistance = 45;
turnPID(true);
turnPID(true);
Intake.spin(forward, 5, volt);
//go forward the right distance, based on the distance sensor.
aDrive(1650);
if (WallDistance.objectDistance(inches) < 55){
aDrive(100);
}
Intake.stop();
} else if (autonType == 2) { //Auton 1: far side, standard one
//collect green triball under elevation bar
Intake.spin(reverse, 11, volt);
wait(800, msec);
Intake.spin(reverse, 4, volt);
//back up to goal
aDrive(-1870);
aTurn(38);
wait(100, msec);
aDrive(-1170);
aTurn(40);
aDriveFor(-40, 100);
aDriveFor(-80, 500);
aDriveFor(-40, 100);
wait(200, msec);
//go forward, turn around, and push other triball into the goal
aDrive(300);
driveDistance = -90;
turnPID(true);
Intake.spin(forward, 11, volt);
wait(200, msec);
aDriveFor(40, 100);
aDriveFor(80, 400);
aDriveFor(40, 100);
Intake.stop();
wait(100, msec);
//back up, to get other triballs
aDrive(-400);
driveDistance = -13;
turnPID(true);
//get the triball NOT on the middle line
Intake.spin(reverse, 11, volt);
aDrive(2750);
//go get triball near the very center of field
aTurn(-60);
Intake.spin(reverse, 4, volt);
aDrive(1200);
aTurn(-96);
//push the three triballs into the goal
Wings1.set(true);
Wings2.set(true);
wait(100, msec);
Intake.spin(forward, 11, volt);