Robotics Library  0.7.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
rl::math::Spline< T > Class Template Reference

A piecewise Function of Polynomial functions. More...

#include <Spline.h>

Inheritance diagram for rl::math::Spline< T >:
Inheritance graph
[legend]

Public Types

typedef ::std::vector< Polynomial< T > >::const_iterator ConstIterator
 
typedef ::std::vector< Polynomial< T > >::const_reverse_iterator ConstReverseIterator
 
typedef ::std::vector< Polynomial< T > >::iterator Iterator
 
typedef ::std::vector< Polynomial< T > >::reverse_iterator ReverseIterator
 

Public Member Functions

 Spline ()
 
virtual ~Spline ()
 
Polynomial< T > & at (const ::std::size_t &i)
 
const Polynomial< T > & at (const ::std::size_t &i) const
 
Polynomial< T > & back ()
 
const Polynomial< T > & back () const
 
Iterator begin ()
 
ConstIterator begin () const
 
void clear ()
 
Splineclone () const
 
Spline derivative () const
 
bool empty ()
 
Iterator end ()
 
ConstIterator end () const
 
Polynomial< T > & front ()
 
const Polynomial< T > & front () const
 
getAbsoluteMaximum () const
 Returns the array of the maximum function values of each dimension within the definition range, not regarding the sign of the function values. More...
 
bool isContinuous (const ::std::size_t &upToDerivative=1) const
 Verifies that the spline is smooth and has no jumps at the piecewise function boundaries. More...
 
operator() (const Real &x, const ::std::size_t &derivative=0) const
 Evaluates the function or a derivative thereof for a given value x. More...
 
Polynomial< T > & operator[] (const ::std::size_t &i)
 
const Polynomial< T > & operator[] (const ::std::size_t &i) const
 
void pop_back ()
 
void push_back (Polynomial< T > &polynomial)
 
void push_back (Spline &spline)
 
Spline scaledX (const Real &factor) const
 Stretches the x-axis of a spline by a given factor. More...
 
::std::size_t size () const
 
ReverseIterator rbegin ()
 
ConstReverseIterator rbegin () const
 
ReverseIterator rend ()
 
ConstReverseIterator rend () const
 
- Public Member Functions inherited from rl::math::Function< T >
 Function ()
 
virtual ~Function ()
 
Real duration () const
 
Reallower ()
 
const Reallower () const
 
Realupper ()
 
const Realupper () const
 

Static Public Member Functions

template<typename Container1 , typename Container2 >
static Spline LinearParabolic (const Container1 &x, const Container2 &y, const Real &parabolicInterval)
 Generates a piecewise spline with parabolic segments around the given supporting points y and linear segments in between. More...
 
template<typename Container1 , typename Container2 >
static Spline LinearQuartic (const Container1 &x, const Container2 &y, const Real &quarticInterval)
 Generates a piecewise spline with quartic polynomial segments around the given supporting points y and linear segments in between. More...
 
template<typename Container1 , typename Container2 >
static Spline LinearSextic (const Container1 &x, const Container2 &y, const Real &sexticInterval)
 Generates a piecewise spline with sextic polynomial segments around the given supporting points y and linear segments in between. More...
 
template<typename U = T>
static Spline QuarticLinearQuarticAtRest (const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &q0, const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &q1, const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &vmax, const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &amax)
 Generates a spline of polynomials of degrees 4-1-4 from rest to rest for one dimension. More...
 
template<typename U = T>
static Spline QuarticLinearQuarticAtRest (const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &q0, const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &q1, const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &vmax, const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &amax)
 Generates a spline of polynomials of degrees 4-1-4 from rest to rest that is phase-synchronized for multiple degree-of-freedoms. More...
 
template<typename U = T>
static Spline SexticLinearSexticAtRest (const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &q0, const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &q1, const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &vmax, const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &amax)
 Generates a spline of polynomials of degrees 6-1-6 from rest to rest for one dimension. More...
 
