GCC Code Coverage Report


Directory: ./
File: include/ndcurves/curve_constraint.h
Date: 2025-03-05 17:18:30
Exec Total Coverage
Lines: 33 33 100.0%
Branches: 42 65 64.6%

Line Branch Exec Source
1 /**
2 * \file curve_constraint.h
3 * \brief struct to define constraints on start / end velocities and
4 * acceleration on a curve \author Steve T. \version 0.1 \date 04/05/2017
5 *
6 */
7
8 #ifndef _CLASS_CURVE_CONSTRAINT
9 #define _CLASS_CURVE_CONSTRAINT
10
11 #include <functional>
12 #include <vector>
13
14 #include "MathDefs.h"
15 #include "serialization/archive.hpp"
16 #include "serialization/eigen-matrix.hpp"
17
18 namespace ndcurves {
19 template <typename Point>
20 struct curve_constraints : serialization::Serializable {
21 typedef Point point_t;
22 65 curve_constraints(const size_t dim = 3)
23
1/2
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
65 : init_vel(point_t::Zero(dim)),
24
3/5
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
65 init_acc(point_t::Zero(dim)),
25
3/5
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
65 init_jerk(point_t::Zero(dim)),
26
3/5
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
65 end_vel(point_t::Zero(dim)),
27
3/5
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
65 end_acc(point_t::Zero(dim)),
28
3/5
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
65 end_jerk(point_t::Zero(dim)),
29 130 dim_(dim) {}
30
31 64 curve_constraints(const curve_constraints& other)
32 64 : init_vel(other.init_vel),
33
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
64 init_acc(other.init_acc),
34
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
64 init_jerk(other.init_jerk),
35
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
64 end_vel(other.end_vel),
36
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
64 end_acc(other.end_acc),
37
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
64 end_jerk(other.end_jerk),
38 84 dim_(other.dim_) {}
39
40 /// \brief Check if actual curve_constraints and other are equal.
41 /// \param other : the other curve_constraints to check.
42 /// \return true if the two curve_constraints are equals.
43 23 virtual bool operator==(const curve_constraints& other) const {
44
2/2
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 2 times.
22 return dim_ == other.dim_ && init_vel == other.init_vel &&
45
4/4
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 1 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 1 times.
19 init_acc == other.init_acc && init_jerk == other.init_jerk &&
46
6/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 1 times.
✓ Branch 6 taken 10 times.
✓ Branch 7 taken 1 times.
60 end_vel == other.end_vel && end_acc == other.end_acc &&
47
2/2
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 1 times.
38 end_jerk == other.end_jerk;
48 }
49
50 /// \brief Check if actual curve_constraint and other are different.
51 /// \param other : the other curve_constraint to check.
52 /// \return true if the two curve_constraint are different.
53 9 virtual bool operator!=(const curve_constraints& other) const {
54 9 return !(*this == other);
55 }
56
57 140 virtual ~curve_constraints() {}
58 point_t init_vel;
59 point_t init_acc;
60 point_t init_jerk;
61 point_t end_vel;
62 point_t end_acc;
63 point_t end_jerk;
64 size_t dim_;
65
66 // Serialization of the class
67 friend class boost::serialization::access;
68 template <class Archive>
69 28 void serialize(Archive& ar, const unsigned int version) {
70 if (version) {
71 // Do something depending on version ?
72 }
73
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar& boost::serialization::make_nvp("init_vel", init_vel);
74
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar& boost::serialization::make_nvp("init_acc", init_acc);
75
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar& boost::serialization::make_nvp("init_jerk", init_jerk);
76
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar& boost::serialization::make_nvp("end_vel", end_vel);
77
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar& boost::serialization::make_nvp("end_acc", end_acc);
78
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar& boost::serialization::make_nvp("end_jerk", end_jerk);
79
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar& boost::serialization::make_nvp("dim", dim_);
80 28 }
81 };
82 } // namespace ndcurves
83 #endif //_CLASS_CUBICZEROVELACC
84