Robot not Connecting to Field Control

Hey forum, my robot isn’t able to connect to the field control system. The code compiles, but it won’t connect to the system. Here is the entirety of my code:

#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 baseControl(int leftSpeed, int rightSpeed, int time)
{
  //motor[leftFront] = leftSpeed;
  LeftFront.spin( fwd, leftSpeed, velocityUnits::rpm );
  //motor[leftBack] = leftSpeed;
  LeftBack.spin( fwd, leftSpeed, velocityUnits::rpm );
  //motor[rightFront] = rightSpeed;
  RightFront.spin( fwd, rightSpeed, velocityUnits::rpm );
  //motor[rightBack] = rightSpeed;
  RightBack.spin( fwd, rightSpeed, velocityUnits::rpm );
  //time = wait1Msec(time);
  vex::task::sleep(time);
}

    void sensorControl(double speed, int sensor)
    {   
        LeftFront.setVelocity(speed,velocityUnits::rpm); 
        LeftBack.spin(directionType::fwd,speed, velocityUnits::rpm);
        RightFront.spin(directionType::fwd,speed, velocityUnits::rpm);
        RightBack.spin(directionType::fwd,speed, velocityUnits::rpm);
        LeftFront.rotateFor(sensor,rotationUnits::deg);
        LeftBack.setVelocity(0,velocityUnits::rpm);
        RightBack.setVelocity(0,velocityUnits::rpm);
        RightFront.setVelocity(0, velocityUnits::rpm);
        LeftFront.setVelocity(0, velocityUnits::rpm);
    }
    
void pivotControl(int speed, int pivot)
{       LeftFront.setRotation(0,rotationUnits::deg);
        LeftFront.setVelocity(speed,velocityUnits::rpm); 
        LeftBack.spin(directionType::fwd,-speed, velocityUnits::rpm);
        RightFront.spin(directionType::fwd,speed, velocityUnits::rpm);
        RightBack.spin(directionType::fwd,speed, velocityUnits::rpm);
        LeftFront.rotateFor(pivot,rotationUnits::deg);
        LeftBack.setVelocity(0,velocityUnits::rpm);
        RightBack.setVelocity(0,velocityUnits::rpm);
        RightFront.setVelocity(0, velocityUnits::rpm);
        LeftFront.setVelocity(0,velocityUnits::rpm);
      
}

void flipControl(int flipSpeed, int time)
{
    Roller.spin (fwd, flipSpeed, velocityUnits::rpm );
    vex::task::sleep(time);
}

void armControl(float armSpeed, int time)
{
     LeftArm.spin (fwd, armSpeed, velocityUnits::rpm );
     RightArm.spin (fwd, armSpeed, velocityUnits::rpm );
    vex::task::sleep(time);
}

void rawArmControl(float rawArmSpeed)
{
    LeftArm.spin(fwd, rawArmSpeed, velocityUnits::rpm );
    RightArm.spin(fwd, rawArmSpeed, velocityUnits::rpm );
}

