Drive Train not driving

My robot is not driving and I have tried so many different options such as checking what ports they are connected to, or checking my controlller connection. The autnomous will work just fine but whenever I try to drive to via controller, it will not move.


from vex import *


# Brain should be defined by default
b = Brain()
c = Controller()
lt = Motor(Ports.PORT4, GearSetting.RATIO_6_1, False)
lb = Motor(Ports.PORT1, GearSetting.RATIO_6_1, True)
rt = Motor(Ports.PORT3, GearSetting.RATIO_6_1, True)
rb = Motor(Ports.PORT2, GearSetting.RATIO_6_1, False)

it = Motor(Ports.PORT5, GearSetting.RATIO_6_1, True)
arm = Motor(Ports.PORT6, GearSetting.RATIO_6_1, True)

lp = Pneumatics(b.three_wire_port.a)
rp = Pneumatics(b.three_wire_port.a)

lt.spin(FORWARD, c.axis2.position(), PERCENT)
lb.spin(FORWARD, c.axis2.position(), PERCENT)
rt.spin(FORWARD, c.axis3.position(), PERCENT)
rb.spin(FORWARD, c.axis3.position(), PERCENT)

def move (direction, speed):
    lt.spin(direction, speed, PERCENT)
    lb.spin(direction, speed, PERCENT)
    rt.spin(direction, speed, PERCENT)
    rb.spin(direction, speed, PERCENT)

def stop():
    lt.stop(BRAKE)
    lb.stop(BRAKE)
    rt.stop(BRAKE)
    rb.stop(BRAKE)

def turn (direction1, velocity1, direction2, velocity2):
    # Left side motors
    lt.spin(direction1, velocity1, RPM)
    lb.spin(direction1, velocity1, PERCENT)
    # Right side motors
    rt.spin(direction2, velocity2, PERCENT)
    rb.spin(direction2, velocity2, PERCENT)

def climb():
    lp.open()
    rp.open()

def autonomous():
    turn(FORWARD, 100, FORWARD, 50)
    wait(200)
    stop()

def drive():
    # Drive
    lt.spin(FORWARD, c.axis2.position(), PERCENT)
    lb.spin(FORWARD, c.axis2.position(), PERCENT)
    rt.spin(FORWARD, c.axis3.position(), PERCENT)
    rb.spin(FORWARD, c.axis3.position(), PERCENT)

comp = Competition(drive, autonomous)

Your motor movement functions are not in a loop; they will run once and then exit.

1 Like

I think @pmkv’s solution is the answer, but I also have a slight improvement:
c.axis2.position() has the range -127 to 127, while PERCENT is -100 to 100, so that means the last 20% of the controller is useless. You can change that by multiplying by 100/127 to the range.

1 Like

Oh, did they update it? I might be mistaken, but that is a C++ link while GBambam is using python.

https://api.vex.com/v5/home/python/Controller/Controller.Axis.html

position() has always been +/~ 100. value() is +/~ 127. That may not be available on Python, I forget.

1 Like