Aikido
aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots > Class Template Reference

An arbitrary dimensional polynomial spline. More...

#include <aikido/common/Spline.hpp>

Public Types

using Scalar = _Scalar
 
using Index = _Index
 
using TimeVector = Eigen::Matrix< Scalar, NumKnotsAtCompileTime, 1 >
 
using SolutionMatrix = Eigen::Matrix< Scalar, NumOutputsAtCompileTime, NumCoefficientsAtCompileTime >
 
using OutputVector = Eigen::Matrix< Scalar, NumOutputsAtCompileTime, 1 >
 
using SolutionMatrices = std::vector< SolutionMatrix, Eigen::aligned_allocator< SolutionMatrix > >
 

Public Member Functions

 SplineND ()=default
 Constructs an empty spline. More...
 
 SplineND (const TimeVector &_times, const std::vector< SolutionMatrix, Eigen::aligned_allocator< SolutionMatrix > > &_solution)
 Constructs a spline with the specified coefficients. More...
 
 SplineND (SplineND &&_other)=default
 
 SplineND (const SplineND &_other)=default
 
SplineNDoperator= (SplineND &&_other)=default
 
SplineNDoperator= (const SplineND &_other)=default
 
void setTime (Index _index, Scalar _t)
 Sets the time of the _index-th knot point. More...
 
void setTimes (TimeVector &&_t)
 Sets the times of all knot points. More...
 
void setTimes (const TimeVector &_t)
 Sets the times of all knot points. More...
 
const TimeVectorgetTimes () const
 Gets times of all knot points. More...
 
const SolutionMatricesgetCoefficients () const
 Gets polynomial coefficients for all segments. More...
 
Index getNumKnots () const
 Gets the number of knot points. More...
 
Index getNumOutputs () const
 Gets the number of outputs points. More...
 
Index getNumDerivatives () const
 Gets an upperbound on the number of non-zero derivatives. More...
 
Index getNumCoefficients () const
 Gets the number of polynomial coefficients in each segment. More...
 
Scalar getDuration () const
 Gets the duration of the spline. More...
 
Index getSegmentIndex (Scalar _t) const
 Gets the index of the segment that contains time _t. More...
 
OutputVector evaluate (Scalar _t, Index _derivative=0) const
 Evaluate the _derivative-th order of the spline at time _t. More...
 

Static Public Attributes

static constexpr Index NumCoefficientsAtCompileTime = _NumCoefficients
 
static constexpr Index NumOutputsAtCompileTime = _NumOutputs
 
static constexpr Index NumKnotsAtCompileTime = _NumKnots
 
static constexpr Index NumSegmentsAtCompileTime
 
static constexpr Index DimensionAtCompileTime
 

Private Types

using CoefficientVector = Eigen::Matrix< Scalar, NumCoefficientsAtCompileTime, 1 >
 
using CoefficientMatrix = Eigen::Matrix< Scalar, NumCoefficientsAtCompileTime, NumCoefficientsAtCompileTime >
 

Private Attributes

TimeVector mTimes
 
SolutionMatrices mSolution
 

Detailed Description

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
class aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >

An arbitrary dimensional polynomial spline.

The number of coefficients, outputs, and knot points may be specified either at compile time (via template parameters) or at runtime (if the template parameters are Eigen::Dynamic). We suggest setting as many of these parameters at compile time as possible for best performance.

Note that this spline is not guaranteed to be continuous at knot points; this is the responsbility of the user who constructs the splines coefficients. See SplineProblem for a helper class that constructs a continuous spline from a set of constraints.

Template Parameters
_Scalarfloating type used to represent a scalar value
_Indexintegral type used to represent an index
_NumCoefficientsnumber of polynomial coefficients, or Dynamic
_NumOutputsnumber of outputs, or Dynamic
_NumKnotsnumber of knots, or Dynamic

Member Typedef Documentation

◆ CoefficientMatrix

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
using aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::CoefficientMatrix = Eigen::Matrix< Scalar, NumCoefficientsAtCompileTime, NumCoefficientsAtCompileTime>
private

◆ CoefficientVector

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
using aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::CoefficientVector = Eigen::Matrix<Scalar, NumCoefficientsAtCompileTime, 1>
private

◆ Index

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
using aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::Index = _Index

◆ OutputVector

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
using aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::OutputVector = Eigen::Matrix<Scalar, NumOutputsAtCompileTime, 1>

◆ Scalar

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
using aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::Scalar = _Scalar

◆ SolutionMatrices

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
using aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::SolutionMatrices = std::vector<SolutionMatrix, Eigen::aligned_allocator<SolutionMatrix> >

◆ SolutionMatrix

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
using aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::SolutionMatrix = Eigen:: Matrix<Scalar, NumOutputsAtCompileTime, NumCoefficientsAtCompileTime>

◆ TimeVector

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
using aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::TimeVector = Eigen::Matrix<Scalar, NumKnotsAtCompileTime, 1>

Constructor & Destructor Documentation

◆ SplineND() [1/4]

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::SplineND ( )
default

Constructs an empty spline.

◆ SplineND() [2/4]

template<class Scalar , class Index , Index _NumCoefficients, Index _NumOutputs, Index _NumKnots>
aikido::common::SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::SplineND ( const TimeVector _times,
const std::vector< SolutionMatrix, Eigen::aligned_allocator< SolutionMatrix > > &  _solution 
)

Constructs a spline with the specified coefficients.

The _solution is a vector of _times.size() - 1 spline coefficients, where the i-th matrix defines the polynomial coefficients for the segment between knot points (i) and (i + 1). Each coefficient matrix of size (num outputs) x (num coefficients), where element (i, j) is the coefficient on the x^j term for output i.

Parameters
_timestimes of knot points, must be monotone increasing
_solutionlist of polynomial coefficients for each segment

◆ SplineND() [3/4]

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::SplineND ( SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots > &&  _other)
default

◆ SplineND() [4/4]

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::SplineND ( const SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots > &  _other)
default

Member Function Documentation

◆ evaluate()

template<class Scalar , class Index , Index _NumCoefficients, Index _NumOutputs, Index _NumKnots>
auto aikido::common::SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::evaluate ( Scalar  _t,
Index  _derivative = 0 
) const

Evaluate the _derivative-th order of the spline at time _t.

The zero-th order derivative is function value. All derivatives greater than getNumDerivatives() are guaranteed to be zero.

Parameters
_ttime parameter
_derivativeorder of derivative to evaluate
Returns
value of the specified derivative at time _t

◆ getCoefficients()

template<class Scalar , class Index , Index _NumCoefficients, Index _NumOutputs, Index _NumKnots>
auto aikido::common::SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::getCoefficients

Gets polynomial coefficients for all segments.

Returns
polynomial coefficients

◆ getDuration()

template<class Scalar , class Index , Index _NumCoefficients, Index _NumOutputs, Index _NumKnots>
Scalar aikido::common::SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::getDuration

Gets the duration of the spline.

This is the difference between the time of the first and last knot points.

Returns
duration of the spline

◆ getNumCoefficients()

template<class Scalar , class Index , Index _NumCoefficients, Index _NumOutputs, Index _NumKnots>
Index aikido::common::SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::getNumCoefficients

Gets the number of polynomial coefficients in each segment.

Returns
number of polynomial coefficients

◆ getNumDerivatives()

template<class Scalar , class Index , Index _NumCoefficients, Index _NumOutputs, Index _NumKnots>
Index aikido::common::SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::getNumDerivatives

Gets an upperbound on the number of non-zero derivatives.

Returns
upper bound on the number of non-zero derivatives

◆ getNumKnots()

template<class Scalar , class Index , Index _NumCoefficients, Index _NumOutputs, Index _NumKnots>
Index aikido::common::SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::getNumKnots