void autonomous( void ) {
  // ..........................................................................
  // Insert autonomous user code here.
  // ..........................................................................
 flipControl(-100, 500);
 flipControl(0, 100);
 sensorControl(100, 1000);
 baseControl(0, 100, 500);  

 baseControl(0, 0, 100);
}

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*                              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 ) {
  
    float speed = 1;
    
    
  // 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.
    // ........................................................................

        RightFront.spin(directionType::fwd,Controller1.Axis2.position(percentUnits::pct)/speed,velocityUnits::pct);
        RightBack.spin(directionType::fwd,Controller1.Axis2.position(percentUnits::pct)/speed,velocityUnits::pct);
        LeftFront.spin(directionType::fwd,Controller1.Axis3.position(percentUnits::pct)/speed,velocityUnits::pct);
        LeftBack.spin(directionType::fwd,Controller1.Axis3.position(percentUnits::pct)/speed,velocityUnits::pct);
       
                      
                     if(Controller1.ButtonR1.pressing()){
                         LeftArm.spin(directionType::fwd, 50, velocityUnits::pct);
                         RightArm.spin(directionType::fwd, 50, velocityUnits::pct);
                          }
                      else if (Controller1.ButtonR2.pressing()){
                          LeftArm.spin(directionType::rev, 50, velocityUnits::pct);
                          RightArm.spin(directionType::rev, 50, velocityUnits::pct);
                      }
                      else{
                          LeftArm.stop(brakeType::hold);
                          RightArm.stop(brakeType::hold);
                      } 
        if(Controller1.ButtonL1.pressing()){
            Roller.spin(directionType::fwd, 50, velocityUnits::pct);
        }
        else if(Controller1.ButtonL2.pressing()){
            Roller.spin(directionType::rev, 100, velocityUnits::pct);
        }
        else{
            Roller.stop(brakeType::hold);
        }
      
      if(Controller1.ButtonUp.pressing()){
          speed = 1.25;
      }
      
      else if(Controller1.ButtonDown.pressing()){
          speed = 2;
      }
      
        if(Controller1.ButtonX.pressing()){
            armControl(50, 2050);
        }
       
      if(Controller1.ButtonY.pressing()){
          armControl(50, 1800);
      }
      
      if(Controller1.ButtonB.pressing()){
          pivotControl(75, 285);
  
      }
      if(Controller1.ButtonA.pressing()){
          sensorControl(-125, -1350);
      }
      
       
  
      
    vex::task::sleep(20); //Sleep the task for a short amount of time to prevent wasted resources. 
  }
}

//
// 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.
    }    
       
}

my other code doesn’t connect to the field control either. Here is that program:

#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 baseControl(int leftSpeed, int rightSpeed, int time)
{
  //motor[leftFront] = leftSpeed;
  LeftFront.spin( fwd, leftSpeed, velocityUnits::rpm );
  //motor[leftBack] = leftSpeed;
  LeftBack.spin( fwd, leftSpeed, velocityUnits::rpm );
  //motor[rightFront] = rightSpeed;
  RightFront.spin( fwd, rightSpeed, velocityUnits::rpm );
  //motor[rightBack] = rightSpeed;
  RightBack.spin( fwd, rightSpeed, velocityUnits::rpm );
  //time = wait1Msec(time);
  vex::task::sleep(time);
}

    void sensorControl(double speed, int sensor)
    {   
        LeftFront.setVelocity(speed,velocityUnits::rpm); 
        LeftBack.spin(directionType::fwd,speed, velocityUnits::rpm);
        RightFront.spin(directionType::fwd,speed, velocityUnits::rpm);
        RightBack.spin(directionType::fwd,speed, velocityUnits::rpm);
        LeftFront.rotateFor(sensor,rotationUnits::deg);
        LeftBack.setVelocity(0,velocityUnits::rpm);
        RightBack.setVelocity(0,velocityUnits::rpm);
        RightFront.setVelocity(0, velocityUnits::rpm);
        LeftFront.setVelocity(0, velocityUnits::rpm);
    }
    
void pivotControl(int speed, int pivot)
{       LeftFront.setRotation(0,rotationUnits::deg);
        LeftFront.setVelocity(speed,velocityUnits::rpm); 
        LeftBack.spin(directionType::fwd,-speed, velocityUnits::rpm);
        RightFront.spin(directionType::fwd,speed, velocityUnits::rpm);
        RightBack.spin(directionType::fwd,speed, velocityUnits::rpm);
        LeftFront.rotateFor(pivot,rotationUnits::deg);
        LeftBack.setVelocity(0,velocityUnits::rpm);
        RightBack.setVelocity(0,velocityUnits::rpm);
        RightFront.setVelocity(0, velocityUnits::rpm);
        LeftFront.setVelocity(0,velocityUnits::rpm);
      
}

