18 #ifndef HPP_CORE_PATH_SPLINE_HH 19 # define HPP_CORE_PATH_SPLINE_HH 23 # include <hpp/pinocchio/device.hh> 24 # include <hpp/pinocchio/liegroup-element.hh> 28 # include <hpp/core/config.hh> 43 template <
int SplineType,
int Degree>
struct spline_basis_function;
44 template <
int SplineType,
int Degree>
struct sbf_traits {
45 enum { NbCoeffs = Degree + 1 };
46 typedef Eigen::Matrix<value_type, NbCoeffs, 1> Coeffs_t;
47 typedef Eigen::Matrix<value_type, NbCoeffs, NbCoeffs> IntegralCoeffs_t;
79 template <
int _PolynomeBasis,
int _Order>
80 class HPP_CORE_DLLAPI Spline :
public Path 84 PolynomeBasis = _PolynomeBasis,
86 NbCoeffs = _Order + 1,
87 NbPowerOfT = 2 * NbCoeffs + 1
90 typedef internal::sbf_traits<PolynomeBasis, Order>
sbf_traits;
96 typedef Eigen::Matrix<value_type, NbCoeffs, Eigen::Dynamic, Eigen::RowMajor>
ParameterMatrix_t;
100 typedef boost::shared_ptr<Spline>
Ptr_t;
105 return parameterSize_;
117 assert (res.size() == NbCoeffs);
118 impl_paramDerivative (res, t);
124 assert (dParam.size() == NbCoeffs * parameterSize_);
125 impl_paramIntegrate (dParam);
143 static void timeFreeBasisFunctionDerivative (
const size_type order,
const value_type& u, BasisFunctionVector_t& res);
147 assert (res.size() == NbCoeffs);
148 BasisFunctionVector_t tmp;
149 timeFreeBasisFunctionDerivative(order, u, tmp);
158 void basisFunctionDerivative (
const size_type order,
const value_type& u, BasisFunctionVector_t& res)
const;
162 assert (res.size() == NbCoeffs);
163 BasisFunctionVector_t tmp;
164 basisFunctionDerivative(order, u, tmp);
177 void squaredNormBasisFunctionIntegral (
const size_type order, BasisFunctionIntegralMatrix_t& res)
const;
182 BasisFunctionIntegralMatrix_t tmp;
183 squaredNormBasisFunctionIntegral (order, tmp);
190 bool res = operator() (q, timeRange().first);
198 bool res = operator() (q, timeRange().second);
208 return base_.vector();
233 return ConstParameterVector_t (parameters_.data(), parameters_.size());
239 ParameterVector_t(parameters_.data(), parameters_.size()) = p;
244 Ptr_t other (
new Spline (*
this));
251 Ptr_t other (
new Spline (*
this, constraints));
262 Ptr_t shPtr (
new Spline(robot, interval, constraints));
275 Eigen::Ref<const ParameterMatrix_t> params,
284 :
Path (interval, robot->configSize(), robot->numberDof(), constraints),
285 parameterSize_ (robot->numberDof()),
287 base_ (robot->RnxSOnConfigSpace()->vectorSpacesMerged()),
288 parameters_ ((int)NbCoeffs, parameterSize_),
289 velocity_ (parameterSize_)
292 for (
size_type i = 1; i < NbPowerOfT; ++i)
293 powersOfT_(i) = powersOfT_(i - 1) *
length();
296 Spline (
const Spline& path);
302 std::ostream& print (std::ostream &os)
const;
330 mutable PowersOfT_t powersOfT_;
338 #endif // HPP_CORE_PATH_SPLINE_HH internal::sbf_traits< PolynomeBasis, Order > sbf_traits
Definition: spline.hh:90
boost::shared_ptr< Spline > Ptr_t
Definition: spline.hh:100
boost::shared_ptr< Path > PathPtr_t
Definition: fwd.hh:170
sbf_traits::IntegralCoeffs_t BasisFunctionIntegralMatrix_t
Definition: spline.hh:94
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:114
PolynomeBasisType
Definition: spline.hh:36
sbf_traits::Coeffs_t BasisFunctionVector_t
Definition: spline.hh:93
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:110
std::pair< value_type, value_type > interval_t
Definition: fwd.hh:158
virtual Configuration_t initial() const
Get the initial configuration.
Definition: spline.hh:187
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition: fwd.hh:98
pinocchio::size_type size_type
Definition: fwd.hh:156
PathPtr_t copy(const ConstraintSetPtr_t &constraints) const
Definition: spline.hh:249
const ParameterMatrix_t & parameters() const
Each row corresponds to a velocity of the robot.
Definition: spline.hh:218
Spline(const DevicePtr_t &robot, const interval_t &interval, const ConstraintSetPtr_t &constraints)
Definition: spline.hh:281
DevicePtr_t robot_
Definition: spline.hh:316
void parameterIntegrate(vectorIn_t dParam)
Adds dParam to the parameters.
Definition: spline.hh:122
void squaredNormBasisFunctionIntegral(const size_type order, matrixOut_t res) const
Definition: spline.hh:179
internal::spline_basis_function< PolynomeBasis, Order > BasisFunction_t
Definition: spline.hh:91
virtual ~Spline()
Definition: spline.hh:256
ConstParameterVector_t rowParameters() const
Concatenate the parameters as one vector (P_0^T, ..., P_n^T).
Definition: spline.hh:231
const Configuration_t & base() const
Definition: spline.hh:206
PathPtr_t copy() const
Return a shared pointer to a copy of this.
Definition: spline.hh:242
assert(d.lhs()._blocks()==d.rhs()._blocks())
pinocchio::vectorIn_t vectorIn_t
Definition: fwd.hh:202
void init(const PathWkPtr_t &self)
static void timeFreeBasisFunctionDerivative(const size_type order, const value_type &u, vectorOut_t res)
Definition: spline.hh:145
pinocchio::vector_t vector_t
Definition: fwd.hh:201
LiegroupElement base_
Definition: spline.hh:320
pinocchio::value_type value_type
Definition: fwd.hh:157
ParameterMatrix_t parameters_
Definition: spline.hh:324
void parameterDerivativeCoefficients(vectorOut_t res, const value_type &t) const
Definition: spline.hh:115
Eigen::Map< vector_t, Eigen::Aligned > ParameterVector_t
Definition: spline.hh:98
constraints::matrixOut_t matrixOut_t
Definition: fwd.hh:150
void init(const Ptr_t &self)
Definition: spline.hh:300
size_type parameterSize() const
Definition: spline.hh:103
pinocchio::vectorOut_t vectorOut_t
Definition: fwd.hh:203
void base(const Configuration_t &q)
Definition: spline.hh:212
void basisFunctionDerivative(const size_type order, const value_type &u, vectorOut_t res) const
Definition: spline.hh:160
void rowParameters(vectorIn_t p)
Set the parameters.
Definition: spline.hh:237
Eigen::Matrix< value_type, NbCoeffs, Eigen::Dynamic, Eigen::RowMajor > ParameterMatrix_t
Definition: spline.hh:96
Eigen::Map< const vector_t, Eigen::Aligned > ConstParameterVector_t
Definition: spline.hh:97
size_type parameterSize_
Robot number of degrees of freedom.
Definition: spline.hh:315
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:96
Eigen::Matrix< value_type, NbPowerOfT, 1 > PowersOfT_t
Definition: spline.hh:92
virtual Configuration_t end() const
Get the final configuration.
Definition: spline.hh:195
static Ptr_t create(const DevicePtr_t &robot, const interval_t &interval, const ConstraintSetPtr_t &constraints)
Definition: spline.hh:258
boost::weak_ptr< Spline > WkPtr_t
Definition: spline.hh:101
void parameters(const ParameterMatrix_t &m)
Definition: spline.hh:225