Can someone give me an example of what code you would put in pre-autonomous? I know what it is used for, I just don’t know how to use it. Thanks.
Most teams put autonomous selection code in there. If you do put code in there make sure than you can skip it if the robot restarts during a match.
You use it by checking a pot or a button on your robot to decide which autonomous.
Setting up/calibrating the gyro is the typical item found in pre_auton.
Reading an autonomous selector and outputting some LED lights or to the LCD screen is another popular use. Yes, you can do that in autonomous, but you get feedback via LED/LCD prior to switching auton on, it can be beneficial.
(Responding to General Reggie) - What would be the benefit of putting the autonomous selection code in pre-autonomous rather then the regular autonomous section? (I don’t have an LCD for autonomous selection, just a potentiometer.)
For a potentiometer, there isn’t really any benefit, unless you have some sort of feedback system such as a set of LEDs or a speaker. That is because the easiest (and probably best) way to choose which autonomous to run would be to check the state of the potentiometer at the very beginning of autonomous.
On the other hand, with the LCD display, the only way to select an autonomous is by pressing the buttons below the display. Usually teams select their autonomous before the autonomous mode begins, so the presses would need to be read during pre-autonomous. However, there are still benefits of at least having the option to wait until the autonomous mode begins to select which autonomous to run.
When I was on a team we had two pots, one for skipping the selection and one that would decide which autonomous would run. It is mostly used with LCD like Team80_Giraffes stated. Both pre auto and in auto would work. Seeing what auto will run helps to not make mistakes in high pressure matches.
Okay, thanks for the quick responses!
Like this.