RIT VEXU Core API
Loading...
Searching...
No Matches
drive_commands.h
1
18
19#pragma once
20
21#include "core/subsystems/tank_drive.h"
22#include "core/utils/command_structure/auto_command.h"
23#include "core/utils/geometry.h"
24#include "vex.h"
25#include "core/utils/math/geometry/pose2d.h"
26
27// ==== DRIVING ====
28
34class DriveForwardCommand : public AutoCommand {
35public:
36 DriveForwardCommand(TankDrive &drive_sys, Feedback &feedback, double inches, vex::directionType dir, double max_speed = 1,
37 double end_speed = 0);
38
44 bool run() override;
45
46 /*
47 * Returns a string describing the commands functionality
48 */
49 std::string toString() override;
50
54 void on_timeout() override;
55
56private:
57 // drive system to run the function on
58 TankDrive &drive_sys;
59
60 // feedback controller to use
61 Feedback &feedback;
62
63 // parameters for drive_forward
64 double inches;
65 vex::directionType dir;
66 double max_speed;
67 double end_speed;
68};
69
74class TurnDegreesCommand : public AutoCommand {
75public:
76 TurnDegreesCommand(TankDrive &drive_sys, Feedback &feedback, double degrees, double max_speed = 1,
77 double end_speed = 0);
78
84 bool run() override;
85
86 /*
87 * Returns a string describing the commands functionality
88 */
89 std::string toString() override;
93
94 void on_timeout() override;
95
96private:
97 // drive system to run the function on
98 TankDrive &drive_sys;
99
100 // feedback controller to use
101 Feedback &feedback;
102
103 // parameters for turn_degrees
104 double degrees;
105 double max_speed;
106 double end_speed;
107};
108
113class DriveToPointCommand : public AutoCommand {
114public:
115 DriveToPointCommand(TankDrive &drive_sys, Feedback &feedback, double x, double y, vex::directionType dir,
116 double max_speed = 1, double end_speed = 0);
117 DriveToPointCommand(TankDrive &drive_sys, Feedback &feedback, Translation2d translation, vex::directionType dir, double max_speed = 1,
118 double end_speed = 0);
119
125 bool run() override;
126
127 /*
128 * Returns a string describing the commands functionality
129 */
130 std::string toString() override;
131private:
132 // drive system to run the function on
133 TankDrive &drive_sys;
134
138 void on_timeout() override;
139
140 // feedback controller to use
141 Feedback &feedback;
142
143 // parameters for drive_to_point
144 double x;
145 double y;
146 vex::directionType dir;
147 double max_speed;
148 double end_speed;
149};
150
151class TurnToPointCommand: public AutoCommand{
152 public:
153
154 TurnToPointCommand(TankDrive &drive_sys, double x, double y, vex::directionType dir, double max_speed = 1, double end_speed = 0);
155 TurnToPointCommand(TankDrive &drive_sys, Translation2d translation, vex::directionType dir, double max_speed = 1, double end_speed = 0);
156
157 bool run() override;
158
159 /*
160 * Returns a string describing the commands functionality
161 */
162 std::string toString() override;
163
164 private:
165
166 void on_timeout() override;
167 TankDrive &drive_sys;
168 double x, y;
169 vex::directionType dir;
170 double max_speed;
171 double end_speed;
172 bool func_initialized = false;
173 double heading;
174};
175
181class TurnToHeadingCommand : public AutoCommand {
182public:
183 TurnToHeadingCommand(TankDrive &drive_sys, Feedback &feedback, double heading_deg, double speed = 1,
184 double end_speed = 0);
185
191 bool run() override;
192
193 /*
194 * Returns a string describing the commands functionality
195 */
196 std::string toString() override;
197
201 void on_timeout() override;
202
203private:
204 // drive system to run the function on
205 TankDrive &drive_sys;
206
207 // feedback controller to use
208 Feedback &feedback;
209
210 // parameters for turn_to_heading
211 double heading_deg;
212 double max_speed;
213 double end_speed;
214};
215
219class PurePursuitCommand : public AutoCommand {
220public:
229 PurePursuitCommand(TankDrive &drive_sys, Feedback &feedback, PurePursuit::Path path, vex::directionType dir,
230 double max_speed = 1, double end_speed = 0);
231
235 bool run() override;
236
237 /*
238 * Returns a string describing the commands functionality
239 */
240 std::string toString() override;
241
245 void on_timeout() override;
246
247private:
248 TankDrive &drive_sys;
250 vex::directionType dir;
251 Feedback &feedback;
252 double max_speed;
253 double end_speed;
254};
255
260class DriveStopCommand : public AutoCommand {
261public:
262 DriveStopCommand(TankDrive &drive_sys);
263
269 bool run() override;
270
271 /*
272 * Returns a string describing the commands functionality
273 */
274 std::string toString() override;
275
276 void on_timeout() override;
277
278private:
279 // drive system to run the function on
280 TankDrive &drive_sys;
281};
282
283// ==== ODOMETRY ====
284
289class OdomSetPosition : public AutoCommand {
290public:
296 OdomSetPosition(OdometryBase &odom, const Pose2d &newpos = OdometryBase::zero_pos);
297
303 bool run() override;
304 /*
305 * Returns a string describing the commands functionality
306 */
307 std::string toString() override;
308private:
309 // drive system with an odometry config
310 OdometryBase &odom;
311 Pose2d newpos;
312};
DriveForwardCommand(TankDrive &drive_sys, Feedback &feedback, double inches, vex::directionType dir, double max_speed=1, double end_speed=0)
Definition drive_commands.cpp:31
void on_timeout() override
Definition drive_commands.cpp:64
bool run() override
Definition drive_commands.cpp:41
bool run() override
Definition drive_commands.cpp:302
DriveStopCommand(TankDrive &drive_sys)
Definition drive_commands.cpp:288
bool run() override
Definition drive_commands.cpp:140
DriveToPointCommand(TankDrive &drive_sys, Feedback &feedback, double x, double y, vex::directionType dir, double max_speed=1, double end_speed=0)
Definition drive_commands.cpp:111
Definition feedback_base.h:10
bool run() override
Definition drive_commands.cpp:323
OdomSetPosition(OdometryBase &odom, const Pose2d &newpos=OdometryBase::zero_pos)
Definition drive_commands.cpp:313
Definition odometry_base.h:31
Definition pose2d.h:24
PurePursuitCommand(TankDrive &drive_sys, Feedback &feedback, PurePursuit::Path path, vex::directionType dir, double max_speed=1, double end_speed=0)
Definition drive_commands.cpp:251
bool run() override
Definition drive_commands.cpp:260
void on_timeout() override
Definition drive_commands.cpp:279
Definition pure_pursuit.h:13
Definition tank_drive.h:21
Definition translation2d.h:21
bool run() override
Definition drive_commands.cpp:85
TurnDegreesCommand(TankDrive &drive_sys, Feedback &feedback, double degrees, double max_speed=1, double end_speed=0)
Definition drive_commands.cpp:76
void on_timeout() override
Definition drive_commands.cpp:97
TurnToHeadingCommand(TankDrive &drive_sys, Feedback &feedback, double heading_deg, double speed=1, double end_speed=0)
Definition drive_commands.cpp:215
void on_timeout() override
Definition drive_commands.cpp:238
bool run() override
Definition drive_commands.cpp:225