Does anyone have a simple code that in case you forget to press the button, still works? Sometimes when we disconnect in a match, we can’t move because we don’t select autonomous.
What do you mean by still works? If your auton doesn’t run, in driver control you will automatically be switched to your driver function and should still be able to move.
If you have V5, you can take advantage of the SD Card so your robot will permanently remember its selected auton unless otherwise changed. This will mean that if you dont select an auton it will run the auton you selected previously which is better than nothing.
If you’re using robotc, you can check out my LCD library which has this feature: https://github.com/mannrobo/in-the-zone-B
(Check lib/lcd.c)
Basically, you want to break out of your while loops if you’re connected to competition control:
/**
* Determines if its okay for LCD UI prompts to continue to block execution
*
* If the robot is not connected to competition control, then there is no "dire"
* circumstance, and prompts can block indefinitely. However, if the robot *is*
* connected, then it will only allow prompts to go when the robot is disabled
**/
bool lcdUIOkay() {
return nVexRCReceiveState & vrCompetitionSwitch ? bIfiRobotDisabled : true;
}
I am using the Code Chooser sample program for RobotC
So here is an example I made.
What you need to do is start a task and run the selection in that task. In autonomous just check a variable to see what auton was selected. Also let usercontrol kill the selection task so it isn’t sitting around doing nothing.