Program not working

We are having a problem where the program isn’t running anything. Our pre autonomous runs but nothing else in the whole program will. We spent hours looking through it but can’t find anything.
Our program is in python so we’re not sure if it is spacing or anything else.

Here is the link to our program:

Your project is private. For others to see your code, you will need to set it to public through the Options gear at the top right.

Fixed that. I must have forgot that it was still private

You enter a blocking loop on line 346 and your competition functions are never registered (lines 406 and 407).

Looks like the your drivercontrol function may have gotten mangled, as there’s nothing in it but a blocking loop that just repeatedly sets some variables to 0.

1 Like

@John_TYler - wondering if you saw code before some changes were made to it? I can only see 395 lines in the present online code. So perhaps the issue you point out was already fixed…

What I found in the code is that it is mixing tabs and spaces, which is not allowed in python generally. Due to the exceptionally weak lint check that RobotMesh Studio has, it does not complain at all. This is a bug which should be fixed, Vex!! (Students: Lint checking is a part of a standard software tool flow that looks for silly mistakes we all make - missing semi-colons, brackets, etc. Its designed to help us find syntactical errors in our code. Really good lint checkers are capable of finding simple programatic errors too. They are REALLY helpful!)

The specific issue is in the def drivercontrol(): currently residing from lines 334-384. Using a modern IDE which allows to see invisibles, you can clearly see tabs and spaces mixed. Remove the tabs and replace with FOUR spaces, and the code will most likely work.

If you ever wonder if your code has this issue a really simple way is to check using python3 on your Mac or PC from a terminal window. you can literally type python3 and it will respond with something like:

  File "", line 338
    drive_right_power = 0
TabError: inconsistent use of tabs and spaces in indentation

(note the ^ does not show the correct place in this post because its not a monospace font. The part that matters is the “TabError” line.)

If a program does not have this issue, it will likely instead fail looking for the vex lib since I do not have that installed in my Python install. e.g. :

Traceback (most recent call last):
File “”, line 3, in
import vex
ModuleNotFoundError: No module named ‘vex’

You can use python3 as a lint check that Robot Mesh Studio ought to be doing for you.

Students: There is an important and not so obvious lesson here. Some editors default to using tabs when you edit code. Some convert your spaces to tabs. Some convert your tabs to spaces. Most leave your code alone. If you copy and paste code outside of Robot Mesh Studio, it may make changes like this to your code and you will likely never see them. Make sure you check your code for proper syntax before you paste it back in. In particular, if your editor you are using allows you to show invisibles, that is a great way to visually check.

An even better way is to be able to search for tabs. That can often be done by searching for \t in your find window. If you find any tabs, replace them with FOUR spaces. We engineers have developed strategies like these to avoid these kinds of issues - because we have been burned by them. ;). BTW - I did try that in Robot Mesh Studio and \t does not work in the search window.

Good luck at State teams!

Hope that helps

We fixed the indentation to spaces, got rid of the second while loop in the driver control function, and looked trough pretty much everything else.
Here’s the updated version:

We’re still in the same position where nothing works when we enter the program. We have states on Saturday and need some help fast

You use the motor “cube_slide” on lines 351 and 353 but have no motor declared with that name.

Would that prevent the rest of the driver control function from working?

Yes, it crashes the interpreter with a Name Error. When you have problems like this I recommend running the program from the computer so that you get console output, which would have shown you the name error and line where it failed.

Thank you so much. I appreciate your time

1 Like