| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * \file definitions.h | ||
| 3 | * \brief utils for defining optimization problems | ||
| 4 | * \author Steve T. | ||
| 5 | * \version 0.1 | ||
| 6 | * \date 06/17/2013 | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef _CLASS_DEFINITIONS_H | ||
| 10 | #define _CLASS_DEFINITIONS_H | ||
| 11 | |||
| 12 | #include <ndcurves/bezier_curve.h> | ||
| 13 | #include <ndcurves/curve_constraint.h> | ||
| 14 | #include <ndcurves/linear_variable.h> | ||
| 15 | #include <ndcurves/quadratic_variable.h> | ||
| 16 | |||
| 17 | namespace ndcurves { | ||
| 18 | namespace optimization { | ||
| 19 | |||
| 20 | enum constraint_flag { | ||
| 21 | INIT_POS = 0x001, | ||
| 22 | INIT_VEL = 0x002, | ||
| 23 | INIT_ACC = 0x004, | ||
| 24 | INIT_JERK = 0x008, | ||
| 25 | END_POS = 0x010, | ||
| 26 | END_VEL = 0x020, | ||
| 27 | END_ACC = 0x040, | ||
| 28 | END_JERK = 0x080, | ||
| 29 | ALL = 0x0ff, | ||
| 30 | NONE = 0x100 | ||
| 31 | }; | ||
| 32 | |||
| 33 | template <typename Point, typename Numeric> | ||
| 34 | struct quadratic_problem { | ||
| 35 | Eigen::Matrix<Numeric, Eigen::Dynamic, Eigen::Dynamic> ineqMatrix; | ||
| 36 | Eigen::Matrix<Numeric, Eigen::Dynamic, 1> ineqVector; | ||
| 37 | quadratic_variable<Numeric> cost; | ||
| 38 | }; | ||
| 39 | |||
| 40 | template <typename Point, typename Numeric> | ||
| 41 | struct problem_definition : public curve_constraints<Point> { | ||
| 42 | typedef Point point_t; | ||
| 43 | typedef Numeric num_t; | ||
| 44 | typedef curve_constraints<point_t> curve_constraints_t; | ||
| 45 | typedef Eigen::Matrix<num_t, Eigen::Dynamic, 1> vector_x_t; | ||
| 46 | typedef Eigen::Matrix<num_t, Eigen::Dynamic, Eigen::Dynamic> matrix_x_t; | ||
| 47 | typedef std::vector<matrix_x_t, Eigen::aligned_allocator<matrix_x_t> > | ||
| 48 | T_matrix_x_t; | ||
| 49 | typedef std::vector<vector_x_t, Eigen::aligned_allocator<vector_x_t> > | ||
| 50 | T_vector_x_t; | ||
| 51 | typedef typename T_matrix_x_t::const_iterator CIT_matrix_x_t; | ||
| 52 | typedef typename T_vector_x_t::const_iterator CIT_vector_x_t; | ||
| 53 | |||
| 54 | 3 | problem_definition(const std::size_t dim) | |
| 55 | : curve_constraints_t(dim), | ||
| 56 | 3 | flag(NONE), | |
| 57 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | init_pos(point_t::Zero(dim)), |
| 58 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | end_pos(point_t::Zero(dim)), |
| 59 | 3 | degree(5), | |
| 60 | 3 | totalTime(1.), | |
| 61 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | splitTimes_(vector_x_t::Zero(0)), |
| 62 |
3/6✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
|
6 | dim_(dim) {} |
| 63 | |||
| 64 | 22 | problem_definition(const curve_constraints_t& parent) | |
| 65 | : curve_constraints_t(parent), | ||
| 66 | 22 | flag(NONE), | |
| 67 |
1/2✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
|
22 | init_pos(point_t::Zero(parent.dim_)), |
| 68 |
2/4✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
|
22 | end_pos(point_t::Zero(parent.dim_)), |
| 69 | 22 | degree(5), | |
| 70 | 22 | totalTime(1.), | |
| 71 |
2/4✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
|
22 | splitTimes_(vector_x_t::Zero(0)), |
| 72 |
3/6✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 22 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 22 times.
✗ Branch 9 not taken.
|
44 | dim_(parent.dim_) {} |
| 73 | |||
| 74 | constraint_flag flag; | ||
| 75 | point_t init_pos; | ||
| 76 | point_t end_pos; | ||
| 77 | std::size_t degree; | ||
| 78 | num_t totalTime; | ||
| 79 | vector_x_t splitTimes_; | ||
| 80 | T_matrix_x_t inequalityMatrices_; // must be of size (splitTimes_ + 1) | ||
| 81 | T_vector_x_t inequalityVectors_; // must be of size (splitTimes_ + 1) | ||
| 82 | const std::size_t dim_; | ||
| 83 | }; | ||
| 84 | |||
| 85 | } // namespace optimization | ||
| 86 | } // namespace ndcurves | ||
| 87 | #endif //_CLASS_DEFINITIONS_H | ||
| 88 |