Can you please tell me why this isn’t working?
This is our six motor drivetrain code. It’s able to drive, but the autonomous doesn’t work. It is on when started currently
myVariable = 0
SpeedLeft = 0
SpeedRight = 0
def Turn_Heading(Turn_Heading__Heading):
global myVariable, SpeedLeft, SpeedRight
L1.spin(FORWARD)
L2.spin(FORWARD)
L3.spin(FORWARD)
R1.spin(REVERSE)
R2.spin(REVERSE)
R3.spin(REVERSE)
while not (math.fabs(Turn_Heading__Heading - 0) < 2 and L1.velocity(RPM) < 5):
SpeedLeft = 2.4 * (Turn_Heading__Heading - inertial_7.rotation(DEGREES))
SpeedRight = 2.4 * (inertial_7.rotation(DEGREES) - Turn_Heading__Heading)
L1.set_velocity(SpeedLeft, RPM)
L2.set_velocity(SpeedLeft, RPM)
L3.set_velocity(SpeedLeft, RPM)
R1.set_velocity(SpeedRight, RPM)
R2.set_velocity(SpeedRight, RPM)
R3.set_velocity(SpeedRight, RPM)
wait(5, MSEC)
L1.stop()
L2.stop()
L3.stop()
R1.stop()
R2.stop()
R3.stop()
controller_1.rumble(“----”)
def Drive_Degrees(Drive_Degrees__Degrees):
global myVariable, SpeedLeft, SpeedRight
L1.spin(FORWARD)
L2.spin(FORWARD)
L3.spin(FORWARD)
R1.spin(FORWARD)
R2.spin(FORWARD)
R3.spin(FORWARD)
L1.spin_to_position(0, DEGREES)
R1.spin_to_position(0, DEGREES)
while not (math.fabs(Drive_Degrees__Degrees - L1.position(DEGREES)) < 2 and L1.velocity(RPM) < 5):
SpeedLeft = 0.68 * (Drive_Degrees__Degrees - L1.position(DEGREES))
SpeedRight = 0.68 * (Drive_Degrees__Degrees - R1.position(DEGREES))
L1.set_velocity(SpeedLeft, RPM)
L2.set_velocity(SpeedLeft, RPM)
L3.set_velocity(SpeedLeft, RPM)
R1.set_velocity(SpeedRight, RPM)
R2.set_velocity(SpeedRight, RPM)
R3.set_velocity(SpeedRight, RPM)
wait(5, MSEC)
L1.stop()
L2.stop()
L3.stop()
R1.stop()
R2.stop()
R3.stop()
controller_1.rumble(“----”)
def when_started1():
global myVariable, SpeedLeft, SpeedRight
pass
def ondriver_drivercontrol_0():
global myVariable, SpeedLeft, SpeedRight
pass
def when_started2():
global myVariable, SpeedLeft, SpeedRight
inertial_7.calibrate()
while inertial_7.is_calibrating():
sleep(50)
wait(2, SECONDS)
Intake.spin(REVERSE)
Middle_Goal.set(True)
Matchload.set(False)
Drive_Degrees(60)
Turn_Heading(90)
Drive_Degrees(60)
Turn_Heading(-90)
Drive_Degrees(-63)
Lever.spin_for(FORWARD, 110, DEGREES)
wait(0.25, SECONDS)
Lever.spin_for(REVERSE, 110, DEGREES, wait=False)
Drive_Degrees(45)
Turn_Heading(-90)
Drive_Degrees(20)
Turn_Heading(45)
Drive_Degrees(110)
wait(0.25, SECONDS)
Intake.stop()
Drive_Degrees(70)
Intake.spin(REVERSE)
Intake.stop()
Intake.spin(FORWARD)
wait(0.25, SECONDS)
Drive_Degrees(25)
Turn_Heading(-45)
Drive_Degrees(115)
Middle_Goal.set(False)
Turn_Heading(45)
Drive_Degrees(40)
Lever.spin_for(FORWARD, 120, DEGREES)
Lever.spin_for(REVERSE, 120, DEGREES)
Drive_Degrees(45)
Matchload.set(True)
Turn_Heading(-45)
Drive_Degrees(55)
def onauton_autonomous_0():
global myVariable, SpeedLeft, SpeedRight
pass
def controller_1buttonUp_pressed_callback_0():
global myVariable, SpeedLeft, SpeedRight
Middle_Goal.set(False)
def controller_1buttonDown_pressed_callback_0():
global myVariable, SpeedLeft, SpeedRight
Middle_Goal.set(True)
def controller_1buttonY_pressed_callback_0():
global myVariable, SpeedLeft, SpeedRight
Matchload.set(False)
def controller_1buttonLeft_pressed_callback_0():
global myVariable, SpeedLeft, SpeedRight
Blocker.set(False)
def controller_1buttonRight_pressed_callback_0():
global myVariable, SpeedLeft, SpeedRight
Blocker.set(True)
def controller_1buttonA_pressed_callback_0():
global myVariable, SpeedLeft, SpeedRight
Matchload.set(True)
def when_started3():
global myVariable, SpeedLeft, SpeedRight
Lever.set_velocity(60, RPM)
Intake.set_velocity(600, RPM)
def controller_1buttonX_pressed_callback_0():
global myVariable, SpeedLeft, SpeedRight
Descore.set(False)
def controller_1buttonB_pressed_callback_0():
global myVariable, SpeedLeft, SpeedRight
Descore.set(False)
def when_started4():
global myVariable, SpeedLeft, SpeedRight
while True:
SpeedLeft = (controller_1.axis1.position() + controller_1.axis3.position()) / 8.3
SpeedRight = (controller_1.axis3.position() - controller_1.axis1.position()) / 8.3
L1.spin(FORWARD, SpeedLeft, VOLT)
L2.spin(FORWARD, SpeedLeft, VOLT)
L3.spin(FORWARD, SpeedLeft, VOLT)
R1.spin(FORWARD, SpeedRight, VOLT)
R2.spin(FORWARD, SpeedRight, VOLT)
R3.spin(FORWARD, SpeedRight, VOLT)
wait(5, MSEC)
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
driver_control_task_0 = Thread( ondriver_drivercontrol_0 )
# 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
driver_control_task_0.stop()