void flipControl(int flipSpeed, int time)
{
    Roller.spin (fwd, flipSpeed, velocityUnits::rpm );
    vex::task::sleep(time);
}

void armControl(float armSpeed, int time)
{
     LeftArm.spin (fwd, armSpeed, velocityUnits::rpm );
     RightArm.spin (fwd, armSpeed, velocityUnits::rpm );
    vex::task::sleep(time);
}

void rawArmControl(float rawArmSpeed)
{
    LeftArm.spin(fwd, rawArmSpeed, velocityUnits::rpm );
    RightArm.spin(fwd, rawArmSpeed, velocityUnits::rpm );
}

void autonomous( void ) {
  // ..........................................................................
  // Insert autonomous user code here.
  // ..........................................................................
 flipControl(-100, 500);
 flipControl(0, 100);
 sensorControl(100, 1000);
 baseControl(0, 100, 500);  

 baseControl(0, 0, 100);
}

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*                              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 ) {
  
    float speed = 1;
    
    
  // 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.
    // ........................................................................

        RightFront.spin(directionType::fwd,Controller1.Axis2.position(percentUnits::pct)/speed,velocityUnits::pct);
        RightBack.spin(directionType::fwd,Controller1.Axis2.position(percentUnits::pct)/speed,velocityUnits::pct);
        LeftFront.spin(directionType::fwd,Controller1.Axis3.position(percentUnits::pct)/speed,velocityUnits::pct);
        LeftBack.spin(directionType::fwd,Controller1.Axis3.position(percentUnits::pct)/speed,velocityUnits::pct);
       
                      
                     if(Controller1.ButtonR1.pressing()){
                         LeftArm.spin(directionType::fwd, 50, velocityUnits::pct);
                         RightArm.spin(directionType::fwd, 50, velocityUnits::pct);
                          }
                      else if (Controller1.ButtonR2.pressing()){
                          LeftArm.spin(directionType::rev, 50, velocityUnits::pct);
                          RightArm.spin(directionType::rev, 50, velocityUnits::pct);
                      }
                      else{
                          LeftArm.stop(brakeType::hold);
                          RightArm.stop(brakeType::hold);
                      } 
        if(Controller1.ButtonL1.pressing()){
            Roller.spin(directionType::fwd, 50, velocityUnits::pct);
        }
        else if(Controller1.ButtonL2.pressing()){
            Roller.spin(directionType::rev, 100, velocityUnits::pct);
        }
        else{
            Roller.stop(brakeType::hold);
        }
      
      if(Controller1.ButtonUp.pressing()){
          speed = 1.25;
      }
      
      else if(Controller1.ButtonDown.pressing()){
          speed = 2;
      }
      
        if(Controller1.ButtonX.pressing()){
            armControl(50, 2050);
        }
       
      if(Controller1.ButtonY.pressing()){
          armControl(50, 1800);
      }
      
      if(Controller1.ButtonB.pressing()){
          pivotControl(75, 285);
  
      }
      if(Controller1.ButtonA.pressing()){
          sensorControl(-125, -1350);
      }
      
       
      
      
      
     
  
     
              
 
      
    vex::task::sleep(20); //Sleep the task for a short amount of time to prevent wasted resources. 
  }
}

//
// 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.
    }    
       
}

Please explain what you mean by this.
Do you mean it does not download to the V5 brain ?
Do you mean that competition switch does not activate driver control and/or autonomous ?

Also, it’s really hard to test code without the robot-config.h information, best to just attach the “.vex” file as well.

It downloads to the brain, but when I try going to the field control icon in the controller, it doesn’t allow me to go over to it.

after downloading, just run the program with field control or a competition switch connected to the controller.

If you are trying to go to the competition->match icon, that’s not enabled in vexos yet. You can simulate a driver skills or programing skills run by using those two icons on the competition screen.

So how would it work during competition?

How would I run it through a competition switch?

Nevermind, I figured it out. Thanks for the help!