The robot randomly freezes during autonomous runs. You can either wait for around a minute and then it carries on, or you can give it a nudge. How do I fix this?
In case it helps, I am using a Version 1 brain with 2.4 gHz radio module, and I code using Vexcode IQ C++
It might be the motors spending a minute trying to get to the correct position before it gives up.
Try setting the motor timeout time to something like 3 seconds. Which means after 3 seconds of the robot trying to turn a motor it gives up and goes onto the next line.
This would be a single line at the start of the program for each motor: motor.setTimeout(3, seconds);
If you do this, you’ll need to turn the robot to get through the gyro turns and vision sensor parts as the code has sections that wait for this to be completed.
Timeouts as suggested by @StuartV seem like the most likely issue here.
Instead of putting your robot on the field and running it, hold it so that the heeled don’t touch the ground. When the robot is supposed to turn using the gyro, just turn the robot in your hands
Then just set your robot down where no wheels touches the ground, and run the program. Does it run as expected? When it is off the ground, does it also stop randomly?
That’s not usually an issue. It only take a second to make most turns, so if it’s taking more than a few seconds than something is probably wrong. When a motor gets stuck, it usually has already competed most of it’s turn and just can’t get the last 5%, such as picking up a game piece.
I had this same problem, but this is an easy fix. Let’s say if the robot is going up against a wall and randomly stops, and your code it says “drive reverse 350mm”. The code will keep running until it completes the step, so if the distance from your robot and the wall is 300, the robot will line up on the wall and stay there until it moves the extra 50mm. To fix this you just make it drive reverse and make it wait a certain amount of seconds and then stop the drivetrain
True, but autonomous isn’t reliable at all, if someone builds an autonomous that can run on any field, then lets say they would probably crush everyone