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"
26using namespace vex;
27
28// ==== DRIVING ====
29
35class DriveForwardCommand : public AutoCommand {
36public:
37 DriveForwardCommand(TankDrive &drive_sys, Feedback &feedback, double inches, directionType dir, double max_speed = 1,
38 double end_speed = 0);
39
45 bool run() override;
46
47 /*
48 * Returns a string describing the commands functionality
49 */
50 std::string toString() override;
51
55 void on_timeout() override;
56
57private:
58 // drive system to run the function on
59 TankDrive &drive_sys;
60
61 // feedback controller to use
62 Feedback &feedback;
63
64 // parameters for drive_forward
65 double inches;
66 directionType dir;
67 double max_speed;
68 double end_speed;
69};
70
75class TurnDegreesCommand : public AutoCommand {
76public:
77 TurnDegreesCommand(TankDrive &drive_sys, Feedback &feedback, double degrees, double max_speed = 1,
78 double end_speed = 0);
79
85 bool run() override;
86
87 /*
88 * Returns a string describing the commands functionality
89 */
90 std::string toString() override;
94
95 void on_timeout() override;
96
97private:
98 // drive system to run the function on
99 TankDrive &drive_sys;
100
101 // feedback controller to use
102 Feedback &feedback;
103
104 // parameters for turn_degrees
105 double degrees;
106 double max_speed;
107 double end_speed;
108};
109
114class DriveToPointCommand : public AutoCommand {
115public:
116 DriveToPointCommand(TankDrive &drive_sys, Feedback &feedback, double x, double y, directionType dir,
117 double max_speed = 1, double end_speed = 0);
118 DriveToPointCommand(TankDrive &drive_sys, Feedback &feedback, Translation2d translation, directionType dir, double max_speed = 1,
119 double end_speed = 0);
120
126 bool run() override;
127
128 /*
129 * Returns a string describing the commands functionality
130 */
131 std::string toString() override;
132private:
133 // drive system to run the function on
134 TankDrive &drive_sys;
135
139 void on_timeout() override;
140
141 // feedback controller to use
142 Feedback &feedback;
143
144 // parameters for drive_to_point
145 double x;
146 double y;
147 directionType dir;
148 double max_speed;
149 double end_speed;
150};
151
152class TurnToPointCommand: public AutoCommand{
153 public:
154
155 TurnToPointCommand(TankDrive &drive_sys, double x, double y, vex::directionType dir, double max_speed = 1, double end_speed = 0);
156 TurnToPointCommand(TankDrive &drive_sys, Translation2d translation, vex::directionType dir, double max_speed = 1, double end_speed = 0);
157
158 bool run() override;
159
160 /*
161 * Returns a string describing the commands functionality
162 */
163 std::string toString() override;
164
165 private:
166
167 void on_timeout() override;
168 TankDrive &drive_sys;
169 double x, y;
170 vex::directionType dir;
171 double max_speed;
172 double end_speed;
173 bool func_initialized = false;
174 double heading;
175};
176
182class TurnToHeadingCommand : public AutoCommand {
183public:
184 TurnToHeadingCommand(TankDrive &drive_sys, Feedback &feedback, double heading_deg, double speed = 1,
185 double end_speed = 0);
186
192 bool run() override;
193
194 /*
195 * Returns a string describing the commands functionality
196 */
197 std::string toString() override;
198
202 void on_timeout() override;
203
204private:
205 // drive system to run the function on
206 TankDrive &drive_sys;
207
208 // feedback controller to use
209 Feedback &feedback;
210
211 // parameters for turn_to_heading
212 double heading_deg;
213 double max_speed;
214 double end_speed;
215};
216
220class PurePursuitCommand : public AutoCommand {
221public:
230 PurePursuitCommand(TankDrive &drive_sys, Feedback &feedback, PurePursuit::Path path, directionType dir,
231 double max_speed = 1, double end_speed = 0);
232
236 bool run() override;
237
238 /*
239 * Returns a string describing the commands functionality
240 */
241 std::string toString() override;
242
246 void on_timeout() override;
247
248private:
249 TankDrive &drive_sys;
251 directionType dir;
252 Feedback &feedback;
253 double max_speed;
254 double end_speed;
255};
256
261class DriveStopCommand : public AutoCommand {
262public:
263 DriveStopCommand(TankDrive &drive_sys);
264
270 bool run() override;
271
272 /*
273 * Returns a string describing the commands functionality
274 */
275 std::string toString() override;
276
277 void on_timeout() override;
278
279private:
280 // drive system to run the function on
281 TankDrive &drive_sys;
282};
283
284// ==== ODOMETRY ====
285
290class OdomSetPosition : public AutoCommand {
291public:
297 OdomSetPosition(OdometryBase &odom, const Pose2d &newpos = OdometryBase::zero_pos);
298
304 bool run() override;
305 /*
306 * Returns a string describing the commands functionality
307 */
308 std::string toString() override;
309private:
310 // drive system with an odometry config
311 OdometryBase &odom;
312 Pose2d newpos;
313};
DriveForwardCommand(TankDrive &drive_sys, Feedback &feedback, double inches, 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, 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:23
PurePursuitCommand(TankDrive &drive_sys, Feedback &feedback, PurePursuit::Path path, 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:15
Definition tank_drive.h:23
Definition translation2d.h:22
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