template<typename U = T>
static Spline SexticLinearSexticAtRest (const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &q0, const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &q1, const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &vmax, const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &amax)
 Generates a spline of polynomials of degrees 6-1-6 from rest to rest that is phase-synchronized for multiple degree-of-freedoms. More...
 
static Spline TrapeziodalAccelerationAtRest (const T &q0, const T &q1, const T &vmax, const T &amax, const T &jmax)
 Generates a trapezoidal acceleration trajectory from rest to rest for multiple dimensions that are phase-synchronized. More...
 

Protected Attributes

::std::vector< Polynomial< T > > polynomials
 
- Protected Attributes inherited from rl::math::Function< T >
Real x0
 
Real x1
 

Detailed Description

template<typename T>
class rl::math::Spline< T >

A piecewise Function of Polynomial functions.

A Spline is a function that consists of a list of polynomials, which may have different degrees. It is indefinitely often differentiable, and can be scaled algebraically. As all children of Function, its is mapping Real -> T, but a Spline is only defined in the interval [lower() upper()].

See also
Polynomial

Member Typedef Documentation

◆ ConstIterator

template<typename T >
typedef ::std::vector<Polynomial<T> >::const_iterator rl::math::Spline< T >::ConstIterator

◆ ConstReverseIterator

template<typename T >
typedef ::std::vector<Polynomial<T> >::const_reverse_iterator rl::math::Spline< T >::ConstReverseIterator

◆ Iterator

template<typename T >
typedef ::std::vector<Polynomial<T> >::iterator rl::math::Spline< T >::Iterator

◆ ReverseIterator

template<typename T >
typedef ::std::vector<Polynomial<T> >::reverse_iterator rl::math::Spline< T >::ReverseIterator

Constructor & Destructor Documentation

◆ Spline()

template<typename T >
rl::math::Spline< T >::Spline ( )
inline

◆ ~Spline()

template<typename T >
virtual rl::math::Spline< T >::~Spline ( )
inlinevirtual

Member Function Documentation

◆ at() [1/2]

template<typename T >
Polynomial<T>& rl::math::Spline< T >::at ( const ::std::size_t &  i)
inline

◆ at() [2/2]

template<typename T >
const Polynomial<T>& rl::math::Spline< T >::at ( const ::std::size_t &  i) const
inline

◆ back() [1/2]

template<typename T >
Polynomial<T>& rl::math::Spline< T >::back ( )
inline

◆ back() [2/2]

template<typename T >
const Polynomial<T>& rl::math::Spline< T >::back ( ) const
inline

◆ begin() [1/2]

template<typename T >
Iterator rl::math::Spline< T >::begin ( )
inline

◆ begin() [2/2]

template<typename T >
ConstIterator rl::math::Spline< T >::begin ( ) const
inline

◆ clear()

template<typename T >
void rl::math::Spline< T >::clear ( )
inline

◆ clone()

template<typename T >
Spline* rl::math::Spline< T >::clone ( ) const
inlinevirtual

◆ derivative()

template<typename T >
Spline rl::math::Spline< T >::derivative ( ) const
inline

◆ empty()

template<typename T >
bool rl::math::Spline< T >::empty ( )
inline

◆ end() [1/2]

template<typename T >
Iterator rl::math::Spline< T >::end ( )
inline

◆ end() [2/2]

template<typename T >
ConstIterator rl::math::Spline< T >::end ( ) const
inline

◆ front() [1/2]

template<typename T >
Polynomial<T>& rl::math::Spline< T >::front ( )
inline

◆ front() [2/2]

template<typename T >
const Polynomial<T>& rl::math::Spline< T >::front ( ) const
inline

◆ getAbsoluteMaximum()

template<typename T >
T rl::math::Spline< T >::getAbsoluteMaximum ( ) const
inline

Returns the array of the maximum function values of each dimension within the definition range, not regarding the sign of the function values.

For polynomials higher than cubics, Eigen::PolynomialSolver is required and calculations become iterative, without guaranteeing convergence. A common use case is to verify speed limits with the comparison (trajectory.derivate().getAbsoluteMaximum() < maximumSpeed).all()

◆ isContinuous()

