Robot freezes between two lines of code

Every time I run my code, the robot freezes with the touch LED set to red. The robot becomes unresponsive, the program cannot be exited by pressing the X button, and the only way to turn off the robot is by taking out the battery. The brain displays no error message.

Screenshot 2020-06-29 at 10.07.53 PM
These are the only 2 blocks of code that set the touch LED.

Here’s my code: https://drive.google.com/file/d/1V4q2k7V1eP-ymJbWWryMPFhY1tOQpcwP/view?usp=sharing (I can’t upload it directly since I’m a new user.)

The code that sets the touch LED is in a loop. When running the code, sometimes the LED cycles between red and purple before freezing on red. Other times, the robot freezes immediately on red.

I have reproduced this error on another VEX IQ robot with the same configuration. Both robots have up-to-date firmware.

This issue has been really confusing for me. To those who see this thread, thank you so much in advance for your time and help!

@jpearman

2 Likes

I will see if I can reproduce the error tomorrow. That’s a big program and the IQ is tight on resources, it may be a memory related issue.

4 Likes

I did look into this to see what is happening, unfortunately it is a memory related problem, you have a pretty big program with a few levels of nested MyBlocks as well as use of the vision sensor. There’s not much we can do fix this with the current release of VEXcode, however, the release due later this month I believe will allow your code to run without issue… just.

6 Likes

Thank you for your help! I’ll try simplifying the code to try to get it to work. Are there any specific memory-intensive things I should avoid with the vision sensor or MyBlocks?

There’s probably not too much you can do. We knew the vision sensor was using too much memory in the current release, but it wasn’t competition legal and so generally was used in simple programs, that changed with recent updates to the game manual. You have good structure to the code and changing too much will destroy that, it would help to have less levels of MyBlocks, but I suspect not enough. You could perhaps trigger some of the code using events and then wait for that code to complete (broadcastAndWait), that will run the code in another thread which has its own area of memory. Perhaps try that with the far right MyBlock code that is using take snapshot.

4 Likes

Here’s a version of the program that substitutes events for two of the myblock functions. I had to create three new global variables (booleans) to be able to pass the parameters to the events. I have not analyzed memory use for this code, but it does seem to work, at least superficially.

RoombaCubesR1.iqblocks (62.7 KB)

3 Likes