Autonomous not working with driver control

Hello Forum,
My team is having a problem with our autonomous and driver control. When we run our code, the autonomous usually does not work at all, and the driver control works the way it’s supposed to. But, in the few instances when our autonomous programming does work, our drivetrain just doesn’t work, we can’t move around at all. Here is our programming:

#pragma region VEXcode Generated Robot Configuration
// Make sure all required headers are included.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>


#include "vex.h"

using namespace vex;

// Brain should be defined by default
brain Brain;


// START V5 MACROS
#define waitUntil(condition)                                                   \
  do {                                                                         \
    wait(5, msec);                                                             \
  } while (!(condition))

#define repeat(iterations)                                                     \
  for (int iterator = 0; iterator < iterations; iterator++)
// END V5 MACROS


// Robot configuration code.
controller Controller1 = controller(primary);
motor Tank = motor(PORT10, ratio36_1, false);

motor LeftShooter = motor(PORT16, ratio36_1, false);

motor RightShooter = motor(PORT18, ratio36_1, false);

motor FR = motor(PORT8, ratio36_1, true);

motor FL = motor(PORT2, ratio36_1, false);

motor BR = motor(PORT15, ratio36_1, true);

motor BL = motor(PORT13, ratio36_1, false);

motor Hook = motor(PORT6, ratio36_1, false);




// Helper to make playing sounds from the V5 in VEXcode easier and
// keeps the code cleaner by making it clear what is happening.
void playVexcodeSound(const char *soundName) {
  printf("VEXPlaySound:%s\n", soundName);
  wait(5, msec);
}



// define variable for remote controller enable/disable
bool RemoteControlCodeEnabled = true;
// define variables used for controlling motors based on controller inputs
bool Controller1LeftShoulderControlMotorsStopped = true;
bool Controller1RightShoulderControlMotorsStopped = true;
bool Controller1UpDownButtonsControlMotorsStopped = true;
bool Controller1XBButtonsControlMotorsStopped = true;

// define a task that will handle monitoring inputs from Controller1
int rc_auto_loop_function_Controller1() {
  // process the controller input every 20 milliseconds
  // update the motors based on the input values
  while(true) {
    if(RemoteControlCodeEnabled) {
      // check the ButtonL1/ButtonL2 status to control LeftShooter
      if (Controller1.ButtonL1.pressing()) {
        LeftShooter.spin(forward);
        Controller1LeftShoulderControlMotorsStopped = false;
      } else if (Controller1.ButtonL2.pressing()) {
        LeftShooter.spin(reverse);
        Controller1LeftShoulderControlMotorsStopped = false;
      } else if (!Controller1LeftShoulderControlMotorsStopped) {
        LeftShooter.stop();
        // set the toggle so that we don't constantly tell the motor to stop when the buttons are released
        Controller1LeftShoulderControlMotorsStopped = true;
      }
      // check the ButtonR1/ButtonR2 status to control RightShooter
      if (Controller1.ButtonR1.pressing()) {
        RightShooter.spin(forward);
        Controller1RightShoulderControlMotorsStopped = false;
      } else if (Controller1.ButtonR2.pressing()) {
        RightShooter.spin(reverse);
        Controller1RightShoulderControlMotorsStopped = false;
      } else if (!Controller1RightShoulderControlMotorsStopped) {
        RightShooter.stop();
        // set the toggle so that we don't constantly tell the motor to stop when the buttons are released
        Controller1RightShoulderControlMotorsStopped = true;
      }
      // check the ButtonUp/ButtonDown status to control Tank
      if (Controller1.ButtonUp.pressing()) {
        Tank.spin(forward);
        Controller1UpDownButtonsControlMotorsStopped = false;
      } else if (Controller1.ButtonDown.pressing()) {
        Tank.spin(reverse);
        Controller1UpDownButtonsControlMotorsStopped = false;
      } else if (!Controller1UpDownButtonsControlMotorsStopped) {
        Tank.stop();
        // set the toggle so that we don't constantly tell the motor to stop when the buttons are released
        Controller1UpDownButtonsControlMotorsStopped = true;
      }
      // check the ButtonX/ButtonB status to control Hook
      if (Controller1.ButtonX.pressing()) {
        Hook.spin(forward);
        Controller1XBButtonsControlMotorsStopped = false;
      } else if (Controller1.ButtonB.pressing()) {
        Hook.spin(reverse);
        Controller1XBButtonsControlMotorsStopped = false;
      } else if (!Controller1XBButtonsControlMotorsStopped) {
        Hook.stop();
        // set the toggle so that we don't constantly tell the motor to stop when the buttons are released
        Controller1XBButtonsControlMotorsStopped = true;
      }
    }
    // wait before repeating the process
    wait(20, msec);
  }
  return 0;
}

