[Vex C++]: Competition Template is not working

I have been trying to create some competition code using the template, but it will not function consistently. Basically, the code will run correctly about a quarter of the time. The code is below.
Thanks for any help.

#include "robot-config.h"
/*---------------------------------------------------------------------------*/
/*                                                                           */
/*        Description: Competition template for VCS VEX V5                   */
/*                                                                           */
/*---------------------------------------------------------------------------*/

//Creates a competition object that allows access to Competition methods.
vex::competition    Competition;

/*---------------------------------------------------------------------------*/
/*                          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 cortex has been powered on and    */
/*  not every time that the robot is disabled.                               */
/*---------------------------------------------------------------------------*/

void pre_auton( void ) {
  // 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 ) {
  // ..........................................................................
  // Insert autonomous user code here.
  // ..........................................................................

    LeftDriveFront.rotateFor(3.82, rotationUnits::rev, 200,velocityUnits::rpm, false);
    LeftDriveMiddle.rotateFor(3.82, rotationUnits::rev, 200,velocityUnits::rpm, false);
    LeftDriveBack.rotateFor(3.82, rotationUnits::rev, 200,velocityUnits::rpm, false);
    RightDriveFront.rotateFor(3.82, rotationUnits::rev, 200,velocityUnits::rpm, false);
    RightDriveMiddle.rotateFor(3.82, rotationUnits::rev, 200,velocityUnits::rpm, false);
    RightDriveBack.rotateFor(3.82, rotationUnits::rev, 200,velocityUnits::rpm, false);
    while (LeftDriveFront.isSpinning() || LeftDriveMiddle.isSpinning() || LeftDriveBack.isSpinning())
    {
    }
    LeftDriveFront.rotateFor(-3.82, rotationUnits::rev, 200,velocityUnits::rpm, false);
    LeftDriveMiddle.rotateFor(-3.82, rotationUnits::rev, 200,velocityUnits::rpm, false);
    LeftDriveBack.rotateFor(-3.82, rotationUnits::rev, 200,velocityUnits::rpm, false);
    RightDriveFront.rotateFor(-3.82, rotationUnits::rev, 200,velocityUnits::rpm, false);
    RightDriveMiddle.rotateFor(-3.82, rotationUnits::rev, 200,velocityUnits::rpm, false);
    RightDriveBack.rotateFor(-3.82, rotationUnits::rev, 200,velocityUnits::rpm, false);
    Flywheel.spin(directionType::fwd,200,velocityUnits::rpm);
    while (LeftDriveFront.isSpinning() || LeftDriveMiddle.isSpinning() || LeftDriveBack.isSpinning())  
    {
    }
    Ball.spin(directionType::fwd,200,velocityUnits::rpm);
    vex::task::sleep(2000);
    
    
}

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*                              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 ) {
 #include "robot-config.h"
    while (1==1)
    {
       LeftDriveFront.spin(directionType::fwd, Controller1.Axis3.value(),velocityUnits::pct);
       LeftDriveMiddle.spin(directionType::fwd, Controller1.Axis3.value(),velocityUnits::pct);
       LeftDriveBack.spin(directionType::fwd, Controller1.Axis3.value(),velocityUnits::pct);
       RightDriveFront.spin(directionType::fwd, Controller1.Axis2.value(),velocityUnits::pct);
       RightDriveFront.spin(directionType::fwd, Controller1.Axis2.value(),velocityUnits::pct);
       RightDriveBack.spin(directionType::fwd, Controller1.Axis2.value(),velocityUnits::pct);
            
        if (Controller1.ButtonL1.pressing()==1){
            Flywheel.spin(directionType::rev,200,velocityUnits::rpm);
        }
        else{
           Flywheel.stop(brakeType::coast);
        }
        if (Controller1.ButtonR1.pressing()==1) {
            Ball.spin(directionType::fwd,200,velocityUnits::rpm);
        }
        else{
           if (Controller1.ButtonR2.pressing()==1){
              Ball.spin(directionType::rev,200,velocityUnits::rpm);
           }
            else{
                 Ball.stop(brakeType::brake);
            }
        }
           
    vex::task::sleep(20);
    }
}


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

    //Prevent main from exiting with an infinite loop.                        
    while(1) {
      vex::task::sleep(100);//Sleep the task for a short amount of time to prevent wasted resources.
    }    
   }

What do you mean by not functioning correctly ? Are you using a competition switch ?
(also, remove the extra #include “robot-config.h” you have in usercontrol, that’s not necessary)

@jpearman
By not functioning correctly, I mean that both the user control and autonomous sections will not consistently execute. About 1/4 times, the user control will allow the driver to control the base motors with the two joysticks. The other 3/4 times, the robot will do nothing when the play button is pressed, more specifically, when the play button is pressed and the competition switch is set to user control, the brain screen will go black with the blue line at the top like normal, but none of the motors will react to the changing of the joysticks or buttons.
The same thing is happening with autonomous, when the play button is pressed and then the competition switch is set to autonomous, the screen goes to black with the blue stripe like normal, but the autonomous programming will not executive about 3/4 times, which is a rough estimate.
I have also tried activating it using the control and going to the skills option, but that does not solve the problem either.
The reason why I believe this is specifically a competition template problem is because the user control code will work perfectly fine in a regular file.

Then I see your issue, there are so many parts to your specific repetition that the robot won’t take it in or you aren’t waiting long enough.

ok, try starting with the competition switch set to disable and then move to enable after running the program. I think you have run into a known bug (ie. starting competition code with robot enabled) that will be fixed in the 1.0.2 vexos release (which is due out very soon)

I could use a little help in fixing these two errors

Which errors ?