So I have two different teams having issues with their python code, where it will run the program up to 5-7 lines, but won’t recognize anything after that.
I noticed it with one teams code thinking it was just not reading the wait, but it kept repeating the code, now I see a team where it just stops at a certain line.
Driver control works fine, it’s just auton doesn’t
HIGH SCHOOL TEAM 3685D - auton doesn’t move after turnF(right…)
# ---------------------------------------------------------------------------- #
# #
# Module: main.py #
# Author: Student #
# Created: 9/4/2024, 3:09:07 PM #
# Description: V5 project #
# #
# ---------------------------------------------------------------------------- #
# Library imports
from vex import *
# Brain should be defined by default
brain=Brain()
# Motor Configuration
rightf1 = Motor(Ports.PORT18, GearSetting.RATIO_6_1, True)
rightb1 = Motor(Ports.PORT19, GearSetting.RATIO_6_1, True)
rightm1 = Motor(Ports.PORT20, GearSetting.RATIO_6_1,False)
leftf1 = Motor(Ports.PORT15,GearSetting.RATIO_6_1, False)
leftb1 = Motor(Ports.PORT16, GearSetting.RATIO_6_1, False)
leftm1 = Motor(Ports.PORT17, GearSetting.RATIO_6_1, True)
intake1 = Motor(Ports.PORT10, GearSetting.RATIO_18_1,False)
intake2 = Motor(Ports.PORT1, GearSetting.RATIO_18_1, True)
InertialSensor = Inertial(Ports.PORT14)
MogoMech = DigitalOut(brain.three_wire_port.b)
Arm = DigitalOut(brain.three_wire_port.a)
IntakePiston = DigitalOut(brain.three_wire_port.c)
# MotorGroups
RightDrive = MotorGroup(rightf1,rightm1,rightb1)
LeftDrive = MotorGroup(leftf1,leftm1,leftb1)
Intake = MotorGroup(intake1,intake2)
# Drivetrain & Controllers
Drivetrain = SmartDrive(RightDrive,LeftDrive,InertialSensor, 300, 320, 320, MM, 1)
Controll = Controller(PRIMARY)
# Functions
def DriveF(direction, speed, distance):
Drivetrain.set_drive_velocity(speed, PERCENT)
Drivetrain.drive_for(direction, distance, INCHES)
def TurnF(direction, speed, angle):
Drivetrain.set_turn_velocity(speed, PERCENT)
Drivetrain.turn_for(direction, angle, DEGREES)
def pre_autonomous():
# actions to do when the program starts
brain.screen.clear_screen()
brain.screen.print("pre auton code")
Drivetrain.set_turn_threshold(0.6)
Drivetrain.set_turn_constant(0.6)
wait(1, SECONDS)
def autonomous():
brain.screen.clear_screen()
brain.screen.print("Hello Guy's")
# place automonous code here
DriveF(REVERSE, 50, 45)
MogoMech.set(True)
Intake.spin(REVERSE, 200)
TurnF(RIGHT, 50, 137)
DriveF(FORWARD, 60, 40)
TurnF(LEFT, 50, 88)
DriveF(FORWARD, 50, 30)
TurnF(RIGHT, 50, 124)
DriveF(FORWARD, 50, 23)
TurnF(LEFT, 50, 81)
wait(1, SECONDS)
DriveF(REVERSE, 50, 58)
wait(15,SECONDS)
def user_control():
brain.screen.clear_screen()
# place driver control in this while loop
while True:
wait(20, MSEC)
RightDrive.set_velocity(Controll.axis3.position() + Controll.axis1.position(), PERCENT)
LeftDrive.set_velocity(Controll.axis3.position() - Controll.axis1.position(), PERCENT)
RightDrive.spin(FORWARD)
LeftDrive.spin(FORWARD)
if Controll.buttonR1.pressing():
Intake.spin(FORWARD, 100, PERCENT)
elif Controll.buttonR2.pressing():
Intake.spin(REVERSE, 100, PERCENT)
else:
Intake.stop(HOLD)
if Controll.buttonL1.pressing():
MogoMech.set(False)
elif Controll.buttonL2.pressing():
MogoMech.set(True)
if Controll.buttonUp.pressing():
Arm.set(False)
elif Controll.buttonDown.pressing():
Arm.set(True)
if Controll.buttonB.pressing():
IntakePiston.set(True)
elif Controll.buttonA.pressing():
IntakePiston.set(False)
# create competition instance
comp = Competition(user_control, autonomous)
pre_autonomous()
MS team 27301A - doesn’t read the wait
# ---------------------------------------------------------------------------- #
# #
# Module: main.py #
# Author: student #
# Created: 9/28/2024, 12:36:20 PM #
# Description: V5 project #
# #
# ---------------------------------------------------------------------------- #
# Library imports
from vex import *
# Brain should be defined by default
brain=Brain()
Lfw = Motor(Ports.PORT2, GearSetting.RATIO_18_1, False)
Rfw = Motor(Ports.PORT10, GearSetting.RATIO_18_1,True)
Lbw = Motor(Ports.PORT12,GearSetting.RATIO_18_1,False)
Rbw = Motor(Ports.PORT20, GearSetting.RATIO_18_1,True)
HIntake= Motor(Ports.PORT4, GearSetting.RATIO_18_1, True)
Wall = Motor(Ports.PORT9, GearSetting.RATIO_36_1, True)
Intake= Motor(Ports.PORT5, GearSetting.RATIO_18_1,True)
Pis1=DigitalOut(brain.three_wire_port.a)
SeA = Inertial(Ports. PORT13)
# Motor groups
Lside = MotorGroup(Lfw, Lbw)
Rside = MotorGroup(Rfw, Rbw)
Intake1 = MotorGroup (Intake, HIntake)
#FUNtionG = MotorGroup (Lfw, Lbw, Rfw, Rbw, Intake)
# drivetrain and Controller
Smarty = SmartDrive(Lside, Rside, SeA, 300, 320, 320, MM, 2)
Dictator = Controller (PRIMARY)
#Functions
def DriveF(direction, distance, speed):
Smarty.set_drive_velocity(speed, PERCENT)
Smarty.drive_for(direction, distance, INCHES)
def LefTurn (direction, angle, speed):
Smarty.set_turn_velocity(speed, PERCENT)
Smarty.turn_for(direction, angle, DEGREES)
def IntakeG(direction, angle, speed):
#Intake1.set_velocity(speed, PERCENT)
HIntake.spin_for(direction, angle, DEGREES,speed, PERCENT)
def intake(direction, angle, speed):
#Intake.set_velocity(speed, PERCENT)
Intake.spin_for(direction, angle, DEGREES, speed, PERCENT)
def twoFunc(direction1, distance, speed1, angle, speed2,direction2):
Intake.set_velocity(speed2, PERCENT)
Smarty.set_turn_velocity(speed1, PERCENT)
Smarty.drive_for(direction1, distance, INCHES)
wait=False
Intake.spin_for(direction2, angle, DEGREES)
wait=False
def ThreadFunc(direction, distance, speed):
Smarty.set_drive_velocity(100, PERCENT)
Smarty.drive_for(FORWARD, 80, INCHES)
def ThreadIntake(direction, angle, speed):
Intake.set_velocity(100, PERCENT)
Intake.spin_for(FORWARD, 80, DEGREES)
#Thread1 = threading.Thread(target = ThreadFunc)
#Thread2 = threading.Thread(target = ThreadIntake)
def IntakePis(dare, poop):
Pis1.set(dare)
Pis1.set(poop)
def Clampy (dare):
Pis1.set (dare)
#Competition Code
def pre_autonomous():
while True:
Smarty.set_stopping(BRAKE)
SeA.calibrate()
Smarty.set_turn_constant(1.5)
Smarty.set_turn_threshold(1)
def autonomous():
while True:
#Thread1.start()
#Thread2.start()
#Lfw.set_velocity(100)
#Rfw.set_velocity(100)
#Lbw.set_velocity(100)
#Rbw.set_velocity(100)
#Intake.spin(FORWARD, 100)
#DriveF(REVERSE, 17, 100)
#Clampy(True)
#wait(1000)
#Intake1.spin(FORWARD, 800, PERCENT)
#LefTurn(RIGHT, 70.8, 100)
#wait(3000)
#DriveF(FORWARD, 39, 100)
#wait(2000)
#Intake1.spin(FORWARD, 800, PERCENT)
#DriveF(FORWARD, 25, 100)
#Intake.spin(FORWARD, 800, PERCENT)
#wait(300)
#LefTurn(RIGHT, 137, 100)
#wait(150)
#DriveF(REVERSE, 52, 100)
#Clampy(False)
#DriveF(FORWARD, 36, 100)
Lfw.set_velocity(100)
Rfw.set_velocity(100)
Lbw.set_velocity(100)
Rbw.set_velocity(100)
Intake.spin(FORWARD, 100)
DriveF(FORWARD, 74, 100)
LefTurn(RIGHT, 90, 60)
DriveF(REVERSE, 38.5, 85)
Clampy(True)
IntakeG(FORWARD, 2999, 100)
wait(500)
LefTurn(LEFT, 48, 100)
DriveF(FORWARD, 33.7, 100)
IntakeG(FORWARD, 0, 100)
LefTurn(RIGHT, 40, 100)
DriveF(REVERSE, 60, 85)
wait(5000)
def usercontrol():
while True:
# controller with joy sticks
Lside.set_velocity(Dictator.axis3.position() + Dictator.axis1.position(), PERCENT)
Rside.set_velocity(Dictator.axis3.position() - Dictator.axis1.position(), PERCENT)
Lside.spin(FORWARD)
Rside.spin(FORWARD)
#Buttons
if Dictator.buttonR1.pressing():
Intake1.spin(FORWARD, 100, PERCENT)
elif Dictator.buttonR2.pressing():
Intake1.spin(REVERSE, 100, PERCENT)
else:
Intake1.stop(COAST)
if Dictator.buttonUp.pressing():
Pis1.set(True)
elif Dictator.buttonDown.pressing():
Pis1.set(False)
if Dictator.buttonL1.pressing():
Wall.spin(FORWARD, 100, PERCENT)
elif Dictator.buttonL2.pressing():
Wall.spin(REVERSE, 100, PERCENT)
else:
Wall.stop(HOLD)
comp = Competition(usercontrol, autonomous) #do not touch this