Auto not running off comp switch

Hi, so I have an issue with running my autonomous off of the competition switch. It works fine off of my controller but does not run during a match. I have had several refs and mentors from multiple schools look at it, but still no luck.

I have run the program on a test bot and it worked perfectly. I am almost certain it is a hardware issue, not a code issue as I had the same problem in PROS earlier this year and that is the reason I switched to VEXcode. None the less I have included my code.

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

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name]               [Type]        [Port(s)]
// Controller1          controller                    
// Motor1               motor         1               
// Motor3               motor         3               
// Motor2               motor         2               
// Motor4               motor         4               
// claw5                motor         5               
// claw10               motor         10              
// Motor9               motor         9               
// Motor11              motor         11              
// ---- 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 autonomous1(void) {
  Motor1.setVelocity(100, velocityUnits::pct);
  Motor2.setVelocity(100, velocityUnits::pct);
  Motor3.setVelocity(100, velocityUnits::pct);
  Motor4.setVelocity(100, velocityUnits::pct);

  Motor1.spin(forward);
  Motor2.spin(forward);
  Motor3.spin(forward);
  Motor4.spin(forward);
  task::sleep(500);
  Motor1.spin(reverse);
  Motor2.spin(reverse);
  Motor3.spin(reverse);
  Motor4.spin(reverse);
  task::sleep(1000);
  Motor1.stop();
  Motor2.stop();
  Motor3.stop();
  Motor4.stop();
  }

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*                              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) {
  
  int clawSpeedPCT = 100;
  int clawbackPCT = -100;
  int liftPCT = 100;
  int liftbackPCT  = -100;
  int trayPCT = 100;
  int trayupPCT= -20;
  // 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.
    // ........................................................................
    Motor1.spin(vex::directionType::fwd, Controller1.Axis2.value(), vex::velocityUnits::pct); //(Axis3+Axis4)/2
    Motor3.spin(vex::directionType::fwd, Controller1.Axis3.value(), vex::velocityUnits::pct);//(Axis3-Axis4)/2
    Motor2.spin(vex::directionType::fwd, Controller1.Axis2.value(), vex::velocityUnits::pct); //(Axis3+Axis4)/2
    Motor4.spin(vex::directionType::fwd, Controller1.Axis3.value(), vex::velocityUnits::pct);//(Axis3-Axis4)/2
    
    if(Controller1.ButtonR1.pressing()){
      claw10.spin(vex::directionType::fwd, clawSpeedPCT, vex::velocityUnits::pct);       
      claw5.spin(vex::directionType::fwd, clawSpeedPCT, vex::velocityUnits::pct); 
      }
     else if (Controller1.ButtonR2.pressing()) {
      claw10.spin(vex::directionType::fwd, clawbackPCT, vex::velocityUnits::pct);       
      claw5.spin(vex::directionType::fwd, clawbackPCT, vex::velocityUnits::pct); 
      }
      else {
     claw10.stop(); 
     claw5.stop(); 
      }

      if(Controller1.ButtonL1.pressing()){
      Motor9.spin(vex::directionType::fwd, liftPCT, vex::velocityUnits::pct);        
      }
     else if (Controller1.ButtonL2.pressing()) {
      Motor9.spin(vex::directionType::fwd, liftbackPCT, vex::velocityUnits::pct);       
      }
      else {
     Motor9.stop(); 
      }
   
    if(Controller1.ButtonB.pressing()){
      Motor11.spin(vex::directionType::fwd, trayPCT, vex::velocityUnits::pct);        
      }
     else if (Controller1.ButtonA.pressing()) {
      Motor11.spin(vex::directionType::fwd, trayupPCT, vex::velocityUnits::pct);       
      }
      else {
     Motor11.stop(); 
      } 

  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(autonomous1);
  Competition.drivercontrol(usercontrol);

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

  // Prevent main from exiting with an infinite loop.
  while (true) {
    wait(100, msec);
  }
}

My system software is also up to date according to VEXcode and the standalone updater.

Does anyone know what could be causing this issue?

Thank you for the help

I feel that the issue is that you labeled the auton function differently. Rather than naming it auton…1, use different functions for different auton (im assuming the 1 signifies that you plan to have multiple) and call those in the basic autonomous function using a selector of sorts.

2 Likes

Have you tried opening up a new competition template and pasting your code in that. Because that might tell you if you accidentally messed up the original template. Have you tried to test other robots from the switch to test if the switch is broken. Could the problem be with the robots brain or controller?

2 Likes

I have tried that. I agree, I think the issue might be my controller or brain

I am a little confused about what you mean. It is only called auto1 since someone tried that to see if the issue was the function

also make sure your brain has the latest VexOS which is here:

1 Like

What is the sequence of events you use when testing on a Competition switch? At what point:

  • Do you plug the controller into the switch
  • What are the switches set to when you connect the controller to the switch
  • When do you start your program.
  • What is the sequence of changes to the switches that you make
1 Like

@Gdemanche, could you verify that your radio is set to VEXnet and not Bluetooth?

See step 6 here: https://help.vex.com/article/11-pairing-wireless-controller-to-the-brain

1 Like

It is set to vexnet. My software is up-to-date. Is there any way to hard reset the brain so I could update it again and see if it was a transfer error during updating?

I have followed the correct steps and still no luck. I don’t think that it is a issue with the sequence

with your program running you can check competition switch status both on the controller status bar and also the brain.
test

3 Likes

How do I get that screen? I only get the blank screen and the status bar which says it works

run your program. press the button on the V5 brain to toggle between the user program screen and the vexos screen.

2 Likes

Using that screen it says driver control when I enable auto from a comp switch, what would be causing this

I have now tested it using other controller and problem solved. I had a bad controller