-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Pressing the stop button starts the program #677
Comments
Was this an Auto program, written using LinearOpMode ? If you have a waitForStart(), followed by some autonomous driving, and you don't have a check to see if the user pressed start or stop before running your auto code, it may drive for up to 2 seconds before the failsafe kicks in. The problem is, if the user presses stop, waitForStart() will return, but it's up to your code to actually abort the autonomous sequence. In all our auto opmodes, after the waitForStart() call, we always put our driving code inside a big IF.. waitForStart(); This way, if the driver presses stop, before play, waitForStart() will return, and then the code will check to see if the opmode is really active, or whether it needs to exit immediately. |
We don't do the if(opModeIsActive). We just have all loops include && opModeIsActive. We may have the bot twitch, but other than that nothing. |
Interesting solution, but it is probably not a good solution from a UX point of view. I'll have to try it anyway. |
Another way to do it is to put a test just after the waitForStart() that returns immediately if stop has been pressed instead of play waitForStart(); I personally don't like this approach because back in the day, when I was learning to program, it was frowned on to have more than one exit point from a function or method. I also prefer the big if() because it ensure no further movement, and it provides the opportunity to do any shutdown after the if() to clean up anything that was started (like vision processing) before the waitForStart(). It's just a sign of more thoughtful programming to prevent your auto code running when the user decides to abort before hitting play. If you just let the program run, and hope for the while loops to terminate quickly, it won't stop other things like servo movement which might unlatch an arm or winch, which then may need to be reset. |
After initializing the program, one member of my team decided to cancel it. When he pressed stop, the program started. It seems to act this way consistently.
The text was updated successfully, but these errors were encountered: