You can just add those blocks to your current program. In VEXcode blocks, the “competition template” is just a blank program with “when autonomous” and “when driver control” hat blocks added, nothing else special going on.
This is correct – another way to think about it is that there are 3 states the robot can be in when under competition control:
- Disabled: All motors are stopped; user code can’t move motors or read inputs from controller, but can do other stuff (read from/calibrate sensors, draw to the screen, etc.).
- Autonomous: User code can move motors but can’t read inputs from the controller.
- Driver control: User code can move motors and read inputs from controller.
If you run the program without being connected to a field or competition switch, you’ll start in the driver control state. When you plug into the field before a match, you’ll start in the disabled state, and the tournament manager software will switch all 4 robots into the autonomous and driver control states at the appropriate points in the match (you’ll go back to disabled in between the auton and driver control periods).
The competition switch does the same job as the field control hardware, it’s just controlled by a couple of switches rather than by tournament manager.
The “when started” hat block starts running when the program is started, regardless of what state the robot is in. The “when autonomous” hat block starts running when the robot enters the autonomous state. The “when driver control” hat block starts running when the robot enters the driver control state. When you switch into the disable state, any stacks under “when autonomous” or “when driver control” hats are stopped.
More on how field control works in this thread: