Any user function may run in any order, any number of times. Your code should be designed around this fact.
Common scenario:
- User starts program with controller UNPLUGGED from field control.
- Program starts, VEXos falls back to default competition flags when unplugged (
DRIVER | ENABLED). - Driver control starts.
- User plugs controller into field control.
- Field control places robot into (
DISABLED | AUTONOMOUS). - Robot is disabled until the match starts.
- Match starts, autonomous runs, disabled again, driver runs for the second time.
Simply starting your program before plugging into field control result in user_control()running twice. In reality, it can run any number of times. For example, a radio drop could potentially do weird things to user code, or TM may decide to re-run auto.
The only code guaranteed to run ONCE is main/initialize/pre_auton/etc…
Don’t register persistent callbacks or tasks, or expect any competition handler to run only a single time in a specific order.
See Competition code and user created tasks as well.