Issues with 3 teams on Python

So I have 3 teams, all having the same issues, all motors that go in reverse glitches, so turning left, and turning right, the motors programmed for reverse glitch while in motion.

Could someone shed some light? I sent 2 feedbacks with my personal email (redacted)

Heres a copy of her code:

# ---------------------------------------------------------------------------- #
#                                                                              #
# 	Module:       main.py                                                      #
# 	Author:       Sheon Catlett                                                #
# 	Created:      Thu Aug 31 20223                                             #
# 	Description:  VEX Competition Template WIS                                 #
#                                                                              #
# ---------------------------------------------------------------------------- #

# Library imports
from vex import *

# Brain should be defined by default
brain=Brain()

# Robot Configuration Code
Lfw = Motor(Ports.PORT20, GearSetting.RATIO_18_1,True)
Rfw = Motor(Ports.PORT13, GearSetting.RATIO_18_1,False)
Lbw = Motor(Ports.PORT10, GearSetting.RATIO_18_1,True)
Rbw = Motor(Ports.PORT3, GearSetting.RATIO_18_1,False)
Claw = Motor(Ports.PORT19, GearSetting.RATIO_18_1,True)
FlyW = Motor(Ports.PORT8, GearSetting.RATIO_6_1, True)
SeA = Inertial(Ports.PORT2)



# Motor groups

LSide = MotorGroup(Lfw,Lbw)
RSide = MotorGroup(Rfw,Rbw)



# drivetrain and Controller

Smarty = SmartDrive(Lbw, Rbw, SeA, 300, 320, 320, MM, 1.9)
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.turn_to_heading( direction, angle, DEGREES)
    Smarty.set_turn_velocity(speed, PERCENT)

def Claw1(direction, angle, speed):
    Claw.spin_for(direction, angle, DEGREES)
    Claw.set_velocity(speed, PERCENT)

def WheelF(direction, time, speed):
    FlyW.spin_for(direction, time, SECONDS)
    FlyW.set_velocity(speed, PERCENT)

    

#Competition Code


def pre_autonomous():
    while True:
        Smarty.set_stopping(COAST)
        SeA.calibrate()
        Smarty.set_turn_constant(1.5)
        Smarty.set_turn_threshold(1)
def autonomous():
    while True:
        DriveF(REVERSE, 50, 100)

   
        wait(15000)
def usercontrol():
    while True:
        Claw.set_velocity(100, PERCENT)
        LSide.set_velocity(85, PERCENT)
        RSide.set_velocity(85, PERCENT)
        FlyW.set_velocity(100, PERCENT)
        Smarty.set_stopping(COAST)
        # controller with joy sticks
        Lbw.set_velocity((Dictator.axis3.position() + Dictator.axis1.position()),PERCENT)
        Rbw.set_velocity((Dictator.axis3.position() - Dictator.axis1.position()),PERCENT)
        Lfw.set_velocity((Dictator.axis3.position() + Dictator.axis1.position()),PERCENT)
        Rfw.set_velocity((Dictator.axis3.position() - Dictator.axis1.position()),PERCENT)
        Lbw.spin(FORWARD)
        Rbw.spin(FORWARD)
        Lfw.spin(FORWARD)
        Lbw.spin(FORWARD)

        #Buttons
        if Dictator.buttonR1.pressing():
            Claw.spin(REVERSE)
        elif Dictator.buttonR2.pressing():
            Claw.spin(FORWARD)
        else:
            Claw.stop(COAST)

        if Dictator.buttonUp.pressing():
            FlyW.spin(REVERSE)
        elif Dictator.buttonDown.pressing():
            FlyW.spin(FORWARD)
        else:
            FlyW.stop(COAST)

        
comp = Competition(usercontrol, autonomous) #do not touch this

type or paste code here

Friday night, no one working in support.
We also do not generally deal with coding problems via feedback.

I suspect the issue is due to using set_velocity while some motors have been commanded to run in reverse, I would suggest rewriting without using the set_velocity followed by spin pattern and instead pass required velocity as a parameter to spin.

3 Likes

more insight into setVelocity here, not exactly related to you problem but worth reading.

5 Likes

Sorry I was going off of what I remembered from C++ in vexcode, we usually loaded set velocities at the beginning of user control.

Thanks again, you saved 3 of my teams from failing at today’s tournament, I’m sorry I thought it was a glitch within VSCode