LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
drive.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "LightLib/lib.hpp"
4
17const double WHEEL_DIAMETER = 3.3369184232;
18const double ROBOT_WIDTH = 11.4375;
19const int KEY = 267267;
20
23 BACK = 0,
24 RIGHT = 1,
25 LEFT = 2
26};
27
30 STANLEY = 0,
31 ODOM = 1,
32 PLAIN = 2,
33 BRAIN = 3,
34};
35
37enum Wait { WAIT = 0,
38 QUICK = 1,
39 CHAIN = 2 };
40
48 public:
49 double x = 0;
50 double y = 0;
51 double t = 0;
52 double right = 127;
53 double left = 0;
55};
56
57extern double angle_offset;
58extern AutonMode autonMode;
59extern std::vector<Coordinate> autonPath;
60
65double getDistance(Coordinate point1, Coordinate point2);
66double getTheta(Coordinate point1, Coordinate point2, light::drive_directions direction);
67double getVelocity(double voltage);
68double getTimeToPoint(double distance, double velocity);
69Coordinate getPoint(Coordinate startPoint, double distance);
70Coordinate getPoint(Coordinate startPoint, double v_left, double v_right, double time);
71std::vector<Coordinate> injectPoint(Coordinate startPoint, Coordinate endPoint, e_angle_behavior behavior, double left, double right, double theta,
72 double lookAhead);
73std::vector<Coordinate> injectPath(std::vector<Coordinate> coordList, double lookAhead);
80void setPosition(double x, double y);
81void setPosition(double x, double y, double t);
82double getDistanceActual(DistanceSide sensor, bool use_theta, double failsafe);
89void pidWait(Wait type);
90void pidWaitUntil(okapi::QLength distance);
91void pidWaitUntil(okapi::QAngle distance);
92void pidWaitUntil(Coordinate coordinate);
93void delayMillis(int millis);
94void delayMillis(int millis, bool ignore);
101void driveSet(double distance, int speed, bool slew);
102void driveSet(double distance, int speed);
103void driveSmartSet(double distance, int speed);
110void turnSet(double theta, int speed, e_angle_behavior behavior);
111void turnSet(double theta, int speed);
112void turnSet(Coordinate point, drive_directions direction, int speed, e_angle_behavior behavior);
113void turnSet(Coordinate point, drive_directions direction, int speed);
114void turnSetRelative(double theta, int speed, e_angle_behavior behavior);
115void turnSetRelative(double theta, int speed);
122void swingSet(light::e_swing side, double theta, double main, double opp, light::e_angle_behavior behavior);
123void swingSet(light::e_swing side, double theta, double main, light::e_angle_behavior behavior);
124void swingSet(light::e_swing side, double theta, double main, double opp);
125void swingSet(light::e_swing side, double theta, double main);
133void getPath();
One waypoint in the legacy injected-path representation.
Definition drive.hpp:47
light::e_angle_behavior behavior
Turn behavior at the waypoint.
Definition drive.hpp:54
double y
Field-frame Y, inches.
Definition drive.hpp:50
double x
Field-frame X, inches.
Definition drive.hpp:49
double t
Heading at the waypoint, degrees.
Definition drive.hpp:51
double right
Right wheel command at the waypoint.
Definition drive.hpp:52
double left
Left wheel command at the waypoint.
Definition drive.hpp:53
Slew-rate limiter that ramps speed up linearly over a configurable distance.
Definition slew.hpp:29
const int KEY
Misc. magic constant retained for legacy code.
Definition drive.hpp:19
Coordinate getPoint(Coordinate startPoint, double distance)
AutonMode
Auton mode selector for the legacy path runner.
Definition drive.hpp:29
@ ODOM
Odom-based motion primitives.
Definition drive.hpp:31
@ STANLEY
Stanley path-follower.
Definition drive.hpp:30
@ BRAIN
Driven by the brain-screen selector.
Definition drive.hpp:33
@ PLAIN
Direct PID drive sequencing.
Definition drive.hpp:32
double getTimeToPoint(double distance, double velocity)
double angle_offset
Heading offset applied by the legacy helpers.
double getTheta(Coordinate point1, Coordinate point2, light::drive_directions direction)
void turnSet(double theta, int speed, e_angle_behavior behavior)
void delayMillis(int millis)
void turnSetRelative(double theta, int speed, e_angle_behavior behavior)
void driveSet(double distance, int speed, bool slew)
double getDistanceActual(DistanceSide sensor, bool use_theta, double failsafe)
std::vector< Coordinate > injectPath(std::vector< Coordinate > coordList, double lookAhead)
Wait
Wait-mode selector for pidWait().
Definition drive.hpp:37
@ WAIT
Definition drive.hpp:37
@ CHAIN
Definition drive.hpp:39
@ QUICK
Definition drive.hpp:38
void driveSmartSet(double distance, int speed)
DistanceSide
Which side a distance sensor faces for the legacy distance helpers.
Definition drive.hpp:22
@ BACK
Definition drive.hpp:23
@ LEFT
Definition drive.hpp:25
@ RIGHT
Definition drive.hpp:24
AutonMode autonMode
Active auton mode for the legacy runner.
void getPathInjected()
Print the post-injection autonPath to the PROS terminal.
std::vector< Coordinate > injectPoint(Coordinate startPoint, Coordinate endPoint, e_angle_behavior behavior, double left, double right, double theta, double lookAhead)
void pidWait(Wait type)
double getVelocity(double voltage)
void pidWaitUntil(okapi::QLength distance)
std::vector< Coordinate > autonPath
Path being executed by the legacy runner.
void setPosition(double x, double y)
const double WHEEL_DIAMETER
Default wheel diameter, inches.
Definition drive.hpp:17
void swingSet(light::e_swing side, double theta, double main, double opp, light::e_angle_behavior behavior)
double getDistance(Coordinate point1, Coordinate point2)
const double ROBOT_WIDTH
Default robot track width, inches.
Definition drive.hpp:18
void getPath()
Print the current autonPath to the PROS terminal.
Umbrella header for LightLib's own classes.
e_angle_behavior
How to choose a turn direction when reaching an absolute heading.
Definition util.hpp:98
@ cw
Definition util.hpp:106
e_swing
Direction for swing-turn motions.
Definition util.hpp:67
drive_directions
Drive direction with multiple spelling aliases.
Definition util.hpp:88