here is my python code. I am trying to figure out how to run my drive groups simultaneously during autonomous.
from vex import *
import urandom
# Brain should be defined by default
brain=Brain()
# Robot configuration code
inertial_12 = Inertial(Ports.PORT12)
motor_21 = Motor(Ports.PORT21, GearSetting.RATIO_18_1, False)
rotation_13 = Rotation(Ports.PORT13, False)
limit_switch_b = Limit(brain.three_wire_port.b)
digital_out_c = DigitalOut(brain.three_wire_port.c)
digital_out_d = DigitalOut(brain.three_wire_port.d)
# wait for rotation sensor to fully initialize
wait(30, MSEC)
#endregion VEXcode Generated Robot Configuration
rotation_13.set_position(61.17, DEGREES)
left_front_drive = Motor(Ports.PORT1)
left_back_drive = Motor(Ports.PORT2)
left_center_drive = Motor(Ports.PORT3)
right_front_drive = Motor(Ports.PORT4)
right_back_drive = Motor(Ports.PORT5)
right_center_drive = Motor(Ports.PORT8)
catapult = Motor(Ports.PORT9)
intake = Motor(Ports.PORT10)
forward = False
inertial_12.calibrate()
limit_switch_b.pressed(catapult.stop())
def tank_drive(left_speed, right_speed):
left_front_drive.spin(REVERSE, 100, PERCENT)
left_back_drive.spin(REVERSE, 100, PERCENT)
left_center_drive.spin(REVERSE, 100, PERCENT)
right_front_drive.spin(FORWARD, 100, PERCENT)
right_back_drive.spin(FORWARD, 100, PERCENT)
right_center_drive.spin(FORWARD, 100, PERCENT)
Controller1 = Controller(PRIMARY)
brain.screen.draw_rectangle(0, 125, 475, 122)
brain.screen.set_fill_color(Color.BLUE)
brain.screen.draw_rectangle(0, 0, 475, 127)
brain.screen.set_fill_color(Color.YELLOW)
catapult.set_stopping(HOLD)
catapult.set_velocity(100, PERCENT)
catapult.set_max_torque(100, PERCENT)
intake.set_velocity(100, PERCENT)
while Controller1.buttonX.pressing():
catapult.spin_for(FORWARD, 180, DEGREES)
# Function to control the catapult
def control_catapult(power):
catapult.spin(FORWARD, power, PERCENT)
# Function to control the intake
def control_intake(power):
intake.spin(FORWARD, power, PERCENT)
def stop_cata():
catapult.stop()
limit_switch_b.pressed(catapult.stop)
def stopintake():
intake.stop()
forward = False
Groupr = MotorGroup(left_front_drive, left_center_drive, left_back_drive)
Groupl = MotorGroup(right_front_drive, right_center_drive, right_back_drive)
def autonomous():
left_front_drive.set_max_torque(100, PERCENT)
left_back_drive.set_max_torque(100, PERCENT)
left_center_drive.set_max_torque(100, PERCENT)
right_front_drive.set_max_torque(100, PERCENT)
right_center_drive.set_max_torque(100, PERCENT)
right_back_drive.set_max_torque(100, PERCENT)
Groupl.spin_for(FORWARD, 180, DEGREES)
Groupr.spin_for(REVERSE, 180, DEGREES)
intake.spin_for(FORWARD, 360, DEGREES)
def drivercontrol():
global stop_cata
global rotation_13
global forward
while True:
# Tank drive using left and right joystick values
tank_drive(Controller1.axis3.position(), Controller1.axis2.position())
if Controller1.buttonA.pressing():
digital_out_c.set(False)
# Control the catapult using button up and down
if Controller1.buttonL2.pressing():
catapult.spin(FORWARD)
# Control the intake using button left and right
if Controller1.buttonR1.pressing():
stopintake()
elif Controller1.buttonR2.pressing() and not(forward):
intake.spin(FORWARD)
elif Controller1.buttonR2.pressing() and forward:
intake.spin(REVERSE)
elif not(Controller1.buttonR2.pressing()):
if forward:
forward = False
else:
forward = True
competition = Competition(drivercontrol, autonomous)