I keep trying to use this code but the drivetrain isnt working during autonomous but it works during driver controll
#include "vex.h"
using namespace vex;
competition Competition;
int Brain_precision = 0, Console_precision = 0, Controller1_precision = 0;
float Uoss, Switch1, Switch2, Switch3, Switch4, Switch5, Switch6;
bool stopvision;
float ControllerScreen[3];
brain Brain;
controller Controller1 = controller(primary);
digital_out DigitalOutH = digital_out(Brain.ThreeWirePort.H);
motor leftMotorA(PORT1, ratio18_1, false);
motor Arm(PORT7, ratio18_1, false);
motor Intake(PORT12, ratio18_1, false);
motor leftMotorB(PORT2, ratio18_1, false);
motor leftMotorC(PORT5, ratio18_1, false);
motor_group LeftDriveSmart(leftMotorA, leftMotorB, leftMotorC);
motor rightMotorA(PORT3, ratio18_1, true);
motor rightMotorB(PORT4, ratio18_1, true);
motor rightMotorC(PORT6, ratio18_1, true);
motor_group RightDriveSmart(rightMotorA, rightMotorB, rightMotorC);
inertial TurnGyroSmart(PORT20);
smartdrive Drivetrain(LeftDriveSmart, RightDriveSmart, TurnGyroSmart, 319.19, 320, 40, mm, 1);
event Startvision = event();
event message1 = event();
event wait5 = event();
int onauton_autonomous_0() {
Controller1.rumble(rumbleLong);
Drivetrain.driveFor(forward,10,inches);
Drivetrain.setHeading(0.0, degrees);
Drivetrain.setStopping(hold);
Drivetrain.setDriveVelocity(25.0, percent);
Drivetrain.drive(reverse);
Drivetrain.stop();
Drivetrain.turnToHeading(335.0, degrees, true);
Drivetrain.drive(reverse);
wait5.broadcast();
wait(1.3, seconds);
Drivetrain.stop();
Drivetrain.driveFor(reverse, 12.0, inches, true);
Drivetrain.turnToHeading(284.0, degrees, true);
Intake.setVelocity(70.0, percent);
Intake.spin(forward);
return 0;
}
// "when Controller1 ButtonR1 pressed" hat block
void onevent_Controller1ButtonR1_pressed_0() {
if (Uoss == 0.0 || Uoss == 2.0) {
Intake.setVelocity(60.0, percent);
Intake.spin(reverse);
Uoss = 1.0;
}
else {
Intake.stop();
Uoss = 0.0;
}
}
void onevent_Controller1ButtonRight_pressed_0() {
Arm.spinFor(forward,58,degrees);
}
void onevent_Controller1ButtonLeft_pressed_0() {
Intake.spinFor(reverse,130,degrees);
Intake.stop();
}
// "when Controller1 ButtonR2 pressed" hat block
void onevent_Controller1ButtonR2_pressed_0() {
if (Uoss == 0.0 || Uoss == 1.0) {
Intake.setVelocity(60.0, percent);
Intake.spin(forward);
Uoss = 2.0;
}
else {
Intake.stop();
Uoss = 0.0;
}
}
// "when I receive wait5" hat block
void onevent_wait5_0() {
wait(1.0, seconds);
DigitalOutH.set(true);
}
// "when started" hat block
int whenStarted2() {
Arm.setStopping(hold);
Uoss = 0.0;
Switch1 = 0.0;
Switch2 = 0.0;
Switch3 = 0.0;
Switch4 = 1.0;
return 0;
}
// "when Controller1 ButtonL1 pressed" hat block
void onevent_Controller1ButtonL1_pressed_0() {
if (Switch1 == 0.0) {
DigitalOutH.set(true);
Switch1 = 1.0;
}
else {
DigitalOutH.set(false);
Switch1 = 0.0;
}
}
// "when driver control" hat block
int ondriver_drivercontrol_0() {
Switch6 = 2.0;
return 0;
}
// "when Controller1 ButtonUp pressed" hat block
void onevent_Controller1ButtonUp_pressed_0() {
Switch2 = 1.0;
while (!(Switch2 == 0.0)) {
Arm.setVelocity(50.0, percent);
Arm.spin(forward);
wait(5, msec);
}
Arm.stop();
}
// "when Controller1 ButtonUp released" hat block
void onevent_Controller1ButtonUp_released_0() {
Switch2 = 0.0;
}
// "when Controller1 ButtonDown released" hat block
void onevent_Controller1ButtonDown_released_0() {
Switch3 = 0.0;
}
// "when Controller1 ButtonDown pressed" hat block
void onevent_Controller1ButtonDown_pressed_0() {
Switch3 = 1.0;
while (!(Switch3 == 0.0)) {
Arm.setVelocity(50.0, percent);
Arm.spin(reverse);
wait(5, msec);
}
Arm.stop();
}
// "when started" hat block
int whenStarted3() {
while (true) {
if (Intake.temperature(percent) == 2.0) {
ControllerScreen[static_cast<int>(2) - 1] = 1;
Controller1.Screen.setCursor(Controller1.Screen.row(), 1);
Controller1.Screen.setCursor(2, 1);
Controller1.Screen.print("Intake Disconnected");
Controller1.Screen.clearLine(2);
} else if (Intake.temperature(percent) > 69.0) {
ControllerScreen[static_cast<int>(2) - 1] = 1;
Controller1.Screen.setCursor(Controller1.Screen.row(), 1);
Controller1.Screen.setCursor(2, 1);
Controller1.Screen.print("Intake Overheating");
Controller1.Screen.clearLine(2);
} else {
ControllerScreen[static_cast<int>(2) - 1] = 0;
}
wait(5, msec);
}
return 0;
}
int whenStarted1() {
Brain.Screen.drawImageFromFile("What.png", 0, 0);
while (true) {
if (Controller1.Axis2.position() > -5 || Controller1.Axis2.position() < 5) {
RightDriveSmart.setVelocity(Controller1.Axis2.position(),percent);
RightDriveSmart.spin(forward);
}
}
return 0;
}
int whenStarted6() {
while (true) {
if (Controller1.Axis3.position() > -5 || Controller1.Axis3.position() < 5) {
LeftDriveSmart.setVelocity(Controller1.Axis3.position(),percent);
LeftDriveSmart.spin(forward);
}
}
return 0;
}
// "when started" hat block
int whenStarted4() {
Controller1.Screen.clearScreen();
ControllerScreen[0] = 0.0;
ControllerScreen[1] = 0.0;
ControllerScreen[2] = 0.0;
while (true) {
if (Arm.temperature(percent) == 2.0) {
ControllerScreen[static_cast<int>(3) - 1] = 1;
Controller1.Screen.setCursor(Controller1.Screen.row(), 1);
Controller1.Screen.setCursor(3, 1);
Controller1.Screen.print("Arm Disconnected");
Controller1.Screen.clearLine(3);
} else if (Arm.temperature(percent) > 69.0) {
ControllerScreen[static_cast<int>(3) - 1] = 1;
Controller1.Screen.setCursor(Controller1.Screen.row(), 1);
Controller1.Screen.setCursor(3, 1);
Controller1.Screen.print("Arm Overheating");
Controller1.Screen.clearLine(3);
} else {
ControllerScreen[static_cast<int>(3) - 1] = 0;
}
wait(5, msec);
}
return 0;
}
// "when Controller1 ButtonY pressed" hat block
void onevent_Controller1ButtonY_pressed_0() {
Brain.Screen.drawImageFromFile("What.png", 0,0);
}
// Used to find the format string for printing numbers with the
// desired number of decimal places
const char* printToController1_numberFormat() {
// look at the current precision setting to find the format string
switch(Controller1_precision){
case 0: return "%.0f"; // 0 decimal places (1)
case 1: return "%.1f"; // 1 decimal place (0.1)
case 2: return "%.2f"; // 2 decimal places (0.01)
case 3: return "%.3f"; // 3 decimal places (0.001)
default: return "%f"; // use the print system default for everthing else
}
}
void VEXcode_driver_task() {
// Start the driver control tasks....
vex::task drive0(ondriver_drivercontrol_0);
while(Competition.isDriverControl() && Competition.isEnabled()) {this_thread::sleep_for(10);}
drive0.stop();
return;
}
void VEXcode_auton_task() {
// Start the auton control tasks....
vex::task auto1(onauton_autonomous_0);
while(Competition.isAutonomous() && Competition.isEnabled()) {this_thread::sleep_for(10);}
auto1.stop();
return;
}
int main() {
vex::competition::bStopTasksBetweenModes = false;
Competition.autonomous(VEXcode_auton_task);
Competition.drivercontrol(VEXcode_driver_task);
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// register event handlers
Controller1.ButtonR1.pressed(onevent_Controller1ButtonR1_pressed_0);
Controller1.ButtonR2.pressed(onevent_Controller1ButtonR2_pressed_0);
wait5(onevent_wait5_0);
Controller1.ButtonL1.pressed(onevent_Controller1ButtonL1_pressed_0);
Controller1.ButtonUp.pressed(onevent_Controller1ButtonUp_pressed_0);
Controller1.ButtonUp.released(onevent_Controller1ButtonUp_released_0);
Controller1.ButtonDown.released(onevent_Controller1ButtonDown_released_0);
Controller1.ButtonDown.pressed(onevent_Controller1ButtonDown_pressed_0);
Controller1.ButtonRight.pressed(onevent_Controller1ButtonRight_pressed_0);
Controller1.ButtonY.pressed(onevent_Controller1ButtonY_pressed_0);
Controller1.ButtonLeft.pressed(onevent_Controller1ButtonLeft_pressed_0);
wait(15, msec);
vex::task ws0(whenStarted1);
vex::task ws1(whenStarted2);
vex::task ws2(whenStarted3);
vex::task ws3(whenStarted4);
vex::task ws5(whenStarted6);
}
edit: code tags added by mods, please remember to use them