RIT VEXU Core API
Loading...
Searching...
No Matches
tank_drive.h
1#pragma once
2
3#ifndef PI
4#define PI 3.141592654
5#endif
6
7#include "../core/include/robot_specs.h"
8#include "../core/include/subsystems/odometry/odometry_tank.h"
9#include "../core/include/utils/command_structure/auto_command.h"
10#include "../core/include/utils/controls/feedback_base.h"
11#include "../core/include/utils/controls/pid.h"
12#include "../core/include/utils/pure_pursuit.h"
13#include "vex.h"
14#include <vector>
15
16using namespace vex;
17
23class TankDrive {
24public:
25 enum class BrakeType {
26 None,
28 Smart,
29 };
38 TankDrive(motor_group &left_motors, motor_group &right_motors, robot_specs_t &config, OdometryBase *odom = NULL);
39
40 AutoCommand *DriveToPointCmd(point_t pt, vex::directionType dir = vex::forward, double max_speed = 1.0,
41 double end_speed = 0.0);
42 AutoCommand *DriveToPointCmd(Feedback &fb, point_t pt, vex::directionType dir = vex::forward, double max_speed = 1.0,
43 double end_speed = 0.0);
44
45 AutoCommand *DriveForwardCmd(double dist, vex::directionType dir = vex::forward, double max_speed = 1.0,
46 double end_speed = 0.0);
47 AutoCommand *DriveForwardCmd(Feedback &fb, double dist, vex::directionType dir = vex::forward, double max_speed = 1.0,
48 double end_speed = 0.0);
49
50 AutoCommand *TurnToHeadingCmd(double heading, double max_speed = 1.0, double end_speed = 0.0);
51 AutoCommand *TurnToHeadingCmd(Feedback &fb, double heading, double max_speed = 1.0, double end_speed = 0.0);
52
53 AutoCommand *TurnToPointCmd(double x, double y, vex::directionType dir = vex::directionType::fwd,
54 double max_speed = 1.0, double end_speed = 0.0);
55
56 AutoCommand *TurnDegreesCmd(double degrees, double max_speed = 1.0, double start_speed = 0.0);
57 AutoCommand *TurnDegreesCmd(Feedback &fb, double degrees, double max_speed = 1.0, double end_speed = 0.0);
58
59 AutoCommand *PurePursuitCmd(PurePursuit::Path path, directionType dir, double max_speed = 1, double end_speed = 0);
60 AutoCommand *PurePursuitCmd(Feedback &feedback, PurePursuit::Path path, directionType dir, double max_speed = 1,
61 double end_speed = 0);
62 Condition *DriveStalledCondition(double stall_time);
63 AutoCommand *DriveTankCmd(double left, double right);
64
68 void stop();
69
80 void drive_tank(double left, double right, int power = 1, BrakeType bt = BrakeType::None);
86 void drive_tank_raw(double left, double right);
87
99 void drive_arcade(double forward_back, double left_right, int power = 1, BrakeType bt = BrakeType::None);
100
114 bool drive_forward(double inches, directionType dir, Feedback &feedback, double max_speed = 1, double end_speed = 0);
115
128 bool drive_forward(double inches, directionType dir, double max_speed = 1, double end_speed = 0);
129
141 bool turn_degrees(double degrees, Feedback &feedback, double max_speed = 1, double end_speed = 0);
142
156 bool turn_degrees(double degrees, double max_speed = 1, double end_speed = 0);
157
171 bool drive_to_point(double x, double y, vex::directionType dir, Feedback &feedback, double max_speed = 1,
172 double end_speed = 0);
173
188 bool drive_to_point(double x, double y, vex::directionType dir, double max_speed = 1, double end_speed = 0);
189
200 bool turn_to_heading(double heading_deg, Feedback &feedback, double max_speed = 1, double end_speed = 0);
211 bool turn_to_heading(double heading_deg, double max_speed = 1, double end_speed = 0);
212
216 void reset_auto();
217
228 static double modify_inputs(double input, int power = 2);
229
244 bool pure_pursuit(PurePursuit::Path path, directionType dir, Feedback &feedback, double max_speed = 1,
245 double end_speed = 0);
246
262 bool pure_pursuit(PurePursuit::Path path, directionType dir, double max_speed = 1, double end_speed = 0);
263
264private:
265 motor_group &left_motors;
266 motor_group &right_motors;
267
268 PID correction_pid;
270 Feedback *drive_default_feedback = NULL;
271 Feedback *turn_default_feedback = NULL;
272
273 OdometryBase *odometry;
275
277 &config;
278
279 bool func_initialized = false;
281 bool is_pure_pursuit = false;
282};
Definition auto_command.h:24
Definition feedback_base.h:10
Definition odometry_base.h:24
Definition pid.h:23
Definition pure_pursuit.h:14
Definition tank_drive.h:23
bool drive_forward(double inches, directionType dir, Feedback &feedback, double max_speed=1, double end_speed=0)
Definition tank_drive.cpp:222
bool turn_to_heading(double heading_deg, Feedback &feedback, double max_speed=1, double end_speed=0)
Definition tank_drive.cpp:513
void drive_tank_raw(double left, double right)
Definition tank_drive.cpp:133
TankDrive(motor_group &left_motors, motor_group &right_motors, robot_specs_t &config, OdometryBase *odom=NULL)
Definition tank_drive.cpp:7
bool turn_degrees(double degrees, Feedback &feedback, double max_speed=1, double end_speed=0)
Definition tank_drive.cpp:297
BrakeType
Definition tank_drive.h:25
@ ZeroVelocity
try to bring the robot to rest. But don't try to hold position
@ None
just send 0 volts to the motors
@ Smart
bring the robot to rest and once it's stopped, try to hold that position
void drive_tank(double left, double right, int power=1, BrakeType bt=BrakeType::None)
Definition tank_drive.cpp:145
void reset_auto()
Definition tank_drive.cpp:123
static double modify_inputs(double input, int power=2)
Definition tank_drive.cpp:577
bool pure_pursuit(PurePursuit::Path path, directionType dir, Feedback &feedback, double max_speed=1, double end_speed=0)
Definition tank_drive.cpp:590
void drive_arcade(double forward_back, double left_right, int power=1, BrakeType bt=BrakeType::None)
Definition tank_drive.cpp:200
bool drive_to_point(double x, double y, vex::directionType dir, Feedback &feedback, double max_speed=1, double end_speed=0)
Definition tank_drive.cpp:357
void stop()
Definition tank_drive.cpp:128
Definition geometry.h:7
Definition robot_specs.h:11