Gets the number of knot points.

Returns
number of knot points

◆ getNumOutputs()

template<class Scalar , class Index , Index _NumCoefficients, Index _NumOutputs, Index _NumKnots>
Index aikido::common::SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::getNumOutputs

Gets the number of outputs points.

Returns
number of outputs points

◆ getSegmentIndex()

template<class Scalar , class Index , Index _NumCoefficients, Index _NumOutputs, Index _NumKnots>
auto aikido::common::SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::getSegmentIndex ( Scalar  _t) const

Gets the index of the segment that contains time _t.

Parameters
_ttime parameter
Returns
index of the segment that contains this time

◆ getTimes()

template<class Scalar , class Index , Index _NumCoefficients, Index _NumOutputs, Index _NumKnots>
auto aikido::common::SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::getTimes

Gets times of all knot points.

Returns
times of knot points

◆ operator=() [1/2]

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
SplineND& aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::operator= ( const SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots > &  _other)
default

◆ operator=() [2/2]

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
SplineND& aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::operator= ( SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots > &&  _other)
default

◆ setTime()

template<class Scalar , class Index , Index _NumCoefficients, Index _NumOutputs, Index _NumKnots>
void aikido::common::SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::setTime ( Index  _index,
Scalar  _t 
)

Sets the time of the _index-th knot point.

Times must remain monotone after performing this operation.

Parameters
_indexindex of a knot point
_tnew time for that knot point

◆ setTimes() [1/2]

template<class Scalar , class Index , Index _NumCoefficients, Index _NumOutputs, Index _NumKnots>
void aikido::common::SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::setTimes ( const TimeVector _t)

Sets the times of all knot points.

Parameters
_tnew times, must be monotone increasing

◆ setTimes() [2/2]

template<class Scalar , class Index , Index _NumCoefficients, Index _NumOutputs, Index _NumKnots>
void aikido::common::SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::setTimes ( TimeVector &&  _t)

Sets the times of all knot points.

Parameters
_tnew times, must be monotone increasing

Member Data Documentation

◆ DimensionAtCompileTime

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
constexpr Index aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::DimensionAtCompileTime
staticconstexpr
Initial value:
= (NumSegmentsAtCompileTime != Eigen::Dynamic
&& _NumCoefficients != Eigen::Dynamic)
: Eigen::Dynamic

◆ mSolution

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
SolutionMatrices aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::mSolution
private

◆ mTimes

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
TimeVector aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::mTimes
private

◆ NumCoefficientsAtCompileTime

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
constexpr Index aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::NumCoefficientsAtCompileTime = _NumCoefficients
staticconstexpr

◆ NumKnotsAtCompileTime

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
constexpr Index aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::NumKnotsAtCompileTime = _NumKnots
staticconstexpr

◆ NumOutputsAtCompileTime

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
constexpr Index aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::NumOutputsAtCompileTime = _NumOutputs
staticconstexpr

◆ NumSegmentsAtCompileTime

template<class _Scalar = double, class _Index = int, _Index _NumCoefficients = Eigen::Dynamic, _Index _NumOutputs = Eigen::Dynamic, _Index _NumKnots = Eigen::Dynamic>
constexpr Index aikido::common::SplineND< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::NumSegmentsAtCompileTime
staticconstexpr
Initial value:
= (_NumKnots != Eigen::Dynamic) ? (NumKnotsAtCompileTime - 1)
: Eigen::Dynamic
aikido::common::SplineND::NumSegmentsAtCompileTime
static constexpr Index NumSegmentsAtCompileTime
Definition: Spline.hpp:48
aikido::common::SplineND::NumCoefficientsAtCompileTime
static constexpr Index NumCoefficientsAtCompileTime
Definition: Spline.hpp:44
aikido::common::SplineND::NumKnotsAtCompileTime
static constexpr Index NumKnotsAtCompileTime
Definition: Spline.hpp:46