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
9namespace PurePursuit {
13class Path {
14 public:
20 Path(std::vector<Translation2d> points, double radius);
21
25 const std::vector<Translation2d> get_points();
26
30 double get_radius();
31
35 bool is_valid();
36
37 private:
38 std::vector<Translation2d> points;
39 double radius;
40 bool valid;
41};
42
46struct spline {
47 double a, b, c, d, x_start, x_end;
48
49 double getY(double x) { return a * pow((x - x_start), 3) + b * pow((x - x_start), 2) + c * (x - x_start) + d; }
50};
51
56 double x;
57 double y;
58 double dir;
59 double mag;
60
61 Translation2d getPoint() const { return Translation2d(x, y); }
62
63 Translation2d getTangent() const { return Translation2d(mag, Rotation2d(dir)); }
64};
65
70extern std::vector<Translation2d>
71line_circle_intersections(Translation2d center, double r, Translation2d point1, Translation2d point2);
75extern Translation2d get_lookahead(const std::vector<Translation2d> &path, Pose2d robot_loc, double radius);
76
80extern std::vector<Translation2d> inject_path(const std::vector<Translation2d> &path, double spacing);
81
92
93extern std::vector<Translation2d>
94smooth_path(const std::vector<Translation2d> &path, double weight_data, double weight_smooth, double tolerance);
95
96extern std::vector<Translation2d> smooth_path_cubic(const std::vector<Translation2d> &path, double res);
97
106extern std::vector<Translation2d> smooth_path_hermite(const std::vector<hermite_point> &path, double step);
107
118extern double estimate_remaining_dist(const std::vector<Translation2d> &path, Pose2d robot_pose, double radius);
119
120} // namespace PurePursuit
Definition pose2d.h:24
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:26
Definition translation2d.h:21
Definition pure_pursuit.h:55
Definition pure_pursuit.h:46