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