New Robot Error

We are running into a new error. Attached is the video and code we are using. We are using Robot Mesh Studio to code and upload onto the cortex directly. The cortex and the joystick both have up to date firmware and have been successfully paired. I cannot seem to match this particular light error with the troubleshooting flowcharts available.

Thank you for your help

VEX EDR Python-Project with Competition Template

import sys
import vex

#region config
right = vex.Motor(1, True)
armRightTop_ = vex.Servo(2)
armLeft = vex.Servo(3)
armRight = vex.Servo(5)
clawFlipLeft = vex.Servo(7)
clawFlipRight = vex.Servo(8)
armLeftTop = vex.Servo(9)
Left = vex.Motor(10)
joystick = vex.Joystick()
#endregion config

def driver():

while True:
    left.run(joystick.axis3())
    right.run(joystick.acis2())
    
    alpu = 0
    arpu = 360
    artpu = 360
    altpu = 0
    
    alpd = 360
    arpd = 0
    artpd = 0
    altpd = 360
    
    cflu = 0
    cfru = 360
    
    cfld = 360
    cfrd = 0
    
    while (joystick.b6up() == True):
        
        alpu = alpu + 10
        arpu = arpu - 10
        artpu = artpu - 10
        altpu = altpu + 10
        
        timer.Timer.start()
        while (timer.Timer.elapsed_time() <= .25):
            armLeft.position(alpu)
            armRight.position(arpu)
            armRightTop_.position(artpu)
            armLeftTop.position(altpu)
        timer.Timer.stop()
        
        
    while (joystick.b6down() == True):
        
        alpd = alpd - 10
        arpd = arpd + 10
        artpd = artpd + 10
        altpd = altpd - 10
        
        timer.Timer.start()
        while (timer.Timer.elapsed_time() <= .25):
            armLeft.position(alpd)
            armRight.position(arpd)
            armRightTop_.position(artpd)
            armLeftTop.position(altpd)
        timer.Timer.stop()
        
        
    while (joystick.b5up() == True):
        
        cflu = cflu + 10
        cfru = cfru - 10
        
        timer.Timer.start()
        while (timer.Timer.elapsed_time() <= .25):
            clawFlipLeft.position(cflu)
            clawFlipRight.position(cfru)
        timer.Timer.stop()
        
        
    while (joystick.b5down() == True):
        
        cfld = cfld - 10
        cfrd = cfrd + 10
        
        timer.Timer.start()
        while (timer.Timer.elapsed_time() <= .25):
            clawFlipLeft.position(cfl)
            clawFlipRight.position(cfr)
        timer.Timer.stop()
            
    
    pass

vex.run_driver(driver)
NewroboGlitch.zip (39.5 MB)

Your code has encountered an exception. If you run the code with the Programming Hardware Cable connected to the computer, then an error will likely be echoed back to the console in the Robot Mesh Studio environment (in the console pane at the bottom).

Reading through your code, there are a couple of errors which standout:

  1. On this line

right.run(joystick.acis2())

there is a typo


acis2()

is incorrect, I assume you mean axis2()

  1. You need an instance of the Timer class. I’ve published an example at http://www.robotmesh.com/studio/100787

I’m not sure where your loops end, if you copy/paste the code into the forum, use the code tags to retain the indentation, or make your project public (in the Options) on Robot Mesh Studio and share the link. Note that the servos don’t need to be continually commanded to go to a particular position in a loop.

Since you’re running the


driver

function with


vex.run_driver(driver)

you will need to have a VEX Competition Switch attached to your joystick and switched to Enable & Driver for the code in the driver thread to run.

Thank you for your help, here is the adjusted code in the proper format.

# VEX EDR Python-Project with Competition Template
import vex
import timer

#region config
right         = vex.Motor(1, True)
armRightTop_  = vex.Servo(2)
armLeft       = vex.Servo(3)
armRight      = vex.Servo(5)
clawFlipLeft  = vex.Servo(7)
clawFlipRight = vex.Servo(8)
armLeftTop    = vex.Servo(9)
Left          = vex.Motor(10)
joystick      = vex.Joystick()

