Actually using Visual studio Code and using the VEX extention, I guess I could of put this under the PROS section, but figured its Python so it should mimic VEXCode V5, sorry about the confussion.
# ---------------------------------------------------------------------------- #
# #
# Module: main.py #
# Author: KaldenPrime03 #
# Created: Wed Aug 24 2022 #
# Description: V5 project #
# #
# ---------------------------------------------------------------------------- #
# Library imports
#from turtle import right
#from turtle import forward
from vex import *
# Brain should be defined by default
brain=Brain()
# Robot Configuration Code
left_drive_smart = Motor(Ports.PORT1, GearSetting.RATIO_18_1, False)
right_drive_smart = Motor(Ports.PORT10, GearSetting.RATIO_18_1, True)
left_drive_rear = Motor (Ports.PORT11, GearSetting.RATIO_18_1, False)
right_drive_rear = Motor(Ports.PORT20, GearSetting.RATIO_18_1, True)
flywheel_run = Motor(Ports.PORT4, GearSetting.RATIO_18_1, True)
convayer_belt = Motor(Ports.PORT5, GearSetting.RATIO_18_1, False)
rollerw = Motor(Ports.PORT7, GearSetting.RATIO_18_1, True)
inertial_sensor = Inertial(Ports.PORT12)
colorsense = Optical(Ports.PORT4)
# Motor groups
left_group = MotorGroup(left_drive_smart, left_drive_rear)
right_group = MotorGroup(right_drive_smart, right_drive_rear)
strafe_left = MotorGroup(left_drive_smart, right_drive_rear)
strafe_right = MotorGroup(left_drive_rear, right_drive_smart)
# drivetrain and Controller
drivetrain = SmartDrive(left_group, right_group, inertial_sensor, 319.19, 295, 40, INCHES, 1) #TrackWidth, WheelBase, Wheel Travel
controller_1 = Controller(PRIMARY)
#Functions
def driveF(distance, speed, direction):
drivetrain.drive_for(direction, distance, INCHES, speed, VelocityUnits.PERCENT)
def turningT(angle, speed, turn):
drivetrain.turn_for(turn, angle, DEGREES, speed)
def slideL (distance, speed):
strafe_left.spin_for(REVERSE, distance, DEGREES, speed, VelocityUnits.PERCENT, False)
strafe_right.spin_for(FORWARD, distance, DEGREES, speed, VelocityUnits.PERCENT)
#Competition Code
def autonomous():
count = 0
brain.screen.clear_screen()
while True:
brain.screen.print_at("Auton.... %6d" %(count), x=10, y=40)
count = count + 1
driveF(100, 100, FORWARD)
slideL(20, 100)
turningT(90, 100, RIGHT)
wait(20, MSEC)
def usercontrol():
count = 0
brain.screen.clear_screen()
while True:
# controller with joy sticks
left_drive_smart.set_velocity((controller_1.axis3.position() + controller_1.axis4.position() + controller_1.axis1.position()), PERCENT)
left_drive_rear.set_velocity((controller_1.axis3.position() + controller_1.axis4.position() - controller_1.axis1.position()), PERCENT)
right_drive_smart.set_velocity((controller_1.axis3.position() - controller_1.axis4.position() - controller_1.axis1.position()), PERCENT)
right_drive_rear.set_velocity((controller_1.axis3.position() - controller_1.axis4.position() + controller_1.axis1.position()), PERCENT)
left_drive_smart.spin(FORWARD)
left_drive_rear.spin(FORWARD)
right_drive_smart.spin(FORWARD)
right_drive_rear.spin(FORWARD)
#left_group.set_velocity((controller_1.axis3.position() + controller_1.axis4.position()), PERCENT) Forward Backward, Left turn right turn
#right_group.set_velocity((controller_1.axis3.position() - controller_1.axis4.position()), PERCENT)
#left_group.spin(FORWARD)
#right_group.spin(FORWARD)
# Buttons
if controller_1.buttonA.pressing():
rollerw.spin(FORWARD)
elif controller_1.buttonB.pressing():
rollerw.spin(REVERSE)
elif controller_1.buttonL1.pressing():
rollerw.stop(HOLD)
brain.screen.print_at("driver... %6d" %(count), x=10, y=40)
count = count + 1
wait(20, MSEC)
comp = Competition(usercontrol, autonomous)