piecewise_curve.h
Go to the documentation of this file.
1 
8 #ifndef _CLASS_PIECEWISE_CURVE
9 #define _CLASS_PIECEWISE_CURVE
10 
11 #include "curve_abc.h"
12 #include "curve_conversion.h"
13 #include <boost/smart_ptr/shared_ptr.hpp>
14 #include <boost/serialization/vector.hpp>
15 #include <fstream>
16 #include <sstream>
17 
18 namespace ndcurves {
28 template <typename Time = double, typename Numeric = Time, bool Safe = false,
29  typename Point = Eigen::Matrix<Numeric, Eigen::Dynamic, 1>, typename Point_derivate = Point,
30  typename CurveType = curve_abc<Time, Numeric, Safe, Point, Point_derivate> >
31 struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point, Point_derivate> {
32  typedef Point point_t;
33  typedef Point_derivate point_derivate_t;
34  typedef std::vector<point_t, Eigen::aligned_allocator<point_t> > t_point_t;
35  typedef std::vector<point_derivate_t, Eigen::aligned_allocator<point_derivate_t> > t_point_derivate_t;
36  typedef Time time_t;
37  typedef Numeric num_t;
39  typedef CurveType curve_t; // contained curves base class
40  typedef boost::shared_ptr<curve_t> curve_ptr_t;
41  typedef typename std::vector<curve_ptr_t> t_curve_ptr_t;
42  typedef typename std::vector<Time> t_time_t;
46  typedef boost::shared_ptr<typename piecewise_curve_derivate_t::curve_t> curve_derivate_ptr_t;
47 
48  public:
51  piecewise_curve() : dim_(0), size_(0), T_min_(0), T_max_(0) {}
52 
57  piecewise_curve(const curve_ptr_t& cf) : dim_(0), size_(0), T_min_(0), T_max_(0) { add_curve_ptr(cf); }
58 
59  piecewise_curve(const t_curve_ptr_t& curves_list) : dim_(0), size_(0), T_min_(0), T_max_(0) {
60  for (typename t_curve_ptr_t::const_iterator it = curves_list.begin(); it != curves_list.end(); ++it) {
61  add_curve_ptr(*it);
62  }
63  }
64 
66  : dim_(other.dim_),
67  curves_(other.curves_),
69  size_(other.size_),
70  T_min_(other.T_min_),
71  T_max_(other.T_max_) {}
72 
73  virtual ~piecewise_curve() {}
74 
75  virtual point_t operator()(const Time t) const {
76  check_if_not_empty();
77  if (Safe & !(T_min_ <= t && t <= T_max_)) {
78  // std::cout<<"[Min,Max]=["<<T_min_<<","<<T_max_<<"]"<<" t="<<t<<std::endl;
79  throw std::out_of_range("can't evaluate piecewise curve, out of range");
80  }
81  return (*curves_.at(find_interval(t)))(t);
82  }
83 
92  bool isApprox(const piecewise_curve_t& other,
93  const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision()) const {
94  if (num_curves() != other.num_curves()) return false;
95  for (size_t i = 0; i < num_curves(); ++i) {
96  if (!curve_at_index(i)->isApprox(other.curve_at_index(i).get(), prec)) return false;
97  }
98  return true;
99  }
100 
101  virtual bool isApprox(const base_curve_t* other,
102  const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision()) const {
103  const piecewise_curve_t* other_cast = dynamic_cast<const piecewise_curve_t*>(other);
104  if (other_cast)
105  return isApprox(*other_cast, prec);
106  else
107  return false;
108  }
109 
110  virtual bool operator==(const piecewise_curve_t& other) const { return isApprox(other); }
111 
112  virtual bool operator!=(const piecewise_curve_t& other) const { return !(*this == other); }
113 
119  virtual point_derivate_t derivate(const Time t, const std::size_t order) const {
120  check_if_not_empty();
121  if (Safe & !(T_min_ <= t && t <= T_max_)) {
122  throw std::invalid_argument("can't evaluate piecewise curve, out of range");
123  }
124  return (*curves_.at(find_interval(t))).derivate(t, order);
125  }
126 
132  piecewise_curve_derivate_t* compute_derivate_ptr(const std::size_t order) const {
134  for (typename t_curve_ptr_t::const_iterator itc = curves_.begin(); itc < curves_.end(); ++itc) {
135  curve_derivate_ptr_t ptr((*itc)->compute_derivate_ptr(order));
136  res->add_curve_ptr(ptr);
137  }
138  return res;
139  }
140 
141  template <typename Curve>
142  void add_curve(const Curve& curve) {
143  curve_ptr_t curve_ptr = boost::make_shared<Curve>(curve);
144  add_curve_ptr(curve_ptr);
145  }
146 
153  void add_curve_ptr(const curve_ptr_t& cf) {
154  if (size_ == 0) { // first curve added
155  dim_ = cf->dim();
156  }
157  // Check time continuity : Beginning time of cf must be equal to T_max_ of actual piecewise curve.
158  if (size_ != 0 && !(fabs(cf->min() - T_max_) < MARGIN)) {
159  std::stringstream ss;
160  ss << "Can not add new Polynom to PiecewiseCurve : time discontinuity between T_max_ and pol.min(). Current "
161  "T_max is "
162  << T_max_ << " new curve min is " << cf->min();
163  throw std::invalid_argument(ss.str().c_str());
164  }
165  if (cf->dim() != dim_) {
166  std::stringstream ss;
167  ss << "All the curves in a piecewiseCurve should have the same dimension. Current dim is " << dim_
168  << " dim of the new curve is " << cf->dim();
169  throw std::invalid_argument(ss.str().c_str());
170  }
171  curves_.push_back(cf);
172  size_ = curves_.size();
173  T_max_ = cf->max();
174  if (size_ == 1) {
175  // First curve added
176  time_curves_.push_back(cf->min());
177  T_min_ = cf->min();
178  }
179  time_curves_.push_back(T_max_);
180  }
181 
186  bool is_continuous(const std::size_t order) {
187  check_if_not_empty();
188  bool isContinuous = true;
189  std::size_t i = 0;
190  if (order == 0) {
191  point_t value_end, value_start;
192  while (isContinuous && i < (size_ - 1)) {
193  curve_ptr_t current = curves_.at(i);
194  curve_ptr_t next = curves_.at(i + 1);
195  value_end = (*current)(current->max());
196  value_start = (*next)(next->min());
197  if (!value_end.isApprox(value_start, MARGIN)) {
198  isContinuous = false;
199  }
200  i++;
201  }
202  } else {
203  point_derivate_t value_end, value_start;
204  while (isContinuous && i < (size_ - 1)) {
205  curve_ptr_t current = curves_.at(i);
206  curve_ptr_t next = curves_.at(i + 1);
207  value_end = current->derivate(current->max(), order);
208  value_start = next->derivate(next->min(), order);
209  if (!value_end.isApprox(value_start, MARGIN)) {
210  isContinuous = false;
211  }
212  i++;
213  }
214  }
215  return isContinuous;
216  }
217 
220  std::size_t num_curves() const { return curves_.size(); }
221 
227  curve_ptr_t curve_at_time(const time_t t) const { return curves_[find_interval(t)]; }
228 
232  curve_ptr_t curve_at_index(const std::size_t idx) const {
233  if (Safe && idx >= num_curves()) {
234  throw std::length_error(
235  "curve_at_index: requested index greater than number of curves in piecewise_curve instance");
236  }
237  return curves_[idx];
238  }
239 
243  template <typename Bezier>
244  piecewise_curve_t convert_piecewise_curve_to_bezier() {
245  check_if_not_empty();
246  // check if given Bezier curve have the correct dimension :
247  BOOST_STATIC_ASSERT(boost::is_same<typename Bezier::point_t, point_t>::value);
248  BOOST_STATIC_ASSERT(boost::is_same<typename Bezier::point_derivate_t, point_derivate_t>::value);
249  // Create piecewise curve
250  piecewise_curve_t pc_res;
251  // Convert and add all other curves (segments)
252  for (std::size_t i = 0; i < size_; i++) {
253  pc_res.add_curve(bezier_from_curve<Bezier>(*curves_.at(i)));
254  }
255  return pc_res;
256  }
257 
262  template <typename Hermite>
264  check_if_not_empty();
265  // check if given Hermite curve have the correct dimension :
266  BOOST_STATIC_ASSERT(boost::is_same<typename Hermite::point_t, point_t>::value);
267  BOOST_STATIC_ASSERT(boost::is_same<typename Hermite::point_derivate_t, point_derivate_t>::value);
268  // Create piecewise curve
269  piecewise_curve_t pc_res;
270  // Convert and add all other curves (segments)
271  for (std::size_t i = 0; i < size_; i++) {
272  pc_res.add_curve(hermite_from_curve<Hermite>(*curves_.at(i)));
273  }
274  return pc_res;
275  }
276 
280  template <typename Polynomial>
282  check_if_not_empty();
283  // check if given Polynomial curve have the correct dimension :
284  BOOST_STATIC_ASSERT(boost::is_same<typename Polynomial::point_t, point_t>::value);
285  BOOST_STATIC_ASSERT(boost::is_same<typename Polynomial::point_derivate_t, point_derivate_t>::value);
286  // Create piecewise curve
287  piecewise_curve_t pc_res;
288  // Convert and add all other curves (segments)
289  for (std::size_t i = 0; i < size_; i++) {
290  pc_res.add_curve(polynomial_from_curve<Polynomial>(*curves_.at(i)));
291  }
292  return pc_res;
293  }
294 
300  template <typename Polynomial>
301  static piecewise_curve_t convert_discrete_points_to_polynomial(t_point_t points, t_time_t time_points) {
302  if (Safe & !(points.size() > 1)) {
303  // std::cout<<"[Min,Max]=["<<T_min_<<","<<T_max_<<"]"<<" t="<<t<<std::endl;
304  throw std::invalid_argument(
305  "piecewise_curve::convert_discrete_points_to_polynomial: Error, less than 2 discrete points");
306  }
307  if (points.size() != time_points.size()) {
308  throw std::invalid_argument(
309  "piecewise_curve::convert_discrete_points_to_polynomial: Error, points and time_points must have the same "
310  "size.");
311  }
312  // check if given Polynomial curve have the correct dimension :
313  BOOST_STATIC_ASSERT(boost::is_same<typename Polynomial::point_t, point_t>::value);
314  BOOST_STATIC_ASSERT(boost::is_same<typename Polynomial::point_derivate_t, point_derivate_t>::value);
315  piecewise_curve_t piecewise_res;
316 
317  for (size_t i = 1; i < points.size(); ++i) {
318  piecewise_res.add_curve(Polynomial(points[i - 1], points[i], time_points[i - 1], time_points[i]));
319  }
320  return piecewise_res;
321  }
322 
329  template <typename Polynomial>
330  static piecewise_curve_t convert_discrete_points_to_polynomial(t_point_t points,
331  t_point_derivate_t points_derivative,
332  t_time_t time_points) {
333  if (Safe & !(points.size() > 1)) {
334  // std::cout<<"[Min,Max]=["<<T_min_<<","<<T_max_<<"]"<<" t="<<t<<std::endl;
335  throw std::invalid_argument(
336  "piecewise_curve::convert_discrete_points_to_polynomial: Error, less than 2 discrete points");
337  }
338  if (points.size() != time_points.size()) {
339  throw std::invalid_argument(
340  "piecewise_curve::convert_discrete_points_to_polynomial: Error, points and time_points must have the same "
341  "size.");
342  }
343  if (points.size() != points_derivative.size()) {
344  throw std::invalid_argument(
345  "piecewise_curve::convert_discrete_points_to_polynomial: Error, points and points_derivative must have the "
346  "same size.");
347  }
348  // check if given Polynomial curve have the correct dimension :
349  BOOST_STATIC_ASSERT(boost::is_same<typename Polynomial::point_t, point_t>::value);
350  BOOST_STATIC_ASSERT(boost::is_same<typename Polynomial::point_derivate_t, point_derivate_t>::value);
351  piecewise_curve_t piecewise_res;
352 
353  for (size_t i = 1; i < points.size(); ++i) {
354  piecewise_res.add_curve(Polynomial(points[i - 1], points_derivative[i - 1], points[i], points_derivative[i],
355  time_points[i - 1], time_points[i]));
356  }
357  return piecewise_res;
358  }
359 
367  template <typename Polynomial>
368  static piecewise_curve_t convert_discrete_points_to_polynomial(t_point_t points,
369  t_point_derivate_t points_derivative,
370  t_point_derivate_t points_second_derivative,
371  t_time_t time_points) {
372  if (Safe & !(points.size() > 1)) {
373  // std::cout<<"[Min,Max]=["<<T_min_<<","<<T_max_<<"]"<<" t="<<t<<std::endl;
374  throw std::invalid_argument(
375  "piecewise_curve::convert_discrete_points_to_polynomial: Error, less than 2 discrete points");
376  }
377  if (points.size() != time_points.size()) {
378  throw std::invalid_argument(
379  "piecewise_curve::convert_discrete_points_to_polynomial: Error, points and time_points must have the same "
380  "size.");
381  }
382  if (points.size() != points_derivative.size()) {
383  throw std::invalid_argument(
384  "piecewise_curve::convert_discrete_points_to_polynomial: Error, points and points_derivative must have the "
385  "same size.");
386  }
387  if (points.size() != points_second_derivative.size()) {
388  throw std::invalid_argument(
389  "piecewise_curve::convert_discrete_points_to_polynomial: Error, points and points_second_derivative must "
390  "have the same size.");
391  }
392  // check if given Polynomial curve have the correct dimension :
393  BOOST_STATIC_ASSERT(boost::is_same<typename Polynomial::point_t, point_t>::value);
394  BOOST_STATIC_ASSERT(boost::is_same<typename Polynomial::point_derivate_t, point_derivate_t>::value);
395  piecewise_curve_t piecewise_res;
396 
397  for (size_t i = 1; i < points.size(); ++i) {
398  piecewise_res.add_curve(Polynomial(points[i - 1], points_derivative[i - 1], points_second_derivative[i - 1],
399  points[i], points_derivative[i], points_second_derivative[i],
400  time_points[i - 1], time_points[i]));
401  }
402  return piecewise_res;
403  }
404 
414  template <typename Polynomial>
415  static piecewise_curve_t load_piecewise_from_text_file(const std::string& filename, const time_t dt,
416  const size_t dim) {
417  if (dim <= 0) throw std::invalid_argument("The dimension should be strictly positive.");
418  if (dt <= 0.) throw std::invalid_argument("The time step should be strictly positive.");
419 
420  piecewise_curve_t piecewise_res;
421  std::ifstream file;
422  file.open(filename.c_str());
423  point_t last_pos = point_t::Zero(dim), last_vel = point_t::Zero(dim), last_acc = point_t::Zero(dim),
424  new_pos = point_t::Zero(dim), new_vel = point_t::Zero(dim), new_acc = point_t::Zero(dim);
425  bool use_vel, use_acc;
426  std::string line;
427  // read first line to found out if we use velocity / acceleration :
428  std::getline(file, line);
429  std::istringstream iss_length(line);
430  const size_t length =
431  std::distance(std::istream_iterator<std::string>(iss_length), std::istream_iterator<std::string>());
432  if (length == dim) {
433  use_vel = false;
434  use_acc = false;
435  } else if (length == dim * 2) {
436  use_vel = true;
437  use_acc = false;
438  } else if (length == dim * 3) {
439  use_vel = true;
440  use_acc = true;
441  } else {
442  std::stringstream error;
443  error << "The first line of the file shold contains either " << dim << ", " << dim * 2 << " or " << dim * 3
444  << "values, got : " << length;
445  throw std::invalid_argument(error.str());
446  }
447  // initialize the first points of the trajectory:
448  num_t val;
449  std::istringstream iss(line);
450  for (size_t i = 0; i < dim; ++i) {
451  iss >> val;
452  last_pos[i] = val;
453  }
454  if (use_vel) {
455  for (size_t i = 0; i < dim; ++i) {
456  iss >> val;
457  last_vel[i] = val;
458  }
459  }
460  if (use_acc) {
461  for (size_t i = 0; i < dim; ++i) {
462  iss >> val;
463  last_acc[i] = val;
464  }
465  }
466 
467  size_t current_length;
468  size_t line_id = 0;
469  // parse all lines of the file:
470  while (std::getline(file, line)) {
471  ++line_id;
472  std::istringstream iss_length(line);
473  current_length =
474  std::distance(std::istream_iterator<std::string>(iss_length), std::istream_iterator<std::string>());
475  if (current_length != length) {
476  std::stringstream error;
477  error << "Cannot parse line " << line_id << " got " << current_length << " values instead of " << length;
478  throw std::invalid_argument(error.str());
479  }
480  std::istringstream iss(line);
481  // parse the points values from the file:
482  for (size_t i = 0; i < dim; ++i) {
483  iss >> val;
484  new_pos[i] = val;
485  }
486  if (use_vel) {
487  for (size_t i = 0; i < dim; ++i) {
488  iss >> val;
489  new_vel[i] = val;
490  }
491  }
492  if (use_acc) {
493  for (size_t i = 0; i < dim; ++i) {
494  iss >> val;
495  new_acc[i] = val;
496  }
497  }
498  // append a new curves connectiong this points
499  if (use_acc) {
500  piecewise_res.add_curve(Polynomial(last_pos, last_vel, last_acc, new_pos, new_vel, new_acc,
501  dt * static_cast<time_t>(line_id - 1), dt * static_cast<time_t>(line_id)));
502  } else if (use_vel) {
503  piecewise_res.add_curve(Polynomial(last_pos, last_vel, new_pos, new_vel, dt * static_cast<time_t>(line_id - 1),
504  dt * static_cast<time_t>(line_id)));
505  } else {
506  piecewise_res.add_curve(
507  Polynomial(last_pos, new_pos, dt * static_cast<time_t>(line_id - 1), dt * static_cast<time_t>(line_id)));
508  }
509  last_pos = new_pos;
510  last_vel = new_vel;
511  last_acc = new_acc;
512  }
513 
514  file.close();
515  return piecewise_res;
516  }
517 
518  private:
523  std::size_t find_interval(const Numeric t) const {
524  // time before first control point time.
525  if (t < time_curves_[0]) {
526  return 0;
527  }
528  // time is after last control point time
529  if (t > time_curves_[size_ - 1]) {
530  return size_ - 1;
531  }
532 
533  std::size_t left_id = 0;
534  std::size_t right_id = size_ - 1;
535  while (left_id <= right_id) {
536  const std::size_t middle_id = left_id + (right_id - left_id) / 2;
537  if (time_curves_.at(middle_id) < t) {
538  left_id = middle_id + 1;
539  } else if (time_curves_.at(middle_id) > t) {
540  right_id = middle_id - 1;
541  } else {
542  return middle_id;
543  }
544  }
545  return left_id - 1;
546  }
547 
548  void check_if_not_empty() const {
549  if (curves_.size() == 0) {
550  throw std::runtime_error("Error in piecewise curve : No curve added");
551  }
552  }
553 
554  /*Helpers*/
555  public:
558  std::size_t virtual dim() const { return dim_; };
561  Time virtual min() const { return T_min_; }
564  Time virtual max() const { return T_max_; }
567  virtual std::size_t degree() const {
568  throw std::runtime_error("degree() method is not implemented for this type of curve.");
569  }
570  std::size_t getNumberCurves() { return curves_.size(); }
571  /*Helpers*/
572 
573  /* Attributes */
574  std::size_t dim_; // Dim of curve
575  t_curve_ptr_t curves_; // for curves 0/1/2 : [ curve0, curve1, curve2 ]
576  t_time_t time_curves_; // for curves 0/1/2 : [ Tmin0, Tmax0,Tmax1,Tmax2 ]
577  std::size_t size_; // Number of segments in piecewise curve = size of curves_
579  /* Attributes */
580 
581  // Serialization of the class
582  friend class boost::serialization::access;
583 
584  template <class Archive>
585  void serialize(Archive& ar, const unsigned int version) {
586  if (version) {
587  // Do something depending on version ?
588  }
589  ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(base_curve_t);
590  ar& boost::serialization::make_nvp("dim", dim_);
591  ar& boost::serialization::make_nvp("curves", curves_);
592  ar& boost::serialization::make_nvp("time_curves", time_curves_);
593  ar& boost::serialization::make_nvp("size", size_);
594  ar& boost::serialization::make_nvp("T_min", T_min_);
595  ar& boost::serialization::make_nvp("T_max", T_max_);
596  }
597 }; // End struct piecewise curve
598 } // namespace ndcurves
599 
600 DEFINE_CLASS_TEMPLATE_VERSION(
601  SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point, typename Point_derivate,
602  typename CurveType),
604 
605 #endif // _CLASS_PIECEWISE_CURVE
Definition: bernstein.h:20
piecewise_curve(const t_curve_ptr_t &curves_list)
Definition: piecewise_curve.h:59
piecewise_curve_derivate_t * compute_derivate_ptr(const std::size_t order) const
compute_derivate return a piecewise_curve which is the derivative of this at given order ...
Definition: piecewise_curve.h:132
boost::shared_ptr< curve_t > curve_ptr_t
Definition: piecewise_curve.h:40
std::vector< point_t, Eigen::aligned_allocator< point_t > > t_point_t
Definition: piecewise_curve.h:34
piecewise_curve(const curve_ptr_t &cf)
Constructor. Initialize a piecewise curve by giving the first curve.
Definition: piecewise_curve.h:57
void serialize(Archive &ar, const unsigned int version)
Definition: piecewise_curve.h:585
virtual point_derivate_t derivate(const Time t, const std::size_t order) const
Evaluate the derivative of order N of curve at time t.
Definition: piecewise_curve.h:119
Point_derivate point_derivate_t
Definition: piecewise_curve.h:33
piecewise_curve< Time, Numeric, Safe, Point_derivate, Point_derivate, typename CurveType::curve_derivate_t > piecewise_curve_derivate_t
Definition: piecewise_curve.h:45
Time T_max_
Definition: piecewise_curve.h:578
virtual ~piecewise_curve()
Definition: piecewise_curve.h:73
virtual std::size_t dim() const
Get dimension of curve.
Definition: piecewise_curve.h:558
std::size_t getNumberCurves()
Definition: piecewise_curve.h:570
std::size_t num_curves() const
Get number of curves in piecewise curve.
Definition: piecewise_curve.h:220
interface for a Curve of arbitrary dimension.
curve_ptr_t curve_at_index(const std::size_t idx) const
Get curve at specified index in piecewise curve.
Definition: piecewise_curve.h:232
piecewise_curve(const piecewise_curve &other)
Definition: piecewise_curve.h:65
void add_curve_ptr(const curve_ptr_t &cf)
Add a new curve to piecewise curve, which should be defined in where is equal to of the actual pie...
Definition: piecewise_curve.h:153
virtual bool isApprox(const base_curve_t *other, const Numeric prec=Eigen::NumTraits< Numeric >::dummy_precision()) const
isApprox check if other and *this are approximately equal given a precision treshold Only two curves ...
Definition: piecewise_curve.h:101
boost::shared_ptr< typename piecewise_curve_derivate_t::curve_t > curve_derivate_ptr_t
Definition: piecewise_curve.h:46
t_curve_ptr_t curves_
Definition: piecewise_curve.h:575
bool is_continuous(const std::size_t order)
Check if the curve is continuous of order given.
Definition: piecewise_curve.h:186
virtual bool operator==(const piecewise_curve_t &other) const
Definition: piecewise_curve.h:110
Point point_t
Definition: piecewise_curve.h:32
piecewise_curve_t convert_piecewise_curve_to_bezier()
Convert all curves in piecewise curve into bezier curves.
Definition: piecewise_curve.h:244
virtual bool operator!=(const piecewise_curve_t &other) const
Definition: piecewise_curve.h:112
double Time
Definition: effector_spline.h:27
Numeric num_t
Definition: piecewise_curve.h:37
virtual Time max() const
Get the maximum time for which the curve is defined.
Definition: piecewise_curve.h:564
std::size_t size_
Definition: piecewise_curve.h:577
virtual std::size_t degree() const
Get the degree of the curve.
Definition: piecewise_curve.h:567
curve_ptr_t curve_at_time(const time_t t) const
Get curve corresponding to time t in piecewise curve. Example : A piecewise curve PC made of two curv...
Definition: piecewise_curve.h:227
std::vector< Time > t_time_t
Definition: piecewise_curve.h:42
Eigen::Matrix< Numeric, Eigen::Dynamic, 1 > Point
Definition: effector_spline.h:28
Time T_min_
Definition: piecewise_curve.h:578
t_time_t time_curves_
Definition: piecewise_curve.h:576
std::size_t dim_
Definition: piecewise_curve.h:574
static piecewise_curve_t convert_discrete_points_to_polynomial(t_point_t points, t_point_derivate_t points_derivative, t_time_t time_points)
Convert discrete points into piecewise polynomial curve with C1 continuity.
Definition: piecewise_curve.h:330
bool isApprox(const piecewise_curve_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: piecewise_curve.h:92
static piecewise_curve_t convert_discrete_points_to_polynomial(t_point_t points, t_point_derivate_t points_derivative, t_point_derivate_t points_second_derivative, t_time_t time_points)
Convert discrete points into piecewise polynomial curve with C2 continuity.
Definition: piecewise_curve.h:368
double Numeric
Definition: effector_spline.h:26
virtual Time min() const
Get the minimum time for which the curve is defined.
Definition: piecewise_curve.h:561
std::vector< point_derivate_t, Eigen::aligned_allocator< point_derivate_t > > t_point_derivate_t
Definition: piecewise_curve.h:35
Definition: fwd.h:34
void add_curve(const Curve &curve)
Definition: piecewise_curve.h:142
piecewise_curve()
Empty constructor. Add at least one curve to call other class functions.
Definition: piecewise_curve.h:51
Time time_t
Definition: piecewise_curve.h:36
curve_abc< Time, Numeric, Safe, point_t, point_derivate_t > base_curve_t
Definition: piecewise_curve.h:38
std::vector< curve_ptr_t > t_curve_ptr_t
Definition: piecewise_curve.h:41
piecewise_curve< Time, Numeric, Safe, Point, Point_derivate, CurveType > piecewise_curve_t
Definition: piecewise_curve.h:43
static piecewise_curve_t convert_discrete_points_to_polynomial(t_point_t points, t_time_t time_points)
Convert discrete points into piecewise polynomial curve with C0 continuity.
Definition: piecewise_curve.h:301
piecewise_curve_t convert_piecewise_curve_to_polynomial()
Convert all curves in piecewise curve into polynomial curves.
Definition: piecewise_curve.h:281
CurveType curve_t
Definition: piecewise_curve.h:39
piecewise_curve_t convert_piecewise_curve_to_cubic_hermite()
Convert all curves in piecewise curve into cubic hermite curves. Curves need to be of degree inferior...
Definition: piecewise_curve.h:263
Represents a curve of dimension Dim. If value of parameter Safe is false, no verification is made on ...
Definition: curve_abc.h:34
static piecewise_curve_t load_piecewise_from_text_file(const std::string &filename, const time_t dt, const size_t dim)
load_piecewise_from_text_file build a piecewise polynomial from a list of discrete points read from a...
Definition: piecewise_curve.h:415
virtual point_t operator()(const Time t) const
Evaluation of the cubic spline at time t.
Definition: piecewise_curve.h:75