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

Hermite spline class. More...

#include <hermite.hpp>

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

Public Member Functions

 Hermite ()
 Default constructor. More...
 
 Hermite (const double multiplier)
 Constructor. More...
 
 Hermite (const Hermite< D > &other)
 Copy constructor.
 
Hermite< D > & operator= (const Hermite< D > &other)
 Assignment operator. More...
 
 ~Hermite () override=default
 Destructor.
 
void insert (const Pose< D > &waypoint)
 Inserts a waypoint. More...
 
void replace (const Pose< D > &waypoint)
 Replaces a waypoint. More...
 
void insertOrReplace (const Pose< D > &waypoint)
 Inserts a waypoint if it doesn't exist, otherwise replaces the waypoint. More...
 
bool exists (const Pose< D > &waypoint) const
 Checks if a waypoint exists. More...
 
bool exists (const double time) const
 Checks if a waypoint at a certain time exists. More...
 
void erase (const Pose< D > &waypoint)
 Removes a waypoint. More...
 
void erase (const double time)
 Removes a waypoint. More...
 
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 last time (highest 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::Hermite< D >

Hermite spline class.

Given a set of poses (i.e. a desired position and velocity at a certain time), this class interpolates a path between these poses by using Hermite splines. It does this by interpolating a Hermite function between each pose using HermiteSub, and matching the final position and velocity of one pose with the initial position and velocity of the next.

This class can work with multiple dimensions, specified in the template argument. For example, if the path you want to interpolate is 2-dimensional, then specify "2" in the template argument.

This class acts like a std::map, where the key is the time. This is to ensure maximum efficiency inserting, removing, changing, and searching for the interpoloation equations. However, because time is a floating point number, and they are always imprecise, it needs to be converted into an integer. It does this by multiplying the time by a certain multiplier and truncating the rest of the digits. This is fine for most cases, as the time does not need to be super precise.

Hermite curves allow for fast local control, meaning that inserting and removing points is quick. However, it only provides C1 continuity, which means that there may be high jerk at knot points (as acceleration is discontinuous).

Constructor & Destructor Documentation

◆ Hermite() [1/2]

template<std::size_t D>
hermite::Hermite< D >::Hermite ( )
inline

Default constructor.

Sets multiplier to 10, meaning that it shifts the decimal place of the given time by 1 digit before truncating the rest of the number whenever it is stored as a waypoint.

◆ Hermite() [2/2]

template<std::size_t D>
hermite::Hermite< D >::Hermite ( const double  multiplier)
inline

Constructor.

Parameters
multiplierMultiplies the time given in the pose by the multiplier, then truncates the rest of the digits when storing the waypoint.

Member Function Documentation

◆ erase() [1/2]

template<std::size_t D>
void hermite::Hermite< D >::erase ( const double  time)
inline

Removes a waypoint.

Parameters
timeTime of waypoint to remove
Note
The waypoint's time is rounded by using the multplier
If the waypoint's time is not precise enough, then this may erase a waypoint even though it might not be intended.

◆ erase() [2/2]

template<std::size_t D>
void hermite::Hermite< D >::erase ( const Pose< D > &  waypoint)
inline

Removes a waypoint.

Parameters
waypointWaypoint to remove
Note
Only the waypoint's time is used in this method.
The waypoint's time is rounded by using the multplier
If the waypoint's time is not precise enough, then this may erase a waypoint even though it might not be intended.

◆ exists() [1/2]

template<std::size_t D>
bool hermite::Hermite< D >::exists ( const double  time) const
inline

Checks if a waypoint at a certain time exists.

Parameters
timeChecks if a waypoint exists at this time
Returns
If waypoint exists.

◆ exists() [2/2]

template<std::size_t D>
bool hermite::Hermite< D >::exists ( const Pose< D > &  waypoint) const
inline

Checks if a waypoint exists.

Parameters
waypointChecks if this waypoint exists
Note
Only uses the time argument of the waypoint.
Returns
If waypoint exists.

◆ getAcc()

template<std::size_t D>
Vector<D> hermite::Hermite< 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.
If called on a border between two functions, will take the value of the latter function.
Parameters
tTime
Returns
Acceleration

Implements hermite::BaseSpline< D >.

◆ getAllWaypoints()

template<std::size_t D>
std::vector<Pose<D> > hermite::Hermite< 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::Hermite< D >::getHighestTime ( ) const
inlineoverridevirtual

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

Note
If there are no waypoints, then returns 0
Returns
The last time measurement

Implements hermite::BaseSpline< D >.

◆ getLength()

template<std::size_t D>
double hermite::Hermite< 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::Hermite< 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
Returns
The first time measurement

Implements hermite::BaseSpline< D >.

◆ getPos()

template<std::size_t D>
Vector<D> hermite::Hermite< 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::Hermite< 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 >.

◆ insert()

template<std::size_t D>
void hermite::Hermite< D >::insert ( const Pose< D > &  waypoint)
inline

Inserts a waypoint.

Parameters
waypointWaypoint to insert
Note
If the waypoint's time exists (rounded according to the multiplier), then this method does nothing.

◆ insertOrReplace()

template<std::size_t D>
void hermite::Hermite< D >::insertOrReplace ( const Pose< D > &  waypoint)
inline

Inserts a waypoint if it doesn't exist, otherwise replaces the waypoint.

Parameters
waypointWaypoint to insert or replace

◆ operator=()

template<std::size_t D>
Hermite<D>& hermite::Hermite< D >::operator= ( const Hermite< D > &  other)
inline

Assignment operator.

Note
All data stored in current Hermite object will be lost.

◆ replace()

template<std::size_t D>
void hermite::Hermite< D >::replace ( const Pose< D > &  waypoint)
inline

Replaces a waypoint.

Parameters
waypointWaypoint to replace
Note
Gets the time from the waypoint.
If the waypoint does not exist, then this method does not change anything.

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