hermite  0.0.1
Public Member Functions | List of all members
hermite::Cubic< D > Class Template Reference

A natural cubic spline. More...

#include <cubic.hpp>

Inheritance diagram for hermite::Cubic< D >:
Inheritance graph
[legend]
Collaboration diagram for hermite::Cubic< D >:
Collaboration graph
[legend]

Public Member Functions

 Cubic ()=default
 Default constructor. More...
 
 Cubic (const std::vector< Pose< D >> &waypoints)
 Constructor. More...
 
 Cubic (const Cubic< D > &other)
 Copy constructor.
 
Cubic< D > & operator= (const Cubic< D > &other)
 Assignment operator.
 
 ~Cubic () override=default
 Destructor.
 
std::vector< Pose< D > > getAllWaypoints () const
 Gets a list of all waypoints. More...
 
double getLowestTime () const override
 Gets the lower bound of the domain of the piecewise spline function, which is the first time (lowest t-value) listed in the waypoints. More...
 
double getHighestTime () const override
 Gets the upper bound of the domain of the piecewise spline function, which is the first time (lowest t-value) listed in the waypoints. More...
 
Vector< D > getPos (const double t) const override
 Gets position at a certain time. More...
 
Vector< D > getVel (const double t) const override
 Gets velocity at a certain time. More...
 
Vector< D > getAcc (const double t) const override
 Gets acceleration of the function at a certain time. More...
 
double getLength (const double timeStep) const override
 Gets arc length. More...
 
- Public Member Functions inherited from hermite::BaseSpline< D >
virtual ~BaseSpline ()=default
 Destructor.
 
double getMaxDistance (const double timeStep) const
 Gets maximum distance from origin. More...
 
double getMaxSpeed (const double timeStep) const
 Gets maximum speed. More...
 
double getMaxAcceleration (const double timeStep) const
 Gets maximum magnitude of acceleration. More...
 
- Public Member Functions inherited from hermite::BaseInterpol< D >
virtual ~BaseInterpol ()=default
 Destructor.
 
virtual Vector< D > operator() (const double t) const
 Gets value of the interpolation function at a certain point. More...
 

Detailed Description

template<std::size_t D>
class hermite::Cubic< D >

A natural cubic spline.

Given a set of poses, this class interpolates a path. However, only the velocity for the first and last poses need to be known. This class will determine velocities for the other positions such that the second derivatives match.

This class takes in an std::vector of poses and interpolates from that vector. This vector should be obtained using the Hermite class's Hermite::getAllWaypoints() method. Although the vector can be created yourself, you need to be careful and make sure there are no repeated points in time, or it may lead to undefined behavior.

The advantage of using this over Hermite is that you obtain C2 continuity. However, the path must be regenerated after changing one position, and it will affect the entire curve, giving up local control. Additionally, you cannot specify the velocities of the waypoints in between the start and end point.

Note that this class can be only used for one unique set of points. To use it for another set, it is highly recommended to insert/delete points from the Hermite class and use the output of Hermite::getAllWaypoints() to generate the points in the constructor to ensure defined behavior.

Constructor & Destructor Documentation

◆ Cubic() [1/2]

template<std::size_t D>
hermite::Cubic< D >::Cubic ( )
default

Default constructor.

Initializes with zero waypoints

◆ Cubic() [2/2]

template<std::size_t D>
hermite::Cubic< D >::Cubic ( const std::vector< Pose< D >> &  waypoints)
inline

Constructor.

It is highly recommended to insert the points in the Hermite class first, and then use the output of Hermite::getAllWaypoints() for the constructor.

Parameters
waypointsA list of waypoints
Note
Sorts the waypoints
Make sure that there are no two waypoints that share the same time, or there will be undefined behavior.

Member Function Documentation

◆ getAcc()

template<std::size_t D>
Vector<D> hermite::Cubic< D >::getAcc ( const double  t) const
inlineoverridevirtual

Gets acceleration of the function at a certain time.

Note
If time is outside the domain of time from the given points, then it calculates the value for the function whose domain is nearest to t.
If number of waypoints is less than or equal to 1, then returns a zero vector.
Parameters
tTime
Returns
Acceleration

Implements hermite::BaseSpline< D >.

◆ getAllWaypoints()

template<std::size_t D>
std::vector<Pose<D> > hermite::Cubic< D >::getAllWaypoints ( ) const
inline

Gets a list of all waypoints.

Returns
A list of all waypoints, sorted in order of time.

◆ getHighestTime()

template<std::size_t D>
double hermite::Cubic< D >::getHighestTime ( ) const
inlineoverridevirtual

Gets the upper bound of the domain of the piecewise spline function, which is the first time (lowest t-value) listed in the waypoints.

Note
If there are no waypoints, then returns 0
Assumes that the list was sorted from the constructor.
Returns
The last time measurement

Implements hermite::BaseSpline< D >.

◆ getLength()

template<std::size_t D>
double hermite::Cubic< D >::getLength ( const double  timeStep) const
inlineoverridevirtual

Gets arc length.

Parameters
timeStepThe time step to try for the arc length
Note
This function will take much longer for smaller timesteps. Recommended is between 0.001 and 0.1, but this also depends on the domain of your function.
If zero or one poses, returns 0.
Returns
Arc length

Implements hermite::BaseSpline< D >.

◆ getLowestTime()

template<std::size_t D>
double hermite::Cubic< D >::getLowestTime ( ) const
inlineoverridevirtual

Gets the lower bound of the domain of the piecewise spline function, which is the first time (lowest t-value) listed in the waypoints.

Note
If there are no waypoints, then returns 0
Assumes that the list was sorted from the constructor.
Returns
The first time measurement

Implements hermite::BaseSpline< D >.

◆ getPos()

template<std::size_t D>
Vector<D> hermite::Cubic< D >::getPos ( const double  t) const
inlineoverridevirtual

Gets position at a certain time.

Same as calling operator()()

Note
If time is outside the domain of time from the given points, then it calculates the value for the function whose domain is nearest to t.
If number of waypoints is less than or equal to 1, then returns a zero vector.
Parameters
tTime
Returns
Position

Implements hermite::BaseSpline< D >.

◆ getVel()

template<std::size_t D>
Vector<D> hermite::Cubic< D >::getVel ( const double  t) const
inlineoverridevirtual

Gets velocity at a certain time.

Note
If time is outside the domain of time from the given points, then it calculates the value for the function whose domain is nearest to t.
If number of waypoints is less than or equal to 1, then returns a zero vector.
Parameters
tTime
Returns
Velocity

Implements hermite::BaseSpline< D >.


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