Aikido
|
Utility for fitting splines given constraints on function value, derivative value, and continuity. More...
#include <aikido/common/Spline.hpp>
Public Types | |
using | Scalar = _Scalar |
using | Index = _Index |
using | TimeVector = Eigen::Matrix< Scalar, NumKnotsAtCompileTime, 1 > |
using | OutputVector = Eigen::Matrix< Scalar, NumOutputsAtCompileTime, 1 > |
using | OutputMatrix = Eigen::Matrix< Scalar, NumCoefficientsAtCompileTime, NumOutputsAtCompileTime > |
using | CoefficientVector = Eigen::Matrix< Scalar, NumCoefficientsAtCompileTime, 1 > |
using | CoefficientMatrix = Eigen::Matrix< Scalar, NumCoefficientsAtCompileTime, NumCoefficientsAtCompileTime > |
using | ProblemMatrix = Eigen::SparseMatrix< Scalar, 0, Index > |
using | ProblemVector = Eigen::Matrix< Scalar, DimensionAtCompileTime, NumOutputsAtCompileTime > |
using | SolutionMatrix = Eigen::Matrix< Scalar, NumOutputsAtCompileTime, NumCoefficientsAtCompileTime > |
using | Spline = SplineND< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots > |
Public Member Functions | |
SplineProblem (const TimeVector &_times) | |
Constructs a spline fitting problem with the knot points at the specified times. More... | |
SplineProblem (const TimeVector &_times, Index _numCoefficients, Index _numOutputs) | |
Constructs a spline fitting problem with knot points at the specified times and the specified number of coefficients and outputs. More... | |
SplineProblem (SplineProblem &&_other)=default | |
SplineProblem (const SplineProblem &_other)=default | |
SplineProblem & | operator= (SplineProblem &&_other)=default |
SplineProblem & | operator= (const SplineProblem &_other)=default |
void | addConstantConstraint (Index _knot, Index _derivative, const OutputVector &_value) |
Adds a constraint that the _derivative-th order derivative of knot point _knot should equal _value . More... | |
void | addContinuityConstraint (Index _knot, Index _derivative) |
Adds a continuity constraint on the _derivative-th order derivative at knot point _knot . More... | |
Spline | fit () |
Fit a spline given the constraints on added to this object. More... | |
Index | getNumKnots () const |
Gets the number of knot points. More... | |
Index | getNumOutputs () const |
Gets the number of outputs points. More... | |
Scalar | getDuration () const |
Gets the duration of the spline. More... | |
Static Public Member Functions | |
static CoefficientVector | createTimeVector (Scalar _t, Index _i, Index _n) |
Creates a vector of the form [ 1, t, t^2, ... t^_n ]. More... | |
static CoefficientMatrix | createCoefficientMatrix (Index _n) |
Creates the _n by _n matrix of derivative coefficients for a polynomial with _n coefficients. 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 Attributes | |
Index | mNumKnots |
Index | mNumSegments |
Index | mNumCoefficients |
Index | mNumOutputs |
Index | mDimension |
CoefficientMatrix | mCoefficientMatrix |
Index | mRowIndex |
TimeVector | mTimes |
ProblemMatrix | mA |
ProblemVector | mB |
std::vector< SolutionMatrix, Eigen::aligned_allocator< SolutionMatrix > > | mSolution |
Utility for fitting splines given constraints on function value, derivative value, and continuity.
This class is intended to be used by calling methods to add constraints to the spline, then calling fit()
to find spline coefficients that satisfy those constraints.
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.
_Scalar | floating type used to represent a scalar value |
_Index | integral type used to represent an index |
_NumCoefficients | number of polynomial coefficients, or Dynamic |
_NumOutputs | number of outputs, or Dynamic |
_NumKnots | number of knots, or Dynamic |
using aikido::common::SplineProblem< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::CoefficientMatrix = Eigen::Matrix< Scalar, NumCoefficientsAtCompileTime, NumCoefficientsAtCompileTime> |
using aikido::common::SplineProblem< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::CoefficientVector = Eigen::Matrix<Scalar, NumCoefficientsAtCompileTime, 1> |
using aikido::common::SplineProblem< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::Index = _Index |
using aikido::common::SplineProblem< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::OutputMatrix = Eigen:: Matrix<Scalar, NumCoefficientsAtCompileTime, NumOutputsAtCompileTime> |
using aikido::common::SplineProblem< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::OutputVector = Eigen::Matrix<Scalar, NumOutputsAtCompileTime, 1> |
using aikido::common::SplineProblem< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::ProblemMatrix = Eigen::SparseMatrix<Scalar, 0, Index> |
using aikido::common::SplineProblem< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::ProblemVector = Eigen::Matrix<Scalar, DimensionAtCompileTime, NumOutputsAtCompileTime> |
using aikido::common::SplineProblem< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::Scalar = _Scalar |
using aikido::common::SplineProblem< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::SolutionMatrix = Eigen:: Matrix<Scalar, NumOutputsAtCompileTime, NumCoefficientsAtCompileTime> |
using aikido::common::SplineProblem< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::Spline = SplineND<Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots> |
using aikido::common::SplineProblem< _Scalar, _Index, _NumCoefficients, _NumOutputs, _NumKnots >::TimeVector = Eigen::Matrix<Scalar, NumKnotsAtCompileTime, 1> |
|
explicit |
Constructs a spline fitting problem with the knot points at the specified times.
This overload is only supported if _NumCoefficients
and _NumOutputs
are specified as template parameters. The length of _times
must equal _NumKnots
if that template parameter is specified
If _NumCoefficients
or _NumOutputs
is Eigen::Dynamic
, you must use the other constructor overload.
_times | list of knot point times, must be monotone increasing |
aikido::common::SplineProblem< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::SplineProblem | ( | const TimeVector & | _times, |
Index | _numCoefficients, | ||
Index | _numOutputs | ||
) |
Constructs a spline fitting problem with knot points at the specified times and the specified number of coefficients and outputs.
These parameters must match _NumKnots
and _NumCoefficients
if they are specified at compile time. Additionally, the length of _times
must match _NumKnots
if that template parameter is specified.
_times | list of knot point times, must be monotone increasing |
_numCoefficients | number of polynomial coefficients |
_numOutputs | number of outputs |
|
default |
|
default |
void aikido::common::SplineProblem< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::addConstantConstraint | ( | Index | _knot, |
Index | _derivative, | ||
const OutputVector & | _value | ||
) |
Adds a constraint that the _derivative-th
order derivative of knot point _knot
should equal _value
.
This adds one constraint if the knot is an end point and two constraints for interior knots. The zero-th derivative is function value.
_knot | knot index to constraint |
_derivative | order of derivative to constraint |
_value | desired value of that knot point's derivative |
void aikido::common::SplineProblem< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::addContinuityConstraint | ( | Index | _knot, |
Index | _derivative | ||
) |
Adds a continuity constraint on the _derivative-th
order derivative at knot point _knot
.
This operation is only defined for interior knot points and adds one constraint.
_knot | knot index to constraint |
_derivative | order of derivative to constraint |
|
static |
Creates the _n
by _n
matrix of derivative coefficients for a polynomial with _n
coefficients.
The i-th row of this matrix corresponds to coefficients for the i-th derivative. The j-th column of this matrix corresponds to the coefficient on x^j.
_n | number of coefficients |
|
static |
Creates a vector of the form [ 1, t, t^2, ... t^_n ].
auto aikido::common::SplineProblem< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::fit |
Fit a spline given the constraints on added to this object.
The behavior of this function is undefined if the problem is over or under-constrained. To avoid this, be sure to only add (num coefficients) * (num knots - 1) constraints to this class.
Scalar aikido::common::SplineProblem< 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.
Index aikido::common::SplineProblem< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::getNumKnots |
Gets the number of knot points.
Index aikido::common::SplineProblem< Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots >::getNumOutputs |
Gets the number of outputs points.
|
default |
|
default |
|
staticconstexpr |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |