1516X High Stakes 2.0
Codebase for 1516X High Stakes season
Loading...
Searching...
No Matches
auton.cpp
Go to the documentation of this file.
1#include "robot/auton.h"
2#include "main.h" // IWYU pragma: export
3
4using namespace Robot;
5using namespace Robot::Globals;
6
8std::string Autonomous::autonName;
9
10ASSET(red_right_pt1_txt);
11ASSET(red_right_pt2_txt);
12ASSET(red_right_pt3_txt);
13ASSET(red_right_pt4_txt);
14ASSET(red_right_pt5_txt);
15
16ASSET(red_left_pt1_txt);
17ASSET(red_left_pt2_txt);
18ASSET(red_left_pt3_txt);
19ASSET(red_left_pt4_txt);
20ASSET(red_left_pt5_txt);
21
22// Red Left
23void Autonomous::Auton1(Intake &intake, Latch &latch)
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}
51
52// Red Right
53void Autonomous::Auton2(Intake &intake, Latch &latch)
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}
78
79// Blue left
80void Autonomous::Auton3(Intake &intake, Latch &latch)
81{
82}
83
84/*
85 * @todo Flesh out this method before the competition in order to make it a full
86 * solo awp autonomous. Blue right
87 */
88void Autonomous::Auton4(Intake &intake, Latch &latch)
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}
101
102void Autonomous::Auton5(Intake &intake, Latch &latch)
103{
104 // Autonomous routine for the Skills challenge
105}
106
107// Takes in two parameters: The autonomous value as well as the puncher object.
108void Autonomous::AutoDrive(Intake &intake, Latch &latch)
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}
130
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}
ASSET(red_right_pt1_txt)
void AutoDrive(Intake &intake, Latch &latch)
Drives the robot autonomously.
Definition auton.cpp:108
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
static std::string autonName
The name of the autonomous program.
Definition auton.h:33
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
static void AutonSwitcher(int autonNum)
Switches the autonomous program.
Definition auton.cpp:131
void Auton5(Intake &intake, Latch &latch)
Definition auton.cpp:102
The Intake class represents a robot intake system.
Definition intake.h:9
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
The Latch class represents a latching mechanism.
Definition latch.h:8
void toggle()
Toggles latch state.
Definition latch.cpp:16
lemlib::Chassis chassis(drivetrain, lateral_controller, angular_controller, sensors, &throttle_curve, &steer_curve)
Definition auton.h:8