So In my case my robot wont turn unless I use drive time out. Ive had this issue for the past 2 weeks. It takes time from my autonomous. Anyone can help me program this without using drive time out and get the robot turning with using drive timeout.
Here my code. Python
myVariable = 0
def onevent_controller_1buttonB_pressed_0():
global myVariable
Lock.set(False)
def onauton_autonomous_0():
global myVariable
Lock.set(True)
wait(0.5, SECONDS)
drivetrain.set_drive_velocity(50, PERCENT)
drivetrain.set_turn_velocity(50, PERCENT)
drivetrain.set_timeout(1, SECONDS)
drivetrain.drive_for(FORWARD, 5, INCHES)
drivetrain.turn_for(LEFT, 90, DEGREES)
def onevent_controller_1buttonRight_pressed_0():
global myVariable
backwing.set(True)
def when_started1():
global myVariable
Kicker.set_max_torque(100, PERCENT)
forebar.set_max_torque(100, PERCENT)
Intake.set_max_torque(100, PERCENT)
Kicker.set_velocity(63, PERCENT)
forebar.set_velocity(100, PERCENT)
Intake.set_velocity(100, PERCENT)
drivetrain.set_drive_velocity(100, PERCENT)
drivetrain.set_turn_velocity(100, PERCENT)
forebar.set_stopping(HOLD)
Lock.set(True)
def onevent_controller_1buttonRight_released_0():
global myVariable
backwing.set(False)
def onevent_controller_1buttonY_pressed_0():
global myVariable
Wings.set(True)
def onevent_controller_1buttonY_released_0():
global myVariable
Wings.set(False)
def onevent_controller_1buttonL2_pressed_0():
global myVariable
Intake.spin(FORWARD)
def onevent_controller_1buttonDown_pressed_0():
global myVariable
Kicker.spin(FORWARD)
def onevent_controller_1buttonL2_released_0():
global myVariable
Intake.stop()
def onevent_controller_1buttonDown_released_0():
global myVariable
Kicker.stop()
def onevent_controller_1buttonL1_pressed_0():
global myVariable
Intake.spin(REVERSE)
def onevent_controller_1buttonL1_released_0():
global myVariable
Intake.stop()
def onevent_controller_1buttonR2_pressed_0():
global myVariable
forebar.spin(FORWARD)
def onevent_controller_1buttonR2_released_0():
global myVariable
forebar.stop()
def onevent_controller_1buttonR1_pressed_0():
global myVariable
forebar.spin(REVERSE)
def onevent_controller_1buttonR1_released_0():
global myVariable
forebar.stop()
# create a function for handling the starting and stopping of all autonomous tasks
def vexcode_auton_function():
# Start the autonomous control tasks
auton_task_0 = Thread( onauton_autonomous_0 )
# wait for the driver control period to end
while( competition.is_autonomous() and competition.is_enabled() ):
# wait 10 milliseconds before checking again
wait( 10, MSEC )
# Stop the autonomous control tasks
auton_task_0.stop()
def vexcode_driver_function():
# Start the driver control tasks
# wait for the driver control period to end
while( competition.is_driver_control() and competition.is_enabled() ):
# wait 10 milliseconds before checking again
wait( 10, MSEC )
# Stop the driver control tasks
# register the competition functions
competition = Competition( vexcode_driver_function, vexcode_auton_function )
# system event handlers
controller_1.buttonB.pressed(onevent_controller_1buttonB_pressed_0)
controller_1.buttonRight.pressed(onevent_controller_1buttonRight_pressed_0)
controller_1.buttonRight.released(onevent_controller_1buttonRight_released_0)
controller_1.buttonY.pressed(onevent_controller_1buttonY_pressed_0)
controller_1.buttonY.released(onevent_controller_1buttonY_released_0)
controller_1.buttonL2.pressed(onevent_controller_1buttonL2_pressed_0)
controller_1.buttonDown.pressed(onevent_controller_1buttonDown_pressed_0)
controller_1.buttonL2.released(onevent_controller_1buttonL2_released_0)
controller_1.buttonDown.released(onevent_controller_1buttonDown_released_0)
controller_1.buttonL1.pressed(onevent_controller_1buttonL1_pressed_0)
controller_1.buttonL1.released(onevent_controller_1buttonL1_released_0)
controller_1.buttonR2.pressed(onevent_controller_1buttonR2_pressed_0)
controller_1.buttonR2.released(onevent_controller_1buttonR2_released_0)
controller_1.buttonR1.pressed(onevent_controller_1buttonR1_pressed_0)
controller_1.buttonR1.released(onevent_controller_1buttonR1_released_0)
# add 15ms delay to make sure events are registered correctly.
wait(15, MSEC)
when_started1()
edit: code tags added by mods, please remember to use them as code, especially python, is almost unreadable without them.