While loops in initialize


I am creating an autonomous selector using the V5 screen. I have the code inside a while() loop in competition_initialize(). When autonomous begins, will it automatically exit this loop and run the autonomous code, or do I need to add something to manually exit the loop when the match begins?

Also, what is the difference between initialize() and competition_initialize()? I know the auto selector is supposed to go inside competition_initialize(), but how is initialize() different and what type of commands are meant to go there?

Thanks for any help!



from the PROS documentation:

Neither autonomous nor driver control code starts:

The initialize() function may still be running. Some tasks such as analog_calibrate take time.

If the initialize() function implements some type of loop or autonomous selection routine, verify that it actually has a means of ending.


 * Runs after initialize(), and before autonomous when connected to the Field
 * Management System or the VEX Competition Switch. This is intended for
 * competition-specific initialization routines, such as an autonomous selector
 * on the LCD.
 * This task will exit when the robot is enabled and autonomous or opcontrol
 * starts.
void competition_initialize() {}


Here’s a link to my team’s auton changer code. Also we did not use competition initialize.

Initialize file

Autonomous file

To answer your general question, competition initialize is the exact same thing as pre-auton and runs before the match begins. We didn’t use competition initialize, so our auton changer code always runs. You just toggle to the right autonomous and it will set your auton and when you start the auton period, it will run that selected auton (no need for center button)