LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
spline.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <optional>
5#include <vector>
6
22namespace light {
23
25struct Waypoint {
26 float x = 0.0f;
27 float y = 0.0f;
28 std::optional<float> headingRad;
29 std::optional<float> speed;
30};
31
34 float x = 0.0f, y = 0.0f;
35 float dx = 0.0f, dy = 0.0f;
36 float ddx = 0.0f, ddy = 0.0f;
37};
38
41 float p0x, p0y, v0x, v0y, a0x, a0y;
42 float p1x, p1y, v1x, v1y, a1x, a1y;
43
51 SplineSample eval(float u) const;
52};
53
60class Spline {
61 public:
62 Spline() = default;
63
70 explicit Spline(const std::vector<Waypoint>& wps);
71
73 bool valid() const { return !segs_.empty(); }
74
76 float totalArcLen() const { return totalLen_; }
77
79 size_t segmentCount() const { return segs_.size(); }
80
87 SplineSample sampleAt(float s) const;
88
96 float headingAt(float s) const;
97
105 float curvatureAt(float s) const;
106
107 private:
108 std::vector<HermiteSegment> segs_;
109 std::vector<std::array<float, 65>> segArcTables_; // per-segment u→s LUT
110 std::vector<float> segLens_;
111 float totalLen_ = 0.0f;
112
113 void sToSegU(float s, int& segIdx, float& u) const;
114};
115
116} // namespace light
Concatenated quintic Hermite spline with arc-length parameterization.
Definition spline.hpp:60
Spline(const std::vector< Waypoint > &wps)
Build a spline from waypoints.
float totalArcLen() const
Definition spline.hpp:76
size_t segmentCount() const
Definition spline.hpp:79
bool valid() const
Definition spline.hpp:73
float headingAt(float s) const
Heading at arc length s, in radians.
SplineSample sampleAt(float s) const
Sample pose / derivatives at arc length s.
Spline()=default
float curvatureAt(float s) const
Signed curvature at arc length s.
Public LightLib odometry / pose-estimation API.
Definition pid.hpp:22
One segment of a quintic Hermite spline.
Definition spline.hpp:40
float a1y
End position, velocity, acceleration.
Definition spline.hpp:42
float a0y
Start position, velocity, acceleration.
Definition spline.hpp:41
SplineSample eval(float u) const
Evaluate the segment at parameter u.
Pose / velocity / acceleration sample produced by spline evaluation.
Definition spline.hpp:33
float dy
First derivative w.r.t. parameter u.
Definition spline.hpp:35
float ddy
Second derivative w.r.t. parameter u.
Definition spline.hpp:36
float y
Position, inches.
Definition spline.hpp:34
Single 2-D waypoint with optional heading and per-point speed cap.
Definition spline.hpp:25
float x
X position, inches.
Definition spline.hpp:26
std::optional< float > headingRad
If absent, tangent taken from adjacent chord.
Definition spline.hpp:28
std::optional< float > speed
Optional per-waypoint speed cap (not used yet).
Definition spline.hpp:29
float y
Y position, inches.
Definition spline.hpp:27