RIT VEXU Core API
Loading...
Searching...
No Matches
drive_commands.h
1
19#pragma once
20
21#include "../core/include/subsystems/tank_drive.h"
22#include "../core/include/utils/command_structure/auto_command.h"
23#include "../core/include/utils/geometry.h"
24#include "vex.h"
25
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;
49 void on_timeout() override;
50
51private:
52 // drive system to run the function on
53 TankDrive &drive_sys;
54
55 // feedback controller to use
56 Feedback &feedback;
57
58 // parameters for drive_forward
59 double inches;
60 directionType dir;
61 double max_speed;
62 double end_speed;
63};
64
69class TurnDegreesCommand : public AutoCommand {
70public:
71 TurnDegreesCommand(TankDrive &drive_sys, Feedback &feedback, double degrees, double max_speed = 1,
72 double end_speed = 0);
73
79 bool run() override;
83 void on_timeout() override;
84
85private:
86 // drive system to run the function on
87 TankDrive &drive_sys;
88
89 // feedback controller to use
90 Feedback &feedback;
91
92 // parameters for turn_degrees
93 double degrees;
94 double max_speed;
95 double end_speed;
96};
97
102class DriveToPointCommand : public AutoCommand {
103public:
104 DriveToPointCommand(TankDrive &drive_sys, Feedback &feedback, double x, double y, directionType dir,
105 double max_speed = 1, double end_speed = 0);
106 DriveToPointCommand(TankDrive &drive_sys, Feedback &feedback, point_t point, directionType dir, double max_speed = 1,
107 double end_speed = 0);
108
114 bool run() override;
115
116private:
117 // drive system to run the function on
118 TankDrive &drive_sys;
119
123 void on_timeout() override;
124
125 // feedback controller to use
126 Feedback &feedback;
127
128 // parameters for drive_to_point
129 double x;
130 double y;
131 directionType dir;
132 double max_speed;
133 double end_speed;
134};
135
141class TurnToHeadingCommand : public AutoCommand {
142public:
143 TurnToHeadingCommand(TankDrive &drive_sys, Feedback &feedback, double heading_deg, double speed = 1,
144 double end_speed = 0);
145
151 bool run() override;
155 void on_timeout() override;
156
157private:
158 // drive system to run the function on
159 TankDrive &drive_sys;
160
161 // feedback controller to use
162 Feedback &feedback;
163
164 // parameters for turn_to_heading
165 double heading_deg;
166 double max_speed;
167 double end_speed;
168};
169
173class PurePursuitCommand : public AutoCommand {
174public:
183 PurePursuitCommand(TankDrive &drive_sys, Feedback &feedback, PurePursuit::Path path, directionType dir,
184 double max_speed = 1, double end_speed = 0);
185
189 bool run() override;
190
194 void on_timeout() override;
195
196private:
197 TankDrive &drive_sys;
199 directionType dir;
200 Feedback &feedback;
201 double max_speed;
202 double end_speed;
203};
204
209class DriveStopCommand : public AutoCommand {
210public:
211 DriveStopCommand(TankDrive &drive_sys);
212
218 bool run() override;
219 void on_timeout() override;
220
221private:
222 // drive system to run the function on
223 TankDrive &drive_sys;
224};
225
226// ==== ODOMETRY ====
227
232class OdomSetPosition : public AutoCommand {
233public:
240
246 bool run() override;
247
248private:
249 // drive system with an odometry config
250 OdometryBase &odom;
251 pose_t newpos;
252};
Definition drive_commands.h:35
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:45
bool run() override
Definition drive_commands.cpp:40
Definition drive_commands.h:209
bool run() override
Definition drive_commands.cpp:178
DriveStopCommand(TankDrive &drive_sys)
Definition drive_commands.cpp:169
Definition drive_commands.h:102
bool run() override
Definition drive_commands.cpp:106
DriveToPointCommand(TankDrive &drive_sys, Feedback &feedback, double x, double y, directionType dir, double max_speed=1, double end_speed=0)
Definition drive_commands.cpp:84
Definition feedback_base.h:10
Definition drive_commands.h:232
bool run() override
Definition drive_commands.cpp:191
OdomSetPosition(OdometryBase &odom, const pose_t &newpos=OdometryBase::zero_pos)
Definition drive_commands.cpp:189
Definition odometry_base.h:24
static constexpr pose_t zero_pos
Definition odometry_base.h:124
Definition drive_commands.h:173
PurePursuitCommand(TankDrive &drive_sys, Feedback &feedback, PurePursuit::Path path, directionType dir, double max_speed=1, double end_speed=0)
Definition drive_commands.cpp:148
bool run() override
Definition drive_commands.cpp:155
void on_timeout() override
Definition drive_commands.cpp:160
Definition pure_pursuit.h:14
Definition tank_drive.h:23
Definition drive_commands.h:69
bool run() override
Definition drive_commands.cpp:66
TurnDegreesCommand(TankDrive &drive_sys, Feedback &feedback, double degrees, double max_speed=1, double end_speed=0)
Definition drive_commands.cpp:57
void on_timeout() override
Definition drive_commands.cpp:70
Definition drive_commands.h:141
TurnToHeadingCommand(TankDrive &drive_sys, Feedback &feedback, double heading_deg, double speed=1, double end_speed=0)
Definition drive_commands.cpp:122
void on_timeout() override
Definition drive_commands.cpp:135
bool run() override
Definition drive_commands.cpp:131
Definition geometry.h:7
Definition geometry.h:52