RIT VEXU Core API
Loading...
Searching...
No Matches
drive_commands.h
1
18
19#pragma once
20
21#include "core/competition/command_structure/auto_command.h"
22#include "core/subsystems/tank_drive.h"
23#include "core/math/geometry/pose2d.h"
24#include "vex/vex.h"
25
26// ==== DRIVING ====
27
33class DriveForwardCommand : public AutoCommand {
34 public:
36 TankDrive& drive_sys, Feedback& feedback, double inches, vex::directionType dir,
37 double max_speed = 1, double end_speed = 0
38 );
39
45 bool run() override;
46
48 std::string toString() override;
49
51 void on_timeout() override;
52
53 private:
54 // drive system to run the function on
55 TankDrive& drive_sys;
56
57 // feedback controller to use
58 Feedback& feedback;
59
60 // parameters for drive_forward
61 double inches;
62 vex::directionType dir;
63 double max_speed;
64 double end_speed;
65};
66
71class TurnDegreesCommand : public AutoCommand {
72 public:
74 TankDrive& drive_sys, Feedback& feedback, double degrees, double max_speed = 1,
75 double end_speed = 0
76 );
77
83 bool run() override;
84
86 std::string toString() override;
87
89 void on_timeout() override;
90
91 private:
92 // drive system to run the function on
93 TankDrive& drive_sys;
94
95 // feedback controller to use
96 Feedback& feedback;
97
98 // parameters for turn_degrees
99 double degrees;
100 double max_speed;
101 double end_speed;
102};
103
108class DriveToPointCommand : public AutoCommand {
109 public:
111 TankDrive& drive_sys, Feedback& feedback, double x, double y, vex::directionType dir,
112 double max_speed = 1, double end_speed = 0
113 );
115 TankDrive& drive_sys, Feedback& feedback, Translation2d translation, vex::directionType dir,
116 double max_speed = 1, double end_speed = 0
117 );
118
124 bool run() override;
125
127 std::string toString() override;
128
129 private:
130 // drive system to run the function on
131 TankDrive& drive_sys;
132
134 void on_timeout() override;
135
136 // feedback controller to use
137 Feedback& feedback;
138
139 // parameters for drive_to_point
140 double x;
141 double y;
142 vex::directionType dir;
143 double max_speed;
144 double end_speed;
145};
146
147class TurnToPointCommand : public AutoCommand {
148 public:
149 TurnToPointCommand(
150 TankDrive& drive_sys, double x, double y, vex::directionType dir, double max_speed = 1,
151 double end_speed = 0
152 );
153 TurnToPointCommand(
154 TankDrive& drive_sys, Translation2d translation, vex::directionType dir, double max_speed = 1,
155 double end_speed = 0
156 );
157
158 bool run() override;
159
161 std::string toString() override;
162
163 private:
164 void on_timeout() override;
165 TankDrive& drive_sys;
166 double x, y;
167 vex::directionType dir;
168 double max_speed;
169 double end_speed;
170 bool func_initialized = false;
171 double heading;
172};
173
178class TurnToHeadingCommand : public AutoCommand {
179 public:
181 TankDrive& drive_sys, Feedback& feedback, double heading_deg, double speed = 1,
182 double end_speed = 0
183 );
184
190 bool run() override;
191
193 std::string toString() override;
194
196 void on_timeout() override;
197
198 private:
199 // drive system to run the function on
200 TankDrive& drive_sys;
201
202 // feedback controller to use
203 Feedback& feedback;
204
205 // parameters for turn_to_heading
206 double heading_deg;
207 double max_speed;
208 double end_speed;
209};
210
215class DriveStopCommand : public AutoCommand {
216 public:
217 DriveStopCommand(TankDrive& drive_sys);
218
224 bool run() override;
225
227 std::string toString() override;
228
229 void on_timeout() override;
230
231 private:
232 // drive system to run the function on
233 TankDrive& drive_sys;
234};
235
236// ==== ODOMETRY ====
237
242class OdomSetPosition : public AutoCommand {
243 public:
250 OdomSetPosition(OdometryBase& odom, const Pose2d& newpos = OdometryBase::zero_pos);
251
257 bool run() override;
258
260 std::string toString() override;
261
262 private:
263 // drive system with an odometry config
264 OdometryBase& odom;
265 Pose2d newpos;
266};
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
Cleans up drive system if we time out before finishing.
Definition drive_commands.cpp:60
std::string toString() override
Returns a string describing the commands functionality.
Definition drive_commands.cpp:44
bool run() override
Definition drive_commands.cpp:41
std::string toString() override
Returns a string describing the commands functionality.
Definition drive_commands.cpp:232
bool run() override
Definition drive_commands.cpp:241
DriveStopCommand(TankDrive &drive_sys)
Definition drive_commands.cpp:229
std::string toString() override
Returns a string describing the commands functionality.
Definition drive_commands.cpp:135
bool run() override
Definition drive_commands.cpp:132
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:103
Definition feedback_base.h:10
std::string toString() override
Returns a string describing the commands functionality.
Definition drive_commands.cpp:255
bool run() override
Definition drive_commands.cpp:260
OdomSetPosition(OdometryBase &odom, const Pose2d &newpos=OdometryBase::zero_pos)
Definition drive_commands.cpp:252
Definition odometry_base.h:27
Definition pose2d.h:21
Definition tank_drive.h:14
bool run() override
Definition drive_commands.cpp:81
TurnDegreesCommand(TankDrive &drive_sys, Feedback &feedback, double degrees, double max_speed=1, double end_speed=0)
Definition drive_commands.cpp:72
std::string toString() override
Returns a string describing the commands functionality.
Definition drive_commands.cpp:84
void on_timeout() override
Cleans up drive system if we time out before finishing.
Definition drive_commands.cpp:89
TurnToHeadingCommand(TankDrive &drive_sys, Feedback &feedback, double heading_deg, double speed=1, double end_speed=0)
Definition drive_commands.cpp:201
std::string toString() override
Returns a string describing the commands functionality.
Definition drive_commands.cpp:214
void on_timeout() override
Cleans up drive system if we time out before finishing.
Definition drive_commands.cpp:220
bool run() override
Definition drive_commands.cpp:211