Autonomous failure

I have a fully functioning autonomous but it has started to stop halfway through, sometimes it completes the code but most of the time it stops. We’ve tried re-downloading the code and resetting the brain but it doesnt seem to be helping. We’ve also checked the functions for the auton but they are correct. What should we do?

Post the code here. Sometimes when code stops in the middle it is because you set an encoder goal and the robot, for one reason or another, is unable to reach that encoder number. This can hang up a program. Of course, there are many other reasons your auton could stop in the middle - but that is a common cause.


But sometimes the autonomous runs through the whole code, it’s only sometimes it stops halfway through.

Well, imagine this (surprisingly common) scenario:
You code a gyro-based turn function that uses progressive slowdown as it approaches the target heading. Kind of

while (err > 0) { setLeft(-err); setRight(err); err = gyro.getHeading() - target; }

As you see, at one degree from the target, it uses power of one (which wouldn’t really move the motors at all. Now, most of the time, a robot would have enough momentum at the end of the turn to finish it w/o motor power. But sometimes, it won’t for some reason (bumping into something, more friction, …). This is but a sample, It could be driving straight, raising arm, whenever your code waits for some condition to happen.

Besides static code inspection for similar patterns, you could also try to pinpoint the exact statement where it stops by adding debug printouts (on the display or over the console).

Another approach, if you version your code properly is to try rolling back the code to one of the older versions and see if you can reproduce the problem (which might be a little harder given it’s random nature).


We think we’ve figured out our problem, our motors were somehow tourqing out because they were hitting hard stops on the robot. Thank you so much for your help with trying to figure this out with me