1516b Over Under 2.0
Codebase for 1516b over under season
Loading...
Searching...
No Matches
Robot::Autonomous Class Reference

The Autonomous class contains classes and functions related to the robot's autonomous behavior. More...

#include <auton.h>

Public Member Functions

void AutoDrive (Puncher &puncher, bool autono)
 Drives the robot autonomously.
 
void AutonSwitcher ()
 Switches the autonomous program.
 

Static Public Attributes

static int auton = 1
 Sets the number of the autonomous program to use.
 

Private Member Functions

void Auton1 ()
 Runs the autonomous path for the far side defensive game strategy.
 
void Auton2 ()
 Runs the autonomous path for the near side offensive game strategy.
 
void Auton3 (Puncher &puncher)
 Runs the puncher routine for the Skills Challenge.
 

Detailed Description

The Autonomous class contains classes and functions related to the robot's autonomous behavior.

We use Lemlib extensively for our documentation. You can find the documentation for Lemlib at Lemlib documentation.

Definition at line 11 of file auton.h.

Member Function Documentation

◆ AutoDrive()

void Autonomous::AutoDrive ( Puncher & puncher,
bool autono = false )

Drives the robot autonomously.

This function drives the robot autonomously based on the selected autonomous program. It takes a reference to a Puncher object and a boolean value indicating whether to use autonomous mode.

Parameters
puncherA reference to the Puncher object.
autonoA boolean value indicating whether to use autonomous mode.

Definition at line 60 of file auton.cpp.

60 {
61
62 // Keep the switcher running while the controller down button has not been pressed and the time period is not autonomous
63 if (autono == false) {
65 }
66
67 // Compare the current auton value to run the auton routine
68 if(Autonomous::auton == 1){
69 Auton1();
70 }
71
72 if(Autonomous::auton == 2){
73 Auton2();
74 }
75
76 if(Autonomous::auton == 3){
77 Auton3(puncher);
78 }
79
80}
void Auton1()
Runs the autonomous path for the far side defensive game strategy.
Definition auton.cpp:11
static int auton
Sets the number of the autonomous program to use.
Definition auton.h:22
void Auton2()
Runs the autonomous path for the near side offensive game strategy.
Definition auton.cpp:31
void AutonSwitcher()
Switches the autonomous program.
Definition auton.cpp:82
void Auton3(Puncher &puncher)
Runs the puncher routine for the Skills Challenge.
Definition auton.cpp:51

References auton, Auton1(), Auton2(), Auton3(), and AutonSwitcher().

Referenced by autonomous().

◆ Auton1()

void Autonomous::Auton1 ( )
private

Runs the autonomous path for the far side defensive game strategy.

This function executes the autonomous path for the far side defensive game strategy. It contains the specific actions and movements required for this strategy.

Definition at line 11 of file auton.cpp.

11 {
12if(Autonomous::auton == 1){
13 // Autonomous for Far side defensive zone.
14
15 if (pros::c::registry_get_plugged_type(13) == pros::c::E_DEVICE_IMU) {
16 // 36.994 -58.128 0
17 chassis.setPose(36.994, -58.128, 0);
18 chassis.follow("home_side_auton_path_1.txt", 2000, 15);
19 chassis.follow("home_side_auton_path_2.txt", 2000, 15);
20 chassis.follow("home_side_auton_path_3.txt", 2000, 15);
21 chassis.follow("home_side_auton_path_4.txt", 2000, 15);
22 chassis.follow("home_side_auton_path_5.txt", 2000, 15);
23 }
24 else {
25 ;
26
27 }
28}
29}
lemlib::Chassis chassis

References auton, and Robot::Globals::chassis.

Referenced by AutoDrive().

◆ Auton2()

void Autonomous::Auton2 ( )
private

Runs the autonomous path for the near side offensive game strategy.

This function executes the autonomous path for the near side offensive game strategy. It contains the specific actions and movements required for this strategy.

Definition at line 31 of file auton.cpp.

31 {
32 if(Autonomous::auton == 2){
33 // Autonomous for near side offensive zone.
34
35 if (pros::c::registry_get_plugged_type(13) == pros::c::E_DEVICE_IMU) {
36 // -36.851 -58.638 0
37 chassis.setPose(-36.851, -58.638, 0);
38 chassis.follow("far_side_auton_path_1.txt", 2000, 15);
39 chassis.follow("far_side_auton_path_2.txt", 2000, 15);
40 chassis.follow("far_side_auton_path_3.txt", 2000, 15);
41 chassis.follow("far_side_auton_path_4.txt", 2000, 15);
42 }
43 else {
44 ;
45 }
46
47 }
48}

References auton, and Robot::Globals::chassis.

Referenced by AutoDrive().

◆ Auton3()

void Autonomous::Auton3 ( Puncher & puncher)
private

Runs the puncher routine for the Skills Challenge.

This function executes the puncher routine for the Skills Challenge. It takes a reference to a Puncher object and performs the necessary actions for the challenge.

Parameters
puncherA reference to the Puncher object.

Definition at line 51 of file auton.cpp.

51 {
52 // Autonomous routine for the Skills challenge
53 while (true) {
54 puncher.run(Autonomous::auton);
55 }
56
57}
void run(int autonVal)
Runs the puncher based on the given autonomous value.
Definition puncher.cpp:15

References auton, and Robot::Puncher::run().

Referenced by AutoDrive().

◆ AutonSwitcher()

void Autonomous::AutonSwitcher ( )

Switches the autonomous program.

Make sure to pass in a reference to the Puncher object with .

This function switches the autonomous program to the next available program. It allows the user to cycle through different autonomous programs during runtime.

Definition at line 82 of file auton.cpp.

82 {
83
84
85 if(controller.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_RIGHT)) {
86
87
88
90
91 // Checks if the toggler goes out of bounds.
92 if (Autonomous::auton == 4) {
94 }
95
96
97 // Set the controllet text to the current autonomous routine value
98 controller.print(0, 0, "Autonomous prog: %d", Autonomous::auton);
99
100 }
101
102
103
104}
pros::Controller controller

References auton, and Robot::Globals::controller.

Referenced by AutoDrive(), and Robot::Utility::toggleSubsystemOptions().

Member Data Documentation

◆ auton

int Autonomous::auton = 1
static

Sets the number of the autonomous program to use.

This function allows the user to specify the autonomous program to be executed by the robot. The autonomous program number determines the specific actions and movements the robot will perform.

Parameters
autonThe number of the autonomous program to use.

Definition at line 22 of file auton.h.

Referenced by AutoDrive(), Auton1(), Auton2(), Auton3(), and AutonSwitcher().


The documentation for this class was generated from the following files: