For some reason, my auton just drives straight instead of running what it’s coded to do. Here is my code:
#region VEXcode Generated Robot Configuration
from vex import *
import urandom
import math
# Brain should be defined by default
brain=Brain()
# Robot configuration code
left_motor_a = Motor(Ports.PORT18, GearSetting.RATIO_18_1, True)
left_motor_b = Motor(Ports.PORT10, GearSetting.RATIO_18_1, True)
left_drive_smart = MotorGroup(left_motor_a, left_motor_b)
right_motor_a = Motor(Ports.PORT12, GearSetting.RATIO_18_1, False)
right_motor_b = Motor(Ports.PORT1, GearSetting.RATIO_18_1, False)
right_drive_smart = MotorGroup(right_motor_a, right_motor_b)
drivetrain = DriveTrain(left_drive_smart, right_drive_smart, 299.24, 285.75, 254, MM, 0.6)
controller_1 = Controller(PRIMARY)
intake_motor_a = Motor(Ports.PORT20, GearSetting.RATIO_18_1, False)
intake_motor_b = Motor(Ports.PORT11, GearSetting.RATIO_18_1, True)
intake = MotorGroup(intake_motor_a, intake_motor_b)
conveyor = Motor(Ports.PORT19, GearSetting.RATIO_18_1, False)
# wait for rotation sensor to fully initialize
wait(30, MSEC)
# Make random actually random
def initializeRandomSeed():
wait(100, MSEC)
random = brain.battery.voltage(MV) + brain.battery.current(CurrentUnits.AMP) * 100 + brain.timer.system_high_res()
urandom.seed(int(random))
# Set random seed
initializeRandomSeed()
def play_vexcode_sound(sound_name):
# Helper to make playing sounds from the V5 in VEXcode easier and
# keeps the code cleaner by making it clear what is happening.
print("VEXPlaySound:" + sound_name)
wait(5, MSEC)
# add a small delay to make sure we don't print in the middle of the REPL header
wait(200, MSEC)
# clear the console to make sure we don't have the REPL in the console
print("\033[2J")
# define variables used for controlling motors based on controller inputs
controller_1_left_shoulder_control_motors_stopped = True
controller_1_right_shoulder_control_motors_stopped = True
drivetrain_l_needs_to_be_stopped_controller_1 = False
drivetrain_r_needs_to_be_stopped_controller_1 = False
#endregion VEXcode Generated Robot Configuration
myVariable = 0
conveyor.set_velocity(50, PERCENT)
intake.set_velocity(180, RPM)
def driver_control():
while True:
left_speed = controller_1.axis3.position()
right_speed = controller_1.axis2.position()
left_drive_smart.set_velocity(left_speed, PERCENT)
right_drive_smart.set_velocity(right_speed, PERCENT)
left_drive_smart.spin(FORWARD)
right_drive_smart.spin(FORWARD)
# Intake
if controller_1.buttonL1.pressing():
intake.spin(FORWARD)
elif controller_1.buttonL2.pressing():
intake.spin(REVERSE)
else:
intake.stop()
# Conveyor
if controller_1.buttonR1.pressing():
conveyor.spin(FORWARD)
elif controller_1.buttonR2.pressing():
conveyor.spin(REVERSE)
else:
conveyor.stop()
conveyor.set_velocity(50, PERCENT)
intake.set_velocity(180, RPM)
drivetrain.set_drive_velocity(30,PERCENT)
drivetrain.set_turn_velocity(30,PERCENT)
wait(20, MSEC)
def autonomous():
global remote_control_code_enabled
remote_control_code_enabled = False
brain.screen.print("RC OFF")
conveyor.set_velocity(50, PERCENT)
intake.set_velocity(180, RPM)
drivetrain.set_drive_velocity(30,PERCENT)
drivetrain.set_turn_velocity(30,PERCENT)
wait(5,SECONDS)
drivetrain.drive_for(FORWARD, 6, INCHES)
# drivetrain.turn_for(RIGHT, 90, DEGREES)
# drivetrain.drive_for(FORWARD, 64, INCHES)
# intake.spin(REVERSE)
# conveyor.spin(FORWARD)
# wait(3,SECONDS)
# intake.stop()
# conveyor.stop()
# drivetrain.drive_for(REVERSE, 24, INCHES)
# drivetrain.turn_for(LEFT, 90, DEGREES)
# drivetrain.drive_for(REVERSE, 24, INCHES)
# conveyor.spin(FORWARD)
autonomous()
# competition = Competition(autonomous, driver_control)
while True:
wait(20, MSEC)
If you know what this is or how to fix it, please help ![]()