Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
splines.hpp File Reference
#include <gsl/gsl_bspline.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_interp.h>
#include <gsl/gsl_multifit.h>
#include <gsl/gsl_spline.h>
#include <cmath>
#include <type_traits>
#include <unordered_set>
#include <utility>
#include <vector>
#include "rclcpp/rclcpp.hpp"
Include dependency graph for splines.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  HasDefaultConstructor< T, typename >
 In this file, a function is implemented to fit a spline to a set of ordered points. More...
 
struct  HasDefaultConstructor< T, std::void_t< decltype(T())> >
 
struct  IsHashable< T, typename >
 
struct  IsHashable< T, std::void_t< decltype(std::hash< T >{}(std::declval< T >()))> >
 
struct  HasEqualityOperator< T, typename >
 
struct  HasEqualityOperator< T, std::void_t< decltype(std::declval< T >()==std::declval< T >())> >
 
struct  HasPosition< T, typename >
 
struct  HasPosition< T, std::void_t< decltype(std::declval< T >().position)> >
 
struct  HasPositionXY< T, typename >
 
struct  HasPositionXY< T, std::void_t< decltype(std::declval< T >().position.x), decltype(std::declval< T >().position.y)> >
 
struct  IsCopyConstructor< T, typename >
 
struct  IsCopyConstructor< T, std::void_t< decltype(T(std::declval< T >()))> >
 
struct  HasEuclideanDistance< T, typename >
 
struct  HasEuclideanDistance< T, std::void_t< decltype(std::declval< T >().position.euclidean_distance(std::declval< T >().position))> >
 
struct  PositionXYAreDouble< T, typename >
 
struct  TripleSpline< T >
 
struct  PositionXYAreDouble< T, std::enable_if_t< std::is_same_v< decltype(std::declval< T >().position.x), double > &&std::is_same_v< decltype(std::declval< T >().position.y), double > > >
 

Functions

template<typename T >
std::vector< T > fit_spline (const std::vector< T > &path, int precision, int order, float coeffs_ratio)
 This function takes a sequence of points (T), fits a spline to them using B-spline basis functions, and returns the sequence of points that represent the fitted spline.
 
template<typename T >
TripleSpline< T > fit_triple_spline (const std::vector< T > &center, const std::vector< T > &left, const std::vector< T > &right, int precision, int order)
 This function takes three sequences of points (center, left, right), fits splines to them using GSL interpolation methods, and returns three sequences of points representing the fitted splines.
 

Function Documentation

◆ fit_spline()

template<typename T >
std::vector< T > fit_spline ( const std::vector< T > &  path,
int  precision,
int  order,
float  coeffs_ratio 
)

This function takes a sequence of points (T), fits a spline to them using B-spline basis functions, and returns the sequence of points that represent the fitted spline.

Template Parameters
TType of the elements in the input and output sequences. T must satisfy several requirements:
  • Default constructible
  • Hashable
  • Equality comparable
  • Has a position member
  • position has x and y members of type double
  • position has a euclidean_distance method
Parameters
pathSequence of points to fit the spline to.
precisionNumber of interpolated points between each pair of original points.
orderOrder of the B-spline.
coeffs_ratioRatio to determine the number of coefficients for the spline.
Returns
std::vector<T> Sequence of points representing the fitted spline.
Note
This function requires the GNU Scientific Library (GSL) for spline fitting.

Definition at line 130 of file splines.hpp.

Here is the caller graph for this function:

◆ fit_triple_spline()

template<typename T >
TripleSpline< T > fit_triple_spline ( const std::vector< T > &  center,
const std::vector< T > &  left,
const std::vector< T > &  right,
int  precision,
int  order 
)

This function takes three sequences of points (center, left, right), fits splines to them using GSL interpolation methods, and returns three sequences of points representing the fitted splines.

All three splines share the same parametric domain based on the center line's arc length.

Template Parameters
TType of the elements in the input and output sequences. T must satisfy several requirements:
  • Default constructible
  • Hashable
  • Equality comparable
  • Has a position member
  • position has x and y members of type double
  • position has a euclidean_distance method
Parameters
centerSequence of points representing the center line.
leftSequence of points representing the left boundary.
rightSequence of points representing the right boundary.
precisionNumber of interpolated points between each pair of original points.
orderOrder of the interpolation: 2=linear, 3=cubic spline
Returns
TripleSpline<T> Structure containing three spline sequences: center, left, and right.
Note
This function requires the GNU Scientific Library (GSL) for spline interpolation.
All three input sequences must have the same size and at least 2 points.

Definition at line 315 of file splines.hpp.

Here is the caller graph for this function: