8#ifndef _CLASS_CUBICHERMITESPLINE
9#define _CLASS_CUBICHERMITESPLINE
11#include <boost/serialization/utility.hpp>
33 typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1> >
38 Eigen::aligned_allocator<pair_point_tangent_t> >
63 template <
typename In>
69 throw std::length_error(
70 "can not create cubic_hermite_spline, number of pairs is inferior to "
78 if (
Safe && (
static_cast<size_t>(
it->first.size()) !=
dim_ ||
79 static_cast<size_t>(
it->second.size()) !=
dim_))
80 throw std::invalid_argument(
81 "All the control points and their derivatives must have the same "
111 throw std::invalid_argument(
112 "can't evaluate cubic hermite spline, out of range");
117 const bezier_t bezier = buildCurrentBezier(
t);
133 const Numeric
prec = Eigen::NumTraits<Numeric>::dummy_precision())
const {
140 if (!
equal)
return false;
141 for (std::size_t
i = 0;
i <
size_; ++
i) {
153 const Numeric
prec = Eigen::NumTraits<Numeric>::dummy_precision())
const {
167 return !(*
this ==
other);
179 throw std::invalid_argument(
180 "can't derivate cubic hermite spline, out of range");
185 const bezier_t bezier = buildCurrentBezier(
t);
192 for (
size_t i = 0;
i <
size_ - 1; ++
i) {
218 throw std::length_error(
219 "size of time control points should be equal to number of control "
222 computeDurationSplines();
223 if (!checkDurationSplines()) {
224 throw std::invalid_argument(
225 "time_splines not monotonous, all spline duration should be superior "
255 std::size_t findInterval(
const time_t t)
const {
304 void check_conditions()
const {
306 throw std::runtime_error(
307 "Error in cubic hermite : there is no control points set / did you "
308 "use empty constructor ?");
309 }
else if (
dim_ == 0) {
310 throw std::runtime_error(
311 "Error in cubic hermite : Dimension of points is zero / did you use "
312 "empty constructor ?");
321 void computeDurationSplines() {
326 for (
i = 0;
i <
size() - 1;
i++) {
336 bool checkDurationSplines()
const {
351 std::size_t
virtual dim()
const {
return dim_; }
394 template <
class Archive>
400 ar& boost::serialization::make_nvp(
"dim",
dim_);
402 ar& boost::serialization::make_nvp(
"time_control_points",
405 ar& boost::serialization::make_nvp(
"T_min",
T_min_);
406 ar& boost::serialization::make_nvp(
"T_max",
T_max_);
407 ar& boost::serialization::make_nvp(
"size",
size_);
408 ar& boost::serialization::make_nvp(
"degree",
degree_);
414 SINGLE_ARG(
typename Time,
typename Numeric,
bool Safe,
typename Point),
#define DEFINE_CLASS_TEMPLATE_VERSION(Template, Type)
Definition archive.hpp:27
#define SINGLE_ARG(...)
Definition archive.hpp:23
class allowing to create a Bezier curve of dimension 1 <= n <= 3.
interface for a Curve of arbitrary dimension.
Eigen::Matrix< Numeric, Eigen::Dynamic, 1 > Point
Definition effector_spline.h:28
double Numeric
Definition effector_spline.h:26
double Time
Definition effector_spline.h:27
Definition bernstein.h:20
bool isApprox(const T a, const T b, const T eps=1e-6)
Definition curve_abc.h:25
class allowing to create a piecewise curve.
Definition bezier_curve.h:31
std::vector< point_t, Eigen::aligned_allocator< point_t > > t_point_t
Definition bezier_curve.h:38
virtual point_t derivate(const time_t t, const std::size_t order) const
Evaluate the derivative order N of curve at time t. If derivative is to be evaluated several times,...
Definition bezier_curve.h:308
Definition cubic_hermite_spline.h:34
piecewise_bezier_t compute_derivate(const std::size_t order) const
Definition cubic_hermite_spline.h:190
void serialize(Archive &ar, const unsigned int version)
Definition cubic_hermite_spline.h:395
Time time_t
Definition cubic_hermite_spline.h:41
virtual std::size_t degree() const
Get the degree of the curve.
Definition cubic_hermite_spline.h:360
virtual Time max() const
Get the maximum time for which the curve is defined.
Definition cubic_hermite_spline.h:357
Time T_max_
Definition cubic_hermite_spline.h:384
bezier_t::t_point_t t_point_t
Definition cubic_hermite_spline.h:47
bezier_curve< Time, Numeric, Safe, point_t > bezier_t
Definition cubic_hermite_spline.h:46
std::size_t degree_
Degree (Cubic so degree 3)
Definition cubic_hermite_spline.h:388
std::size_t dim_
Dim of curve.
Definition cubic_hermite_spline.h:365
std::vector< pair_point_tangent_t, Eigen::aligned_allocator< pair_point_tangent_t > > t_pair_point_tangent_t
Definition cubic_hermite_spline.h:39
cubic_hermite_spline(const cubic_hermite_spline &other)
Definition cubic_hermite_spline.h:89
bool isApprox(const cubic_hermite_spline_t &other, const Numeric prec=Eigen::NumTraits< Numeric >::dummy_precision()) const
isApprox check if other and *this are approximately equals. Only two curves of the same class can be ...
Definition cubic_hermite_spline.h:131
vector_time_t getTime()
Get vector of Time corresponding to Time for each control point.
Definition cubic_hermite_spline.h:238
std::size_t size_
Number of control points (pairs).
Definition cubic_hermite_spline.h:386
virtual Time min() const
Get the minimum time for which the curve is defined.
Definition cubic_hermite_spline.h:354
std::pair< Point, Point > pair_point_tangent_t
Definition cubic_hermite_spline.h:36
Numeric num_t
Definition cubic_hermite_spline.h:42
Time T_min_
Definition cubic_hermite_spline.h:381
void setTime(const vector_time_t &time_control_points)
Set time of each control point of cubic hermite spline. Set duration of each spline,...
Definition cubic_hermite_spline.h:213
virtual Point operator()(const time_t t) const
Evaluation of the cubic hermite spline at time t.
Definition cubic_hermite_spline.h:108
virtual std::size_t dim() const
Get dimension of curve.
Definition cubic_hermite_spline.h:351
std::size_t size() const
Get number of control points contained in the trajectory.
Definition cubic_hermite_spline.h:243
std::vector< Time > vector_time_t
Definition cubic_hermite_spline.h:40
vector_time_t time_control_points_
Definition cubic_hermite_spline.h:372
virtual bool operator!=(const cubic_hermite_spline_t &other) const
Definition cubic_hermite_spline.h:166
t_pair_point_tangent_t control_points_
Vector of pair < Point, Tangent >.
Definition cubic_hermite_spline.h:367
virtual Point derivate(const time_t t, const std::size_t order) const
Evaluate the derivative of order N of spline at time t.
Definition cubic_hermite_spline.h:176
std::size_t numIntervals() const
Get number of intervals (subsplines) contained in the trajectory.
Definition cubic_hermite_spline.h:248
vector_time_t duration_splines_
Definition cubic_hermite_spline.h:378
cubic_hermite_spline(In PairsBegin, In PairsEnd, const vector_time_t &time_control_points)
Constructor.
Definition cubic_hermite_spline.h:64
piecewise_curve< Time, Numeric, Safe, point_t, point_t, bezier_t > piecewise_bezier_t
Definition cubic_hermite_spline.h:49
curve_abc< Time, Numeric, Safe, point_t > curve_abc_t
Definition cubic_hermite_spline.h:43
friend class boost::serialization::access
Definition cubic_hermite_spline.h:392
virtual ~cubic_hermite_spline()
Destructor.
Definition cubic_hermite_spline.h:100
Point point_t
Definition cubic_hermite_spline.h:35
cubic_hermite_spline()
Empty constructor. Curve obtained this way can not perform other class functions.
Definition cubic_hermite_spline.h:55
virtual bool operator==(const cubic_hermite_spline_t &other) const
Definition cubic_hermite_spline.h:162
cubic_hermite_spline< Time, Numeric, Safe, point_t > cubic_hermite_spline_t
Definition cubic_hermite_spline.h:45
piecewise_bezier_t * compute_derivate_ptr(const std::size_t order) const
Compute the derived curve at order N.
Definition cubic_hermite_spline.h:203
t_pair_point_tangent_t getControlPoints()
Get vector of pair (positition, derivative) corresponding to control points.
Definition cubic_hermite_spline.h:233
virtual bool isApprox(const curve_abc_t *other, const Numeric prec=Eigen::NumTraits< Numeric >::dummy_precision()) const
Definition cubic_hermite_spline.h:151
Represents a curve of dimension Dim. If value of parameter Safe is false, no verification is made on ...
Definition curve_abc.h:36
Definition piecewise_curve.h:37