template<typename T >
bool rl::math::Spline< T >::isContinuous ( const ::std::size_t &  upToDerivative = 1) const
inline

Verifies that the spline is smooth and has no jumps at the piecewise function boundaries.

Mathematically, it checks whether the spline and a certain number of its derivatives are continuous.

Parameters
[in]upToDerivativeSets the number of derivatives that are also checked for continuity.

◆ LinearParabolic()

template<typename T >
template<typename Container1 , typename Container2 >
static Spline rl::math::Spline< T >::LinearParabolic ( const Container1 &  x,
const Container2 &  y,
const Real parabolicInterval 
)
inlinestatic

Generates a piecewise spline with parabolic segments around the given supporting points y and linear segments in between.

Note that the duration of the returned Spline is longer than the given x, because there is one parabolic interval more than segments in x.

Parameters
[in]parabolicIntervalGives the duration of a parabolic interval, the following linear interval then has a duration of x(n+1) - x(n) - parabolicInterval

◆ LinearQuartic()

template<typename T >
template<typename Container1 , typename Container2 >
static Spline rl::math::Spline< T >::LinearQuartic ( const Container1 &  x,
const Container2 &  y,
const Real quarticInterval 
)
inlinestatic

Generates a piecewise spline with quartic polynomial segments around the given supporting points y and linear segments in between.

Note that the duration of the returned Spline is longer than the given x, because there is one quartic polynomial interval more than segments in x.

Parameters
[in]quarticIntervalGives the duration of a quartic interval, the following linear interval then has a duration of x(n+1) - x(n) - quarticInterval

◆ LinearSextic()

template<typename T >
template<typename Container1 , typename Container2 >
static Spline rl::math::Spline< T >::LinearSextic ( const Container1 &  x,
const Container2 &  y,
const Real sexticInterval 
)
inlinestatic

Generates a piecewise spline with sextic polynomial segments around the given supporting points y and linear segments in between.

Note that the duration of the returned Spline is longer than the given x, because there is one sextic polynomial interval more than segments in x.

Parameters
[in]sexticIntervalGives the duration of a sextic interval, the following linear interval then has a duration of x(n+1) - x(n) - sexticInterval

◆ operator()()

template<typename T >
T rl::math::Spline< T >::operator() ( const Real x,
const ::std::size_t &  derivative = 0 
) const
inlinevirtual

Evaluates the function or a derivative thereof for a given value x.

Some functions are only defined in the interval [lower(), upper()], and fail to evaluate outside of [lower() - FUNCTION_BOUNDARY, upper() + FUNCTION_BOUNDARY]. In Debug mode, this is signaled by failing asserts. In Release mode, the function is evaluated if algebraically possible, or will return an empty ArrayX otherwise. Some functions are not indefinitely often differentiable, and will return a NaN array for all higher orders.

Parameters
[in]xInput value of the function or derivative
[in]derivativeOrder of the derivative to be evaluated

Implements rl::math::Function< T >.

◆ operator[]() [1/2]

template<typename T >
Polynomial<T>& rl::math::Spline< T >::operator[] ( const ::std::size_t &  i)
inline

◆ operator[]() [2/2]

template<typename T >
const Polynomial<T>& rl::math::Spline< T >::operator[] ( const ::std::size_t &  i) const
inline

◆ pop_back()

template<typename T >
void rl::math::Spline< T >::pop_back ( )
inline

◆ push_back() [1/2]

template<typename T >
void rl::math::Spline< T >::push_back ( Polynomial< T > &  polynomial)
inline

◆ push_back() [2/2]

template<typename T >
void rl::math::Spline< T >::push_back ( Spline< T > &  spline)
inline

◆ QuarticLinearQuarticAtRest() [1/2]

template<typename T >
template<typename U = T>
static Spline rl::math::Spline< T >::QuarticLinearQuarticAtRest ( const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &  q0,
const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &  q1,
const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &  vmax,
const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &  amax 
)
inlinestatic

Generates a spline of polynomials of degrees 4-1-4 from rest to rest that is phase-synchronized for multiple degree-of-freedoms.

