libstp
Robotics library for Botball
Loading...
Searching...
No Matches
libstp::motion::CatmullRomSpline Class Reference

#include <catmull_rom_spline.hpp>

Public Member Functions

 CatmullRomSpline (std::vector< Eigen::Vector2d > waypoints, int samples_per_segment=200)
double totalLength () const
int numWaypoints () const
Eigen::Vector2d positionAt (double s) const
Eigen::Vector2d tangentAt (double s) const
double findNearestArcLength (const Eigen::Vector2d &point, double s_hint) const

Detailed Description

Centripetal Catmull-Rom spline (alpha = 0.5) with arc-length reparameterization.

Stores waypoints in 2D and provides arc-length-parameterized evaluation of position and tangent. Centripetal parameterization avoids cusps and self-intersections that uniform Catmull-Rom produces on unevenly-spaced points.

Endpoint handling: the first and last control points are duplicated so the curve passes through all user-supplied waypoints.

Definition at line 22 of file catmull_rom_spline.hpp.

Constructor & Destructor Documentation

◆ CatmullRomSpline()

libstp::motion::CatmullRomSpline::CatmullRomSpline ( std::vector< Eigen::Vector2d > waypoints,
int samples_per_segment = 200 )
inlineexplicit

Construct a spline through the given waypoints.

Parameters
waypointsAt least 2 points in (x, y) meters.
samples_per_segmentLUT density for arc-length reparameterization.
Exceptions
std::invalid_argumentif fewer than 2 waypoints.

Definition at line 32 of file catmull_rom_spline.hpp.

Member Function Documentation

◆ findNearestArcLength()

double libstp::motion::CatmullRomSpline::findNearestArcLength ( const Eigen::Vector2d & point,
double s_hint ) const
inlinenodiscard

Find the arc-length of the closest point on the spline to a query point.

Uses coarse LUT scan near s_hint then Newton refinement.

Parameters
pointQuery point in spline frame (meters).
s_hintApproximate arc-length (e.g., from previous cycle).
Returns
Arc-length of the nearest point on the spline.

Definition at line 97 of file catmull_rom_spline.hpp.

◆ numWaypoints()

int libstp::motion::CatmullRomSpline::numWaypoints ( ) const
inlinenodiscard

Number of user-supplied waypoints.

Definition at line 61 of file catmull_rom_spline.hpp.

◆ positionAt()

Eigen::Vector2d libstp::motion::CatmullRomSpline::positionAt ( double s) const
inlinenodiscard

Evaluate position at arc-length s (clamped to [0, totalLength]).

Definition at line 66 of file catmull_rom_spline.hpp.

◆ tangentAt()

Eigen::Vector2d libstp::motion::CatmullRomSpline::tangentAt ( double s) const
inlinenodiscard

Evaluate unit tangent at arc-length s.

Definition at line 75 of file catmull_rom_spline.hpp.

◆ totalLength()

double libstp::motion::CatmullRomSpline::totalLength ( ) const
inlinenodiscard

Total arc length of the spline in meters.

Definition at line 58 of file catmull_rom_spline.hpp.


The documentation for this class was generated from the following file: