RIT VEXU Core API
Toggle main menu visibility
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
9
namespace
PurePursuit {
13
class
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
46
struct
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
55
struct
hermite_point
{
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
70
extern
std::vector<Translation2d>
71
line_circle_intersections(
Translation2d
center,
double
r,
Translation2d
point1,
Translation2d
point2);
75
extern
Translation2d
get_lookahead(
const
std::vector<Translation2d> &path,
Pose2d
robot_loc,
double
radius);
76
80
extern
std::vector<Translation2d> inject_path(
const
std::vector<Translation2d> &path,
double
spacing);
81
92
93
extern
std::vector<Translation2d>
94
smooth_path(
const
std::vector<Translation2d> &path,
double
weight_data,
double
weight_smooth,
double
tolerance);
95
96
extern
std::vector<Translation2d> smooth_path_cubic(
const
std::vector<Translation2d> &path,
double
res);
97
106
extern
std::vector<Translation2d> smooth_path_hermite(
const
std::vector<hermite_point> &path,
double
step);
107
118
extern
double
estimate_remaining_dist(
const
std::vector<Translation2d> &path,
Pose2d
robot_pose,
double
radius);
119
120
}
// namespace PurePursuit
Pose2d
Definition
pose2d.h:24
PurePursuit::Path::get_points
const std::vector< Translation2d > get_points()
Definition
pure_pursuit.cpp:51
PurePursuit::Path::is_valid
bool is_valid()
Definition
pure_pursuit.cpp:61
PurePursuit::Path::Path
Path(std::vector< Translation2d > points, double radius)
Definition
pure_pursuit.cpp:8
PurePursuit::Path::get_radius
double get_radius()
Definition
pure_pursuit.cpp:56
Rotation2d
Definition
rotation2d.h:26
Translation2d
Definition
translation2d.h:21
PurePursuit::hermite_point
Definition
pure_pursuit.h:55
PurePursuit::spline
Definition
pure_pursuit.h:46
include
core
utils
pure_pursuit.h
Generated by
1.17.0