Its acceleration and deceleration segments are parabolic and at least one degree-of-freedon reaches its maximum acceleration amax. vmax may or may not be reached; in the latter case, the linear segment is omitted. The result is the shortest synchronized 4-1-4 spline with continuous acceleration.

◆ QuarticLinearQuarticAtRest() [2/2]

template<typename T >
template<typename U = T>
static Spline rl::math::Spline< T >::QuarticLinearQuarticAtRest ( const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &  q0,
const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &  q1,
const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &  vmax,
const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &  amax 
)
inlinestatic

Generates a spline of polynomials of degrees 4-1-4 from rest to rest for one dimension.

Its acceleration and deceleration segments are parabolic and reach amax. vmax may or may not be reached; in the latter case, the linear segment is omitted. The result is the shortest such 4-1-4 spline with continuous acceleration.

◆ rbegin() [1/2]

template<typename T >
ReverseIterator rl::math::Spline< T >::rbegin ( )
inline

◆ rbegin() [2/2]

template<typename T >
ConstReverseIterator rl::math::Spline< T >::rbegin ( ) const
inline

◆ rend() [1/2]

template<typename T >
ReverseIterator rl::math::Spline< T >::rend ( )
inline

◆ rend() [2/2]

template<typename T >
ConstReverseIterator rl::math::Spline< T >::rend ( ) const
inline

◆ scaledX()

template<typename T >
Spline rl::math::Spline< T >::scaledX ( const Real factor) const
inline

Stretches the x-axis of a spline by a given factor.

The returned, scaled spline s' of a given spline s fulfills s'(x * factor) = s(x), and s'.duration() = factor * s.duration(). This is done by recalculating the underlying polynomial coefficients.

◆ SexticLinearSexticAtRest() [1/2]

template<typename T >
template<typename U = T>
static Spline rl::math::Spline< T >::SexticLinearSexticAtRest ( const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &  q0,
const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &  q1,
const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &  vmax,
const typename ::std::enable_if< ::std::is_class< U >::value, U >::type &  amax 
)
inlinestatic

Generates a spline of polynomials of degrees 6-1-6 from rest to rest that is phase-synchronized for multiple degree-of-freedoms.

Its acceleration and deceleration segments are quartic and at least one degree-of-freedon reaches its maximum acceleration amax. vmax may or may not be reached; in the latter case, the linear segment is omitted. The result is the shortest synchronized 6-1-6 spline with continuous jerk.

◆ SexticLinearSexticAtRest() [2/2]

template<typename T >
template<typename U = T>
static Spline rl::math::Spline< T >::SexticLinearSexticAtRest ( const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &  q0,
const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &  q1,
const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &  vmax,
const typename ::std::enable_if< ::std::is_floating_point< U >::value, U >::type &  amax 
)
inlinestatic

Generates a spline of polynomials of degrees 6-1-6 from rest to rest for one dimension.

Its acceleration and deceleration segments are quartic and reach amax. vmax may or may not be reached; in the latter case, the linear segment is omitted. Compared to QuarticLinearQuarticAtRest, SexticLinearSexticAtRest makes sure the jerk is continuous, which results in a smoother and slightly longer trajectory. The result is the shortest such 6-1-6 spline.

◆ size()

template<typename T >
::std::size_t rl::math::Spline< T >::size ( ) const
inline

◆ TrapeziodalAccelerationAtRest()

template<typename T >
static Spline rl::math::Spline< T >::TrapeziodalAccelerationAtRest ( const T &  q0,
const T &  q1,
const T &  vmax,
const T &  amax,
const T &  jmax 
)
inlinestatic

Generates a trapezoidal acceleration trajectory from rest to rest for multiple dimensions that are phase-synchronized.

A trapezoidal acceleration trajectory has up to seven segments of constant jerk. Its velocity curve is double-S shaped.

see L. Biagiotti, C. Melchiorri (2008) "Trajectory Planning for Automatic Machines and Robots", pp. 90ff.

Member Data Documentation

◆ polynomials

template<typename T >
::std::vector<Polynomial<T> > rl::math::Spline< T >::polynomials
protected

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