mytimer = timer.Timer()
#endregion config


def driver():
    
    while True:
        left.run(joystick.axis3())
        right.run(joystick.axis2())
        
        alpu = 0
        arpu = 360
        artpu = 360
        altpu = 0
        
        alpd = 360
        arpd = 0
        artpd = 0
        altpd = 360
        
        cflu = 0
        cfru = 360
        
        cfld = 360
        cfrd = 0
        
        while (joystick.b6up() == True):
            
            alpu = alpu + 10
            arpu = arpu - 10
            artpu = artpu - 10
            altpu = altpu + 10
            
            mytimer.start()
            while (mytimer.elapsed_time() <= .25):
                armLeft.position(alpu)
                armRight.position(arpu)
                armRightTop_.position(artpu)
                armLeftTop.position(altpu)
            mytimer.stop()
            mytimer.reset()
            
            
        while (joystick.b6down() == True):
            
            alpd = alpd - 10
            arpd = arpd + 10
            artpd = artpd + 10
            altpd = altpd - 10
            
            mytimer.start()
            while (mytimer.elapsed_time() <= .25):
                armLeft.position(alpd)
                armRight.position(arpd)
                armRightTop_.position(artpd)
                armLeftTop.position(altpd)
            mytimer.stop()
            mytimer.reset()
            
        while (joystick.b5up() == True):
            
            cflu = cflu + 10
            cfru = cfru - 10
            
            mytimer.start()
            while (mytimer.elapsed_time() <= .25):
                clawFlipLeft.position(cflu)
                clawFlipRight.position(cfru)
            mytimer.stop()
            mytimer.reset()
            
            
        while (joystick.b5down() == True):
            
            cfld = cfld - 10
            cfrd = cfrd + 10
            
            mytimer.start()
            while (mytimer.elapsed_time() <= .25):
                clawFlipLeft.position(cfl)
                clawFlipRight.position(cfr)
            mytimer.stop()
            mytimer.reset()
                
        
        pass

vex.run_driver(driver)

I understand that they do not need to be continuously running but I would like them to start and stop as I press the buttons with minimal delay. Is there a more efficient way to do this?

Additionally, if I take out the vex.run_driver will I be able to drive without the vex enabler switches?

To test without the Competition Switch you can replace the call at the end to:

# vex.run_driver(driver)
driver()

Just remember to put the original call back in before competition and test with a competition switch

If you just want the servos to move in steps you could simply use a delay (a sleep) instead of the timer so instead of:

            mytimer.start()
            while (mytimer.elapsed_time() <= .25):
                armLeft.position(alpd)
                armRight.position(arpd)
                armRightTop_.position(artpd)
                armLeftTop.position(altpd)
            mytimer.stop()
            mytimer.reset()

Simply use:

            armLeft.position(alpd)
            armRight.position(arpd)
            armRightTop_.position(artpd)
            armLeftTop.position(altpd)
            sys.sleep(0.25)

Thank you for your advice thus far. You have been incredibly helpful. I have a few additional questions.

Is there a way for the servos to continually run so they do not just move to a specified location? Because of the way my gear ratios are set, the servo will need to rotate more than 360 degrees.

@Weehawken Robotics Servos only rotate 180 degrees. If they move further then the servo is broken

If you are using the official VEX Servo, it is, as bwilfong wrote, a limited range device that will not spin 360 degrees. Here are the product specifications for the 3-Wire Servo:

Rotation:100 degrees
Stall Torque:6.5 in-lbs
Voltage:4.4 - 9.1 Volts (Motor life will be reduced operating outside this range)
PWM Input:1ms - 2ms will give full reverse to full forward, 1.5ms is neutral
Black Wire:Ground
Orange Wire:Power
White Wire:PWM signal
Current Draw:20mA to 1.5 A per Servo
Max Power:4.9 W when rated @ 6V