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
using namespace
vex;
10
11
namespace
PurePursuit {
15
class
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
48
struct
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
57
struct
hermite_point
{
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
72
extern
std::vector<Translation2d>
73
line_circle_intersections(
Translation2d
center,
double
r,
Translation2d
point1,
Translation2d
point2);
77
extern
Translation2d
get_lookahead(
const
std::vector<Translation2d> &path,
Pose2d
robot_loc,
double
radius);
78
82
extern
std::vector<Translation2d> inject_path(
const
std::vector<Translation2d> &path,
double
spacing);
83
94
95
extern
std::vector<Translation2d>
96
smooth_path(
const
std::vector<Translation2d> &path,
double
weight_data,
double
weight_smooth,
double
tolerance);
97
98
extern
std::vector<Translation2d> smooth_path_cubic(
const
std::vector<Translation2d> &path,
double
res);
99
108
extern
std::vector<Translation2d> smooth_path_hermite(
const
std::vector<hermite_point> &path,
double
step);
109
120
extern
double
estimate_remaining_dist(
const
std::vector<Translation2d> &path,
Pose2d
robot_pose,
double
radius);
121
122
}
// 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:57
PurePursuit::spline
Definition
pure_pursuit.h:48
include
core
utils
pure_pursuit.h
Generated by
1.17.0