Cubic B-Spline trajectory. More...
#include <roboptim/trajectory/cubic-b-spline.hh>
Public Types | |
typedef Polynomial3 | polynomial_t |
Polynomial type. More... | |
typedef std::vector < polynomial_t, Eigen::aligned_allocator < polynomial_t > > | basisPolynomials_t |
Basis polynomials type. More... | |
typedef std::vector < basisPolynomials_t > | basisPolynomialsVector_t |
Basis polynomials vector type. More... | |
typedef basisPolynomials_t polynomials3vector_t | ROBOPTIM_TRAJECTORY_DEPRECATED |
Legacy typedef. More... | |
typedef basisPolynomialsVector_t polynomials3vectors_t | ROBOPTIM_TRAJECTORY_DEPRECATED |
Legacy typedef. More... | |
typedef vector_t | knots_t |
Knot vector type. More... | |
Public Types inherited from roboptim::trajectory::Trajectory< 3 > | |
typedef parent_t::interval_t | interval_t |
Import interval type. More... | |
Public Member Functions | |
CubicBSpline (interval_t timeRange, size_type dimension, const vector_t ¶meters, const std::string name="cubic B-Spline", bool clamped=false) | |
Instantiate a uniform cubic B-Spline from its definition. More... | |
CubicBSpline (size_type dimension, const knots_t &knots, const vector_t ¶meters, const std::string name="cubic B-Spline") | |
Instantiate a cubic B-Spline from its definition. More... | |
CubicBSpline (const CubicBSpline &spline) | |
Copy constructor. More... | |
virtual | ~CubicBSpline () |
virtual void | setParameters (const_vector_ref) |
Modify spline parameters. More... | |
virtual jacobian_t | variationConfigWrtParam (value_type t) const |
virtual jacobian_t | variationDerivWrtParam (value_type t, size_type order) const |
virtual value_type | singularPointAtRank (size_type rank) const |
Get singular point at given rank. More... | |
virtual vector_t | derivBeforeSingularPoint (size_type rank, size_type order) const |
Get left limit value of derivative at given singular point. More... | |
virtual vector_t | derivAfterSingularPoint (size_type rank, size_type order) const |
Get right limit value of derivative at given singular point. More... | |
virtual Trajectory < derivabilityOrder > * | resize (interval_t timeRange) const |
Clone and resize a trajectory. More... | |
virtual std::ostream & | print (std::ostream &o) const |
Display the function on the specified output stream. More... | |
jacobian_t | variationConfigWrtParam (StableTimePoint tp) const |
jacobian_t | variationDerivWrtParam (StableTimePoint tp, size_type order) const |
template<typename P > | |
void | freezeCurveStart (P &problem, size_type offset=0) const |
Add a constraint to a problem in order to freeze the B-spline at its start. More... | |
template<typename P > | |
void | freezeCurveEnd (P &problem, size_type offset=0) const |
Add a constraint to a problem in order to freeze the B-spline at its end. More... | |
value_type | Dt () const ROBOPTIM_TRAJECTORY_DEPRECATED |
Regular spacing between B-spline knots. More... | |
void | translateBasisPolynomials (value_type t1) |
Translate the basis polynomials to a given time t1. More... | |
void | toPolynomials (basisPolynomials_t &res) const |
Return the polynomial expression of the cubic B-spline on each time interval. More... | |
const basisPolynomialsVector_t & | basisPolynomials () const |
Constant getter for the basis polynomials of the cubic B-spline. More... | |
size_type | interval (value_type t) const |
Find the index of the interval in which t is. More... | |
size_type | getNumberControlPoints () const |
Get the number of control points of the spline. More... | |
const knots_t & | knotVector () const |
Return the knot vector of the spline. More... | |
CubicBSpline | operator+ (const CubicBSpline &s) const |
Add two cubic B-splines, supposing they have the same dimensions. More... | |
void | operator+= (const CubicBSpline &s) |
Add a second B-spline to this B-spline. More... | |
int | order () const |
Retrieve the order of the spline. More... | |
Public Member Functions inherited from roboptim::trajectory::Trajectory< 3 > | |
ROBOPTIM_NTIMES_DERIVABLE_FUNCTION_FWD_TYPEDEFS_ (NTimesDerivableFunction< DerivabilityOrder >) | |
Parent type and imports. More... | |
virtual | ~Trajectory () |
result_t | operator() (StableTimePoint argument) const |
void | operator() (result_ref result, StableTimePoint argument) const |
derivative_t | derivative (StableTimePoint argument, size_type order=1) const |
void | derivative (derivative_ref derivative, StableTimePoint argument, size_type order=1) const |
bool | isValidTime (value_type t) const |
virtual void | normalizeAngles (size_type index) |
Normalize angles in parameters array. More... | |
virtual Trajectory < DerivabilityOrder > * | clone () const =0 |
const vector_t & | parameters () const |
interval_t | timeRange () const |
value_type | length () const |
virtual vector_t | state (double t, size_type order) const |
Get state along trajectory. More... | |
virtual vector_t | state (StableTimePoint t, size_type order) const |
virtual jacobian_t | variationConfigWrtParam (double t) const =0 |
Get the variation of a configuration with respect to parameter vector. More... | |
virtual jacobian_t | variationDerivWrtParam (double t, size_type order) const =0 |
Get the variation of a derivative with respect to parameter vector. More... | |
jacobian_t | variationStateWrtParam (double t, size_type order) const |
Get the variation of the state with respect to parameter vector. More... | |
jacobian_t | variationStateWrtParam (StableTimePoint stp, size_type order) const |
size_type | singularPoints () const |
Get number of singular points. More... | |
void | tolerance (const double &tolerance) |
double | tolerance () const |
Get tolerance for inclusion of parameter in interval of definition. More... | |
Protected Member Functions | |
void | impl_compute (result_ref, value_type) const |
void | impl_derivative (derivative_ref g, value_type x, size_type order) const |
void | impl_derivative (derivative_ref g, StableTimePoint, size_type order) const |
void | computeBasisPolynomials () |
Compute the basis polynomials for the cubic B-spline. More... | |
vector_t | basisFunctions (value_type t, size_type order) const ROBOPTIM_TRAJECTORY_DEPRECATED |
Compute the basis functions for a given instant t. More... | |
Protected Member Functions inherited from roboptim::trajectory::Trajectory< 3 > | |
virtual void | normalizeAngles (size_type index, size_type offset) |
Internal version of normalizeAngles allowing an optional offset. More... | |
void | impl_compute (result_ref, StableTimePoint) const |
Trajectory (interval_t, size_type, const vector_t &, std::string name=std::string()) | |
Additional Inherited Members | |
Protected Attributes inherited from roboptim::trajectory::Trajectory< 3 > | |
interval_t | timeRange_ |
vector_t | parameters_ |
size_type | singularPoints_ |
Cubic B-Spline trajectory.
Implement a B-Spline as a trajectory as described in doc/cubic-b-spline.tex
typedef std::vector< polynomial_t, Eigen::aligned_allocator<polynomial_t> > roboptim::trajectory::CubicBSpline::basisPolynomials_t |
Basis polynomials type.
typedef std::vector<basisPolynomials_t> roboptim::trajectory::CubicBSpline::basisPolynomialsVector_t |
Basis polynomials vector type.
typedef vector_t roboptim::trajectory::CubicBSpline::knots_t |
Knot vector type.
typedef basisPolynomials_t polynomials3vector_t roboptim::trajectory::CubicBSpline::ROBOPTIM_TRAJECTORY_DEPRECATED |
Legacy typedef.
typedef basisPolynomialsVector_t polynomials3vectors_t roboptim::trajectory::CubicBSpline::ROBOPTIM_TRAJECTORY_DEPRECATED |
Legacy typedef.
roboptim::trajectory::CubicBSpline::CubicBSpline | ( | interval_t | timeRange, |
size_type | dimension, | ||
const vector_t & | parameters, | ||
const std::string | name = "cubic B-Spline" , |
||
bool | clamped = false |
||
) |
Instantiate a uniform cubic B-Spline from its definition.
timeRange | spline time range: $ \([t_3,t_n]\) |
dimension | spline dimension: \(n\) |
parameters | vector of parameters defining control points |
name | function title |
clamped | whether the spline should be clamped |
The number of control points is inferred from the dimension of the parameter vector.
References computeBasisPolynomials(), roboptim::trajectory::Trajectory< 3 >::parameters_, and setParameters().
Referenced by resize().
roboptim::trajectory::CubicBSpline::CubicBSpline | ( | size_type | dimension, |
const knots_t & | knots, | ||
const vector_t & | parameters, | ||
const std::string | name = "cubic B-Spline" |
||
) |
Instantiate a cubic B-Spline from its definition.
dimension | spline dimension: \(n\) |
knots | vector of knots, |
parameters | vector of parameters defining control points |
name | function title |
The number of control points is inferred from the dimension of the parameter vector.
References computeBasisPolynomials(), roboptim::trajectory::Trajectory< 3 >::parameters_, and setParameters().
roboptim::trajectory::CubicBSpline::CubicBSpline | ( | const CubicBSpline & | spline | ) |
Copy constructor.
spline | spline that will be copied |
References roboptim::trajectory::Trajectory< dorder >::parameters(), roboptim::trajectory::Trajectory< 3 >::parameters_, and setParameters().
|
virtual |
|
protected |
Compute the basis functions for a given instant t.
t | instant considered. |
order | order of the basis functions. |
References Dt(), roboptim::trajectory::detail::fixTime(), interval(), roboptim::trajectory::Trajectory< 3 >::length(), roboptim::trajectory::Trajectory< 3 >::timeRange(), and roboptim::trajectory::Trajectory< 3 >::tolerance().
|
inline |
Constant getter for the basis polynomials of the cubic B-spline.
Note: computeBasisPolynomials() needs to be called beforehand (which is done in the CubicBSpline constructor).
|
protected |
Compute the basis polynomials for the cubic B-spline.
Referenced by CubicBSpline().
|
virtual |
Get right limit value of derivative at given singular point.
rank | rank of the singular points. |
order | order of derivation. |
derivative | Limit of the derivative at singular point for decreasing parameter values. |
Implements roboptim::trajectory::Trajectory< 3 >.
References roboptim::trajectory::Trajectory< 3 >::derivative(), and singularPointAtRank().
|
virtual |
Get left limit value of derivative at given singular point.
rank | rank of the singular points. |
order | order of derivation. |
Implements roboptim::trajectory::Trajectory< 3 >.
References roboptim::trajectory::Trajectory< 3 >::derivative(), and singularPointAtRank().
CubicBSpline::value_type roboptim::trajectory::CubicBSpline::Dt | ( | ) | const |
Regular spacing between B-spline knots.
This is only valid for uniform B-splines.
References roboptim::trajectory::Trajectory< 3 >::length().
Referenced by basisFunctions().
void roboptim::trajectory::CubicBSpline::freezeCurveEnd | ( | P & | problem, |
size_type | offset = 0 |
||
) | const |
Add a constraint to a problem in order to freeze the B-spline at its end.
problem | problem to which the constraint will be added. |
offset | offset of the B-spline parameters in the problem's parameter list. |
References interval(), and roboptim::trajectory::Trajectory< 3 >::parameters().
void roboptim::trajectory::CubicBSpline::freezeCurveStart | ( | P & | problem, |
size_type | offset = 0 |
||
) | const |
Add a constraint to a problem in order to freeze the B-spline at its start.
problem | problem to which the constraint will be added. |
offset | offset of the B-spline parameters in the problem's parameter list. |
References interval(), and roboptim::trajectory::Trajectory< 3 >::parameters().
|
inline |
Get the number of control points of the spline.
Referenced by roboptim::trajectory::visualization::matplotlib::plot_spline().
|
protected |
|
protected |
ROBOPTIM_DO_NOT_CHECK_ALLOCATION
ROBOPTIM_DO_NOT_CHECK_ALLOCATION
References roboptim::trajectory::Polynomial< N >::derivative(), roboptim::trajectory::detail::fixTime(), interval(), and roboptim::trajectory::Trajectory< 3 >::parameters().
Referenced by impl_derivative().
|
protectedvirtual |
Implements roboptim::trajectory::Trajectory< 3 >.
References roboptim::trajectory::StableTimePoint::getTime(), and impl_derivative().
CubicBSpline::size_type roboptim::trajectory::CubicBSpline::interval | ( | value_type | t | ) | const |
Find the index of the interval in which t is.
t | instant considered. |
References roboptim::trajectory::detail::fixTime(), and roboptim::trajectory::Trajectory< 3 >::timeRange().
Referenced by basisFunctions(), freezeCurveEnd(), freezeCurveStart(), and impl_derivative().
|
inline |
Return the knot vector of the spline.
Referenced by roboptim::trajectory::visualization::matplotlib::plot_spline().
CubicBSpline roboptim::trajectory::CubicBSpline::operator+ | ( | const CubicBSpline & | s | ) | const |
Add two cubic B-splines, supposing they have the same dimensions.
s | other B-spline with the same dimensions. |
std::runtime_error | if splines do not have the same dimensions. |
References roboptim::trajectory::Trajectory< 3 >::parameters(), roboptim::trajectory::Trajectory< dorder >::parameters(), roboptim::trajectory::Trajectory< 3 >::timeRange(), and roboptim::trajectory::Trajectory< dorder >::timeRange().
void roboptim::trajectory::CubicBSpline::operator+= | ( | const CubicBSpline & | s | ) |
Add a second B-spline to this B-spline.
s | other B-spline with the same dimensions. |
std::runtime_error | if splines do not have the same dimensions. |
References roboptim::trajectory::Trajectory< 3 >::parameters(), roboptim::trajectory::Trajectory< dorder >::parameters(), setParameters(), roboptim::trajectory::Trajectory< 3 >::timeRange(), and roboptim::trajectory::Trajectory< dorder >::timeRange().
int roboptim::trajectory::CubicBSpline::order | ( | ) | const |
Retrieve the order of the spline.
|
virtual |
Display the function on the specified output stream.
o | output stream used for display |
Reimplemented from roboptim::trajectory::Trajectory< 3 >.
References roboptim::trajectory::Trajectory< 3 >::length(), and roboptim::trajectory::Trajectory< 3 >::parameters().
|
inlinevirtual |
Clone and resize a trajectory.
Implements roboptim::trajectory::Trajectory< 3 >.
References CubicBSpline(), and roboptim::trajectory::Trajectory< 3 >::parameters().
|
virtual |
Modify spline parameters.
Reimplemented from roboptim::trajectory::Trajectory< 3 >.
References roboptim::trajectory::Trajectory< 3 >::parameters_.
Referenced by CubicBSpline(), roboptim::trajectory::SplineLength::impl_compute(), roboptim::trajectory::SplineLength::impl_gradient(), and operator+=().
|
virtual |
Get singular point at given rank.
Implements roboptim::trajectory::Trajectory< 3 >.
References roboptim::trajectory::Trajectory< 3 >::length().
Referenced by derivAfterSingularPoint(), and derivBeforeSingularPoint().
void roboptim::trajectory::CubicBSpline::toPolynomials | ( | basisPolynomials_t & | res | ) | const |
Return the polynomial expression of the cubic B-spline on each time interval.
ROBOPTIM_DO_NOT_CHECK_ALLOCATION
ROBOPTIM_DO_NOT_CHECK_ALLOCATION
References roboptim::trajectory::Trajectory< 3 >::parameters().
Referenced by roboptim::trajectory::visualization::matplotlib::plot_spline().
void roboptim::trajectory::CubicBSpline::translateBasisPolynomials | ( | value_type | t1 | ) |
Translate the basis polynomials to a given time t1.
t1 | new center time, i.e. P = sum(a_i*(t-t1)^i, i={0,3}) |
This method can be useful when one needs to have all the polynomials expressed in the same basis (e.g. t1 = 0).
|
virtual |
Referenced by variationConfigWrtParam().
|
virtual |
Implements roboptim::trajectory::Trajectory< 3 >.
References roboptim::trajectory::StableTimePoint::getTime(), and variationConfigWrtParam().
|
virtual |
Referenced by variationDerivWrtParam().
|
virtual |
Implements roboptim::trajectory::Trajectory< 3 >.
References roboptim::trajectory::StableTimePoint::getTime(), and variationDerivWrtParam().