curve_constraint.h 2.72 KB
Newer Older
1
/**
Guilhem Saurel's avatar
Guilhem Saurel committed
2
3
4
5
6
7
8
9
 * \file curve_constraint.h
 * \brief struct to define constraints on start / end velocities and acceleration
 * on a curve
 * \author Steve T.
 * \version 0.1
 * \date 04/05/2017
 *
 */
10
11
12
13
14

#ifndef _CLASS_CURVE_CONSTRAINT
#define _CLASS_CURVE_CONSTRAINT

#include "MathDefs.h"
15
16
#include "serialization/archive.hpp"
#include "serialization/eigen-matrix.hpp"
17
18
19
#include <functional>
#include <vector>

Steve T's avatar
Steve T committed
20
namespace ndcurves {
Guilhem Saurel's avatar
Guilhem Saurel committed
21
template <typename Point>
22
struct curve_constraints : serialization::Serializable {
Guilhem Saurel's avatar
Guilhem Saurel committed
23
  typedef Point point_t;
Pierre Fernbach's avatar
Pierre Fernbach committed
24
  curve_constraints(const size_t dim = 3)
Guilhem Saurel's avatar
Format    
Guilhem Saurel committed
25
26
27
28
29
30
31
      : init_vel(point_t::Zero(dim)),
        init_acc(point_t::Zero(dim)),
        init_jerk(point_t::Zero(dim)),
        end_vel(point_t::Zero(dim)),
        end_acc(point_t::Zero(dim)),
        end_jerk(point_t::Zero(dim)),
        dim_(dim) {}
32

33
  curve_constraints(const curve_constraints& other)
Guilhem Saurel's avatar
Format    
Guilhem Saurel committed
34
35
36
37
38
39
40
      : init_vel(other.init_vel),
        init_acc(other.init_acc),
        init_jerk(other.init_jerk),
        end_vel(other.end_vel),
        end_acc(other.end_acc),
        end_jerk(other.end_jerk),
        dim_(other.dim_) {}
41

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  /// \brief Check if actual curve_constraints and other are equal.
  /// \param other : the other curve_constraints to check.
  /// \return true if the two curve_constraints are equals.
  virtual bool operator==(const curve_constraints& other) const {
    return  dim_ == other.dim_ &&
        init_vel == other.init_vel &&
        init_acc == other.init_acc &&
        init_jerk == other.init_jerk &&
        end_vel == other.end_vel &&
        end_acc == other.end_acc &&
        end_jerk == other.end_jerk;
  }

  /// \brief Check if actual curve_constraint and other are different.
  /// \param other : the other curve_constraint to check.
  /// \return true if the two curve_constraint are different.
  virtual bool operator!=(const curve_constraints& other) const { return !(*this == other); }


Guilhem Saurel's avatar
Format    
Guilhem Saurel committed
61
62
63
64
65
66
67
68
  ~curve_constraints() {}
  point_t init_vel;
  point_t init_acc;
  point_t init_jerk;
  point_t end_vel;
  point_t end_acc;
  point_t end_jerk;
  size_t dim_;
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

   // Serialization of the class
  friend class boost::serialization::access;
  template <class Archive>
  void serialize(Archive& ar, const unsigned int version) {
    if (version) {
      // Do something depending on version ?
    }
    ar& boost::serialization::make_nvp("init_vel", init_vel);
    ar& boost::serialization::make_nvp("init_acc", init_acc);
    ar& boost::serialization::make_nvp("init_jerk", init_jerk);
    ar& boost::serialization::make_nvp("end_vel", end_vel);
    ar& boost::serialization::make_nvp("end_acc", end_acc);
    ar& boost::serialization::make_nvp("end_jerk", end_jerk);
    ar& boost::serialization::make_nvp("dim", dim_);
  }
Guilhem Saurel's avatar
Guilhem Saurel committed
85
};
Steve T's avatar
Steve T committed
86
}  // namespace ndcurves
Guilhem Saurel's avatar
Guilhem Saurel committed
87
#endif  //_CLASS_CUBICZEROVELACC