VCS Competition Code

vex::competition

void pre_auton( void ) {
vex::task::sleep(100);

}

void autonomous( void ) {
vex::task::sleep(100);
}

void usercontrol( void ) {
while (1){
RightMotorB.spin(vex::directionType::rev, Controller1.Axis2.value(), vex::velocityUnits::pct);
RightMotorF.spin(vex::directionType::fwd, Controller1.Axis2.value(), vex::velocityUnits::pct);
LeftMotorF.spin(vex::directionType::fwd, Controller1.Axis3.value(), vex::velocityUnits::pct);
LeftMotorB.spin(vex::directionType::fwd, Controller1.Axis3.value(), vex::velocityUnits::pct);

    if(Controller1.ButtonR2.pressing()) {
        Lift.spin(vex::directionType::fwd, 200, vex::velocityUnits::pct);
        Lift2.spin(vex::directionType::rev, 200, vex::velocityUnits::pct);
    }
    else if(Controller1.ButtonR1.pressing()) {
        Lift.spin(vex::directionType::rev, 200, vex::velocityUnits::pct);
        Lift.spin(vex::directionType::fwd, 200, vex::velocityUnits::pct);
    }
    else {
        Lift.stop(vex::brakeType::brake);
        Lift2.stop(vex::brakeType::brake);
    }
            if(Controller1.ButtonL1.pressing()) {
        CapFlipper.rotateTo(540,rotationUnits::deg,200,velocityUnits::pct);
    }
    else if(Controller1.ButtonL2.pressing()) {
        CapFlipper.rotateTo(0,rotationUnits::deg,200,velocityUnits::pct);
    }
    else { 
        CapFlipper.stop(vex::brakeType::brake);
    }
vex::task::sleep(20); 

}
}
int main() {

pre_auton();

Competition.autonomous( autonomous );
Competition.drivercontrol( usercontrol );
                  
while(1) {
  vex::task::sleep(100);
}    

}

What’s wrong with this. it’s giving me errors with the void pre_auton( void ).

– error – In file included from cxx_entry.cpp:16:
./main.cpp:6:1: error: cannot combine with previous ‘type-name’ declaration specifier
void pre_auton( void ) {

This


vex::competition

should be this.


vex::competition Competition;

also, because pre_auton() has a long delay, reorder the beginning of main to be like this.


Competition.autonomous( autonomous );
Competition.drivercontrol( usercontrol );
pre_auton();