9 #ifndef _CLASS_CONSTANTCURVE 10 #define _CLASS_CONSTANTCURVE 18 template <
typename Time = double,
typename Numeric =
Time,
bool Safe =
false,
19 typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>,
typename Point_derivate =
Point>
40 constant_curve(
const Point& value,
const time_t T_min = 0.,
const time_t T_max = std::numeric_limits<time_t>::max())
43 throw std::invalid_argument(
"can't create constant curve: min bound is higher than max bound");
61 if (Safe && (t < T_min_ || t >
T_max_)) {
62 throw std::invalid_argument(
63 "error in constant curve : time t to evaluate should be in range [Tmin, Tmax] of the curve");
74 if (point_derivate_t::RowsAtCompileTime == Eigen::Dynamic) {
77 derivate_size = point_derivate_t::RowsAtCompileTime;
79 point_derivate_t value(point_derivate_t::Zero(derivate_size));
94 virtual point_derivate_t
derivate(
const time_t t,
const std::size_t)
const {
95 if (Safe && (t < T_min_ || t >
T_max_)) {
96 throw std::invalid_argument(
97 "error in constant curve : time t to derivate should be in range [Tmin, Tmax] of the curve");
100 if (point_derivate_t::RowsAtCompileTime == Eigen::Dynamic) {
101 derivate_size =
dim_;
103 derivate_size = point_derivate_t::RowsAtCompileTime;
105 return point_derivate_t::Zero(derivate_size);
116 virtual bool isApprox(
const constant_curve_t& other,
117 const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision())
const {
118 return curves::isApprox<num_t>(
T_min_, other.
min()) && curves::isApprox<num_t>(
T_max_, other.
max()) &&
123 const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision())
const {
124 const constant_curve_t* other_cast =
dynamic_cast<const constant_curve_t*
>(other);
133 virtual bool operator!=(
const constant_curve_t& other)
const {
return !(*
this == other); }
138 std::size_t
virtual dim()
const {
return dim_; }
147 virtual std::size_t
degree()
const {
return 0; }
159 template <
class Archive>
160 void serialize(Archive& ar,
const unsigned int version) {
164 ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(curve_abc_t);
165 ar& boost::serialization::make_nvp(
"value", value_);
166 ar& boost::serialization::make_nvp(
"T_min", T_min_);
167 ar& boost::serialization::make_nvp(
"T_max", T_max_);
168 ar& boost::serialization::make_nvp(
"dim", dim_);
174 DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(
typename Time,
typename Numeric,
bool Safe,
typename Point,
typename Point_derivate),
177 #endif // _CLASS_CONSTANTCURVE Point point_t
Definition: constant_curve.h:21
virtual std::size_t dim() const
Get dimension of curve.
Definition: constant_curve.h:138
curve_derivate_t compute_derivate() const
Compute the derived curve at order N. Computes the derivative order N, of bezier curve of parametric...
Definition: constant_curve.h:72
Point value_
Definition: constant_curve.h:151
Numeric num_t
Definition: constant_curve.h:24
double Numeric
Definition: effector_spline.h:26
constant_curve< Time, Numeric, Safe, Point, Point_derivate > constant_curve_t
Definition: constant_curve.h:25
constant_curve(const Point &value, const time_t T_min=0., const time_t T_max=std::numeric_limits< time_t >::max())
Constructor..
Definition: constant_curve.h:40
Time time_t
Definition: constant_curve.h:23
virtual bool operator==(const constant_curve_t &other) const
Definition: constant_curve.h:131
interface for a Curve of arbitrary dimension.
Definition: bernstein.h:20
constant_curve(const constant_curve_t &other)
Copy constructor.
Definition: constant_curve.h:49
virtual bool operator!=(const constant_curve_t &other) const
Definition: constant_curve.h:133
virtual std::size_t degree() const
Get the degree of the curve.
Definition: constant_curve.h:147
constant_curve< Time, Numeric, Safe, Point_derivate > curve_derivate_t
Definition: constant_curve.h:26
virtual point_t operator()(const time_t t) const
Evaluation of the cubic spline at time t.
Definition: constant_curve.h:60
void serialize(Archive &ar, const unsigned int version)
Definition: constant_curve.h:160
time_t T_min_
Definition: constant_curve.h:152
virtual ~constant_curve()
Destructor.
Definition: constant_curve.h:53
virtual point_derivate_t derivate(const time_t t, const std::size_t) const
Evaluate the derivative of order N of curve at time t.
Definition: constant_curve.h:94
std::size_t dim_
Definition: constant_curve.h:153
virtual bool isApprox(const curve_abc_t *other, const Numeric prec=Eigen::NumTraits< Numeric >::dummy_precision()) const
Definition: constant_curve.h:122
Represents a constant_curve curve, always returning the same value and a null derivative.
Definition: constant_curve.h:20
virtual num_t max() const
Get the maximum time for which the curve is defined.
Definition: constant_curve.h:144
Point_derivate point_derivate_t
Definition: constant_curve.h:22
curve_abc< Time, Numeric, Safe, point_t, Point_derivate > curve_abc_t
Definition: constant_curve.h:27
virtual num_t min() const
Get the minimum time for which the curve is defined.
Definition: constant_curve.h:141
constant_curve()
Empty constructor. Curve obtained this way can not perform other class functions. ...
Definition: constant_curve.h:33
double Time
Definition: effector_spline.h:27
friend class boost::serialization::access
Definition: constant_curve.h:157
Eigen::Matrix< Numeric, Eigen::Dynamic, 1 > Point
Definition: effector_spline.h:28
virtual curve_derivate_t * compute_derivate_ptr(const std::size_t) const
Compute the derived curve at order N.
Definition: constant_curve.h:86
Represents a curve of dimension Dim. If value of parameter Safe is false, no verification is made on ...
Definition: curve_abc.h:34
time_t T_max_
Definition: constant_curve.h:152
virtual bool isApprox(const constant_curve_t &other, const Numeric prec=Eigen::NumTraits< Numeric >::dummy_precision()) const
isApprox check if other and *this are approximately equals given a precision treshold Only two curves...
Definition: constant_curve.h:116