1516X High Stakes 2.0
Codebase for 1516X High Stakes 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 Types

enum  AUTON_ROUTINE {
  RED_LEFT = 1 , RED_RIGHT = 2 , BLUE_LEFT = -1 , BLUE_RIGHT = -2 ,
  SKILLS = 0
}
 

Public Member Functions

void AutoDrive (Intake &intake, Latch &latch)
 Drives the robot autonomously.
 

Static Public Member Functions

static void AutonSwitcher (int autonNum)
 Switches the autonomous program.
 

Static Public Attributes

static AUTON_ROUTINE auton = RED_LEFT
 Sets the number of the autonomous program to use.
 
static std::string autonName
 The name of the autonomous program.
 

Private Member Functions

void Auton1 (Intake &intake, Latch &latch)
 Runs the autonomous path for the far side defensive game strategy.
 
void Auton2 (Intake &intake, Latch &latch)
 Runs the autonomous path for the near side offensive game strategy.
 
void Auton3 (Intake &intake, Latch &latch)
 Runs the puncher routine for the Skills Challenge.
 
void Auton4 (Intake &intake, Latch &latch)
 Runs the autonomous path for the far side offensive game strategy. This function executes the autonomous path for the far side offensive game strategy. It contains the specific actions and movements required for this strategy.
 
void Auton5 (Intake &intake, Latch &latch)
 

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 14 of file auton.h.

Member Enumeration Documentation

◆ AUTON_ROUTINE

Enumerator
RED_LEFT 
RED_RIGHT 
BLUE_LEFT 
BLUE_RIGHT 
SKILLS 

Definition at line 16 of file auton.h.

Member Function Documentation

◆ AutoDrive()

void Autonomous::AutoDrive ( Intake & intake,
Latch & latch )

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 108 of file auton.cpp.

109{
110 // Keep the switcher running while the controller down button has not been pressed and the time period is not
111 // autonomous Compare the current auton value to run the auton routine
112 switch (Autonomous::auton) {
113 case RED_LEFT:
114 Auton1(intake, latch);
115 break;
116 case RED_RIGHT:
117 Auton2(intake, latch);
118 break;
119 case BLUE_LEFT:
120 Auton3(intake, latch);
121 break;
122 case BLUE_RIGHT:
123 Auton4(intake, latch);
124 break;
125 case SKILLS:
126 Auton5(intake, latch);
127 break;
128 }
129}
void Auton4(Intake &intake, Latch &latch)
Runs the autonomous path for the far side offensive game strategy. This function executes the autonom...
Definition auton.cpp:88
void Auton1(Intake &intake, Latch &latch)
Runs the autonomous path for the far side defensive game strategy.
Definition auton.cpp:23
void Auton2(Intake &intake, Latch &latch)
Runs the autonomous path for the near side offensive game strategy.
Definition auton.cpp:53
static AUTON_ROUTINE auton
Sets the number of the autonomous program to use.
Definition auton.h:26
void Auton3(Intake &intake, Latch &latch)
Runs the puncher routine for the Skills Challenge.
Definition auton.cpp:80
void Auton5(Intake &intake, Latch &latch)
Definition auton.cpp:102

References auton, Auton1(), Auton2(), Auton3(), Auton4(), Auton5(), BLUE_LEFT, BLUE_RIGHT, RED_LEFT, RED_RIGHT, and SKILLS.

Referenced by autonomous().

◆ Auton1()

void Autonomous::Auton1 ( Intake & intake,
Latch & latch )
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 23 of file auton.cpp.

24{
25 chassis.setPose(-148.132, -58.408, 190);
26 // robot backs up into wallstake and is ready to outake
27 chassis.follow(red_right_pt1_txt, 15, 5000);
28
29 intake.score();
30 intake.toggle();
31 // robot moves forward and intakes red ring on top of stack
32 chassis.follow(red_right_pt2_txt, 15, 5000);
33
34 // robot moves backward and stops at mobile goal. ready to latch and outake
35 // ring
36 chassis.follow(red_right_pt3_txt, 15, 5000);
37 latch.toggle();
38 intake.score();
39 intake.toggle();
40
41 // robot drags mobile goal and intakes bottom of ring of 2ring stack then
42 // stops. ready to outake to mobile goal
43 // then unlatches mobile goal
44 chassis.follow(red_right_pt4_txt, 15, 5000);
45 intake.score();
46 latch.toggle();
47
48 // robot ends in contact with tower
49 chassis.follow(red_right_pt5_txt, 15, 5000);
50}
void score()
Outakes alliance rings into latched mobile goal and ejects enemy rings.
Definition intake.cpp:35
void toggle()
Toggles intake elevation.
Definition intake.cpp:29
void toggle()
Toggles latch state.
Definition latch.cpp:16
lemlib::Chassis chassis(drivetrain, lateral_controller, angular_controller, sensors, &throttle_curve, &steer_curve)

References Robot::Globals::chassis(), Robot::Intake::score(), Robot::Intake::toggle(), and Robot::Latch::toggle().

Referenced by AutoDrive().

◆ Auton2()

void Autonomous::Auton2 ( Intake & intake,
Latch & latch )
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 53 of file auton.cpp.

54{
55 chassis.setPose(-146.76, 63.046, 10);
56 // robot backs up into wallstake and is ready to outake
57 chassis.follow(red_left_pt1_txt, 15, 5000);
58 intake.score();
59 intake.toggle();
60
61 // robot moves and intakes ring from top of 2ring stack.
62 chassis.follow(red_left_pt2_txt, 15, 5000);
63 intake.toggle();
64
65 // robot moves backward toward mobile goal. Ready to latch then score.
66 chassis.follow(red_left_pt3_txt, 15, 5000);
67 latch.toggle();
68 intake.score();
69
70 // robot turns around and intakes ring from bottom of 2ring stack.
71 chassis.follow(red_left_pt4_txt, 15, 5000);
72 intake.score();
73 latch.toggle();
74
75 // robot ends in contact with mobile goal
76 chassis.follow(red_left_pt5_txt, 15, 5000);
77}

References Robot::Globals::chassis(), Robot::Intake::score(), Robot::Intake::toggle(), and Robot::Latch::toggle().

Referenced by AutoDrive().

◆ Auton3()

void Autonomous::Auton3 ( Intake & intake,
Latch & latch )
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 80 of file auton.cpp.

81{
82}

Referenced by AutoDrive().

◆ Auton4()

void Autonomous::Auton4 ( Intake & intake,
Latch & latch )
private

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

Todo
Make the autonomous more fleshed out, building it properly for the competition

Definition at line 88 of file auton.cpp.

89{
90 chassis.setBrakeMode(pros::E_MOTOR_BRAKE_BRAKE);
91
92 chassis.setPose(0, 0, 0);
93 // move 48" forwards
94 chassis.moveToPoint(0, 72, 3500, { .maxSpeed = 110 }, true);
95 chassis.turnToHeading(180, 1000, { .maxSpeed = 90 }, false);
96
97 chassis.setPose(0, 0, 0);
98 chassis.moveToPoint(0, 24, 1000, { .maxSpeed = 110 });
99 chassis.turnToHeading(0, 1200, { .maxSpeed = 110 }, false);
100}

References Robot::Globals::chassis().

Referenced by AutoDrive().

◆ Auton5()

void Autonomous::Auton5 ( Intake & intake,
Latch & latch )
private

Executes the Skills challenge autonomous.

This function controls the robot's actions during autonomous routine 5. It takes references to the Intake and Latch objects as parameters.

Parameters
intakeThe reference to the Intake object.
latchThe reference to the Latch object.

Definition at line 102 of file auton.cpp.

103{
104 // Autonomous routine for the Skills challenge
105}

Referenced by AutoDrive().

◆ AutonSwitcher()

void Autonomous::AutonSwitcher ( int autonNum)
static

Switches the autonomous program.

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 131 of file auton.cpp.

132{
133 switch (autonNum) {
134 case 1:
135 Autonomous::autonName = "Red Left";
137 break;
138 case 2:
139 Autonomous::autonName = "Red Right";
141 break;
142 case -1:
143 Autonomous::autonName = "Blue Left";
145 break;
146 case -2:
147 Autonomous::autonName = "Blue Right";
149 break;
150 case 0:
151 Autonomous::autonName = "Skills";
153 }
154 std::cout << "Current auton: " + Autonomous::autonName << std::endl;
155}
static std::string autonName
The name of the autonomous program.
Definition auton.h:33

References auton, autonName, BLUE_LEFT, BLUE_RIGHT, RED_LEFT, RED_RIGHT, and SKILLS.

Member Data Documentation

◆ auton

Autonomous::AUTON_ROUTINE Autonomous::auton = RED_LEFT
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 26 of file auton.h.

Referenced by AutoDrive(), and AutonSwitcher().

◆ autonName

std::string Autonomous::autonName
static

The name of the autonomous program.

This variable stores the name of the autonomous program currently selected. It is handled by the switching functions and the screen.

Definition at line 33 of file auton.h.

Referenced by AutonSwitcher().


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