task rc_auto_loop_task_Controller1(rc_auto_loop_function_Controller1);

#pragma endregion VEXcode Generated Robot Configuration

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       {author}                                                  */
/*    Created:      {date}                                                    */
/*    Description:  V5 project                                                */
/*                                                                            */
/*----------------------------------------------------------------------------*/
void preAutonomous(void) {
  // actions to do when the program starts
  Brain.Screen.clearScreen();
  Brain.Screen.print("pre auton code");
  wait(1, seconds);
}
void autoMove(int Hook2, int RightShooter2, int LeftShooter2, int BL2, int BR2, int FL2, int FR2, double time){
   Hook.setVelocity(Hook2,percent);
   RightShooter.setVelocity(RightShooter2,percent);
   LeftShooter.setVelocity(LeftShooter2,percent);
   BL.setVelocity(BL2,percent);
   BR.setVelocity(BR2,percent);
   FL.setVelocity(FL2,percent);
   FR.setVelocity(FR2,percent);
   Hook.spin(forward);
   RightShooter.spin(forward);
   LeftShooter.spin(forward);
   BL.spin(forward);
   BR.spin(forward);
   FL.spin(forward);
   FR.spin(forward);
   wait(time, msec);
   Hook.setVelocity(0,percent);
   RightShooter.setVelocity(0,percent);
   LeftShooter.setVelocity(0,percent);
   BL.setVelocity(0,percent);
   BR.setVelocity(0,percent);
   FL.setVelocity(0,percent);
   FR.setVelocity(0,percent);
 }
void autonomous(void) {
  Brain.Screen.clearScreen();
  Brain.Screen.print("autonomous code");
  autoMove(-130,0,0,0,0,0,0, 2000);
  wait(10, msec);
  autoMove(0,-360,360,0,0,0,0, 2000);
  wait(10, msec);
  autoMove(0, 0, 0, 360, -360, 360, -360, 2000);
}

void userControl(void) {
  Brain.Screen.clearScreen();
  // place driver control in this while loop
  
int main(){

} 
  // create competition instance
  competition Competition;

  // Set up callbacks for autonomous and driver control periods.
  Competition.autonomous(autonomous);
  Competition.drivercontrol(userControl);

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

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

Any help would be greatly appreciated. Thank you!

edit: code tags added by mods, please remember to use them when posting code.

First of all, in function void userControl(void), there isn’t a closing brace. Secondly, in the autoMove function, you are passing values such as “360” and “-360”, which is not a type percent even though you pass it in as a percent. also, seperate your code a little bit and dont make every single movement condensed to one function. Also, maybe ask the programmers in your school for help before coming to vex forums, as these are very simple fixes and design flaws.

You should ask the programmers in your school for help Evelyn, their job is to help you and you haven’t asked them yet.

The code works in skills, so the problem is not the percents.

I actually have asked, none of them knew how to fix it.

You may need to set this to false at the beginning of autonomous and back to true at the beginning of driver control.

The code you posted does seem to have some syntax errors, perhaps that was just a cut & paste issue, if you attach the project file here and I will take a look for you.

1 Like

I will try that, thank you! If we continue to have issues, I will attach the project file.

Ok, sounds great, let us know if you have anymore issues.