RIT VEXU Core API
Loading...
Searching...
No Matches
pure_pursuit.h
1#pragma once
2
3#include "core/utils/geometry.h"
4#include "core/utils/math/geometry/pose2d.h"
5#include "core/utils/math/geometry/translation2d.h"
6#include "vex.h"
7#include <vector>
8
9using namespace vex;
10
11namespace PurePursuit {
15class Path {
16 public:
22 Path(std::vector<Translation2d> points, double radius);
23
27 const std::vector<Translation2d> get_points();
28
32 double get_radius();
33
37 bool is_valid();
38
39 private:
40 std::vector<Translation2d> points;
41 double radius;
42 bool valid;
43};
44
48struct spline {
49 double a, b, c, d, x_start, x_end;
50
51 double getY(double x) { return a * pow((x - x_start), 3) + b * pow((x - x_start), 2) + c * (x - x_start) + d; }
52};
53
58 double x;
59 double y;
60 double dir;
61 double mag;
62
63 Translation2d getPoint() const { return Translation2d(x, y); }
64
65 Translation2d getTangent() const { return Translation2d(mag, Rotation2d(dir)); }
66};
67
72extern std::vector<Translation2d>
73line_circle_intersections(Translation2d center, double r, Translation2d point1, Translation2d point2);
77extern Translation2d get_lookahead(const std::vector<Translation2d> &path, Pose2d robot_loc, double radius);
78
82extern std::vector<Translation2d> inject_path(const std::vector<Translation2d> &path, double spacing);
83
94
95extern std::vector<Translation2d>
96smooth_path(const std::vector<Translation2d> &path, double weight_data, double weight_smooth, double tolerance);
97
98extern std::vector<Translation2d> smooth_path_cubic(const std::vector<Translation2d> &path, double res);
99
108extern std::vector<Translation2d> smooth_path_hermite(const std::vector<hermite_point> &path, double step);
109
120extern double estimate_remaining_dist(const std::vector<Translation2d> &path, Pose2d robot_pose, double radius);
121
122} // namespace PurePursuit
Definition pose2d.h:23
const std::vector< Translation2d > get_points()
Definition pure_pursuit.cpp:51
bool is_valid()
Definition pure_pursuit.cpp:61
Path(std::vector< Translation2d > points, double radius)
Definition pure_pursuit.cpp:8
double get_radius()
Definition pure_pursuit.cpp:56
Definition rotation2d.h:25
Definition translation2d.h:22
Definition pure_pursuit.h:57
Definition pure_pursuit.h:48