Writing Autons
- Go to
\include\autons.h
and add your auton using the formatvoid my_first_auton();
. This is called the function declaration. - Go to
\src\autons.cpp
and add your auton using the following format:
void my_first_auton(){
}
Your code will go within the brackets. For example:
void my_first_auton(){
chassis.drive_distance(12);
chassis.turn_to_angle(90);
chassis.drive_distance(12);
chassis.drive_distance(-12);
chassis.turn_to_angle(0);
chassis.drive_distance(-12);
}
This code should drive in an L shape and return to its start along the same path, and this segment of code is the function's definition.
- Go to
\src\main.cpp
and scroll to thevoid pre_auton()
function. Pick a case (in this example we'll pick 0) and change the name of the auton displayed on the brain screen in auton selection. The code will look like
case 0:
Brain.Screen.printAt(5, 140, "My First Auton");
break;
- In
\src\main.cpp
, scroll to thevoid autonomous()
function. Using the same case you picked in step 3, change the auton function called within that case. The code will look like
case 0:
my_first_auton();
break;
- Test your auton. If you chose case 0, this is the default auton and you don't have to select the correct auton from the brain screen. For other cases, you'll need to tap on the brain screen in pre auton until you reach the desired auton.