My Autonomous won't run

This is my code but my autonomous won’t run and I don’t know why.

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       VEX                                                       */
/*    Created:      Thu Sep 26 2019                                           */
/*    Description:  Competition Template                                      */
/*                                                                            */
/*----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name]               [Type]        [Port(s)]
// RM                   motor         8               
// RF                   motor         20              
// RB                   motor         18              
// LM                   motor         5               
// LF                   motor         2               
// LB                   motor         3               
// Clamp                digital_out   D               
// Controller1          controller                    
// back                 digital_out   A               
// LeftArm              motor         4               
// RightArm             motor         9               
// Ring                 motor         10              
// ---- END VEXCODE CONFIGURED DEVICES ----

#include "vex.h"

using namespace vex;

// A global instance of competition
competition Competition;

// define your global instances of motors and other devices here

/*---------------------------------------------------------------------------*/
/*                          Pre-Autonomous Functions                         */
/*                                                                           */
/*  You may want to perform some actions before the competition starts.      */
/*  Do them in the following function.  You must return from this function   */
/*  or the autonomous and usercontrol tasks will not be started.  This       */
/*  function is only called once after the V5 has been powered on and        */
/*  not every time that the robot is disabled.                               */
/*---------------------------------------------------------------------------*/

void pre_auton(void) {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // All activities that occur before the competition starts
  // Example: clearing encoders, setting servo positions, ...
}

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*                              Autonomous Task                              */
/*                                                                           */
/*  This task is used to control your robot during the autonomous phase of   */
/*  a VEX Competition.                                                       */
/*                                                                           */
/*  You must modify the code to add your own robot specific commands here.   */
/*---------------------------------------------------------------------------*/

void autonomous(void) {
  RF.setVelocity(100,percent);
  RB.setVelocity(100,percent);
  RM.setVelocity(100,percent);
  LF.setVelocity(100,percent);
  LB.setVelocity(100,percent);
  LM.setVelocity(100,percent);
  
  Clamp.set(true);
  vex::task::sleep(1000);
  RF.startRotateFor(vex::directionType::rev, 700, vex::rotationUnits::deg);
  RM.startRotateFor(vex::directionType::fwd, 700, vex::rotationUnits::deg);
  RB.startRotateFor(vex::directionType::rev, 700, vex::rotationUnits::deg);
  LF.startRotateFor(vex::directionType::rev, 700, vex::rotationUnits::deg);
  LM.startRotateFor(vex::directionType::fwd, 700, vex::rotationUnits::deg);
  LB.startRotateFor(vex::directionType::rev, 700, vex::rotationUnits::deg);
  vex::task::sleep(1000);
  Clamp.set(false);
  vex::task::sleep(500); 
   LF.startRotateFor(vex::directionType::fwd, 500, vex::rotationUnits::deg);
  LM.startRotateFor(vex::directionType::rev, 500, vex::rotationUnits::deg);
  LB.startRotateFor(vex::directionType::fwd, 500, vex::rotationUnits::deg);
  RF.startRotateFor(vex::directionType::fwd, 500, vex::rotationUnits::deg);
  RM.startRotateFor(vex::directionType::rev, 500, vex::rotationUnits::deg);
  RB.startRotateFor(vex::directionType::fwd, 500, vex::rotationUnits::deg);
  // ..........................................................................
  // Insert autonomous user code here.
  // ..........................................................................
}

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*                              User Control Task                            */
/*                                                                           */
/*  This task is used to control your robot during the user control phase of */
/*  a VEX Competition.                                                       */
/*                                                                           */
/*  You must modify the code to add your own robot specific commands here.   */
/*---------------------------------------------------------------------------*/

void usercontrol(void) {
  // User control code here, inside the loop
  while (1) {
    // This is the main execution loop for the user control program.
    // Each time through the loop your program should update motor + servo
    // values based on feedback from the joysticks.

    // ........................................................................
    // Insert user code here. This is where you use the joystick values to
    // update your motors, etc.
    // ........................................................................

    wait(20, msec); // Sleep the task for a short amount of time to
                    // prevent wasted resources.
  }
}

//
// Main will set up the competition functions and callbacks.
//
int main() {
  // Set up callbacks for autonomous and driver control periods.
  Competition.autonomous(autonomous);
  Competition.drivercontrol(usercontrol);

  // Run the pre-autonomous function.
  pre_auton();
  

  RM.stop(vex::brakeType::hold);
       RB.stop(vex::brakeType::hold);
       RF.stop(vex::brakeType::hold);
       LF.stop(vex::brakeType::hold);
       LB.stop(vex::brakeType::hold);
       LM.stop(vex::brakeType::hold);
  // Prevent main from exiting with an infinite loop.
  while (true) {
    RB.spin(vex::directionType::fwd, (Controller1.Axis3.position() - Controller1.Axis1.value())/1, vex::velocityUnits::pct);
     RF.spin(vex::directionType::fwd, (Controller1.Axis3.position() - Controller1.Axis1.value())/1, vex::velocityUnits::pct);
     RM.spin(vex::directionType::fwd, (Controller1.Axis3.position() - Controller1.Axis1.value())/1, vex::velocityUnits::pct);    
     LM.spin(vex::directionType::fwd, (Controller1.Axis3.position() + Controller1.Axis1.value())/1, vex::velocityUnits::pct);
     LB.spin(vex::directionType::fwd, (Controller1.Axis3.position() + Controller1.Axis1.value())/1, vex::velocityUnits::pct);
     LF.spin(vex::directionType::fwd, (Controller1.Axis3.position() + Controller1.Axis1.value())/1, vex::velocityUnits::pct);
     
       if (Controller1.ButtonUp.pressing()) {
      back.set(true);

     }
     else if(Controller1.ButtonDown.pressing()){
      back.set(false);
      

     }
    if (Controller1.ButtonR2.pressing()) {
      Clamp.set(true);
    }
      else{
        Clamp.set(false);

      }
      if (Controller1.ButtonR1.pressing() ) {
      Ring.spin(vex::directionType::rev, 100, vex::velocityUnits::pct);
      
    }
    else if (Controller1.ButtonRight.pressing()) {
    Ring.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
    }
    else{
    Ring.stop(vex::brakeType::hold);
    
    }
     if (Controller1.ButtonL1.pressing()) {
     LeftArm.spin(vex::directionType::fwd,80, vex::velocityUnits::pct);
     RightArm.spin(vex::directionType::fwd,80, vex::velocityUnits::pct);

    
    }
    else if (Controller1.ButtonL2.pressing()) {
   LeftArm.spin(vex::directionType::rev, 80, vex::velocityUnits::pct);
   RightArm.spin(vex::directionType::rev, 80, vex::velocityUnits::pct);
    
    }
    else{
    LeftArm.stop(vex::brakeType::hold);
    
    RightArm.stop(vex::brakeType::hold);

    

    }

    wait(100, msec);
  }
}

Edit: code tags added by mods, please remember to use them.

probably because of all the driver control code in main that should be in the usercontrol function.

5 Likes