Autonomous code running in comp template

So sorry if this has been asked before, or if it’s an obvious issue and I’m just stupid. This is my first year programming.

So essentially when we run the code in a standard setup, w/out any templates set up at all it runs exactly as intended. However, as soon as I copy and paste it over to the comp template nothing runs properly. Any help on why would be greatly appreciated.
All motors are plugged into the proper ports, no code has been changed between the two programs.

(Also super sorry if this didn’t embed properly. I’m new to all this.)

#include "vex.h"

using namespace vex;

// A global instance of competition
competition Competition;

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



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


void autonomous(void) {
 frontLeft.spin(forward);
 backLeft.spin(forward);
 frontRight.spin(forward);
 backRight.spinFor(720,degrees);
  // ..........................................................................
  // For 15 sec of autonomous action at the beginning of the round (tbd)
  // ..........................................................................
}



void usercontrol(void) {

  while (1) {
    int forward = Controller1.Axis3.position(vex::percent);
    int sideways = Controller1.Axis4.position(vex::percent);
    int turn = Controller1.Axis1.position(vex::percent);

    frontRight.spin(vex::forward, forward - sideways - turn, vex::percent);
    frontLeft.spin(vex::forward,  forward + sideways + turn, vex::percent);
    backRight.spin(vex::forward,  forward + sideways - turn, vex::percent);
    backLeft.spin(vex::forward,   forward - sideways + turn, vex::percent);
    

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




int main() {
  // Set up callbacks for autonomous and driver control periods.
  Competition.autonomous(autonomous);
  Competition.drivercontrol(usercontrol);

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

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

What exactly do you mean, when you you say “nothing runs properly”?

How do you start your run?

Do you use competition switch or you choose rub type on the controller menu (i.e. driver control, autonomous, timed skills) ?

Also, in your autonomous 3 motors will start and are not going to stop until autonomous ends, only backRight motor is expected to stop. Is that what you expect?

3 Likes

Where’s the issue exactly?
If it’s just that the auton won’t run its an easy fix. You either need to use a competition switch or you have to pick the autonomous function on the controller.

1 Like

imma be honest, I didn’t know that competition was a controller setting. That appears to have fixed everything.

Also yeah, those settings are intentional. We were experimenting.
Thanks for your time!

2 Likes