Directory: | ./ |
---|---|
File: | include/hpp/core/steering-method/spline.hh |
Date: | 2024-12-13 16:14:03 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 9 | 15 | 60.0% |
Branches: | 1 | 10 | 10.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2017 CNRS | ||
3 | // Authors: Joseph Mirabel | ||
4 | // | ||
5 | |||
6 | // Redistribution and use in source and binary forms, with or without | ||
7 | // modification, are permitted provided that the following conditions are | ||
8 | // met: | ||
9 | // | ||
10 | // 1. Redistributions of source code must retain the above copyright | ||
11 | // notice, this list of conditions and the following disclaimer. | ||
12 | // | ||
13 | // 2. Redistributions in binary form must reproduce the above copyright | ||
14 | // notice, this list of conditions and the following disclaimer in the | ||
15 | // documentation and/or other materials provided with the distribution. | ||
16 | // | ||
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
21 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
28 | // DAMAGE. | ||
29 | |||
30 | #ifndef HPP_CORE_STEERING_METHOD_SPLINE_HH | ||
31 | #define HPP_CORE_STEERING_METHOD_SPLINE_HH | ||
32 | |||
33 | #include <hpp/core/config.hh> | ||
34 | #include <hpp/core/fwd.hh> | ||
35 | #include <hpp/core/steering-method.hh> | ||
36 | #include <hpp/util/debug.hh> | ||
37 | #include <hpp/util/pointer.hh> | ||
38 | |||
39 | namespace hpp { | ||
40 | namespace core { | ||
41 | namespace steeringMethod { | ||
42 | /// \addtogroup steering_method | ||
43 | /// \{ | ||
44 | |||
45 | /// Steering method that creates path::Spline instances | ||
46 | /// | ||
47 | template <int _PolynomeBasis, int _SplineOrder> | ||
48 | class HPP_CORE_DLLAPI Spline : public SteeringMethod { | ||
49 | public: | ||
50 | enum { PolynomeBasis = _PolynomeBasis, SplineOrder = _SplineOrder }; | ||
51 | typedef path::Spline<PolynomeBasis, SplineOrder> SplinePath; | ||
52 | typedef typename SplinePath::Ptr_t SplinePathPtr_t; | ||
53 | |||
54 | typedef shared_ptr<Spline> Ptr_t; | ||
55 | typedef weak_ptr<Spline> WkPtr_t; | ||
56 | |||
57 | 41 | static Ptr_t create(const ProblemConstPtr_t& problem) { | |
58 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
41 | Spline* ptr = new Spline(problem); |
59 | 41 | Ptr_t shPtr(ptr); | |
60 |
0/2✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
41 | ptr->init(shPtr); |
61 | 41 | return shPtr; | |
62 | } | ||
63 | |||
64 | /// Copy instance and return shared pointer | ||
65 | ✗ | static Ptr_t createCopy(const Ptr_t& other) { | |
66 | ✗ | Spline* ptr = new Spline(*other); | |
67 | ✗ | Ptr_t shPtr(ptr); | |
68 | ✗ | ptr->init(shPtr); | |
69 | ✗ | return shPtr; | |
70 | } | ||
71 | |||
72 | /// Copy instance and return shared pointer | ||
73 | ✗ | virtual SteeringMethodPtr_t copy() const { return createCopy(weak_.lock()); } | |
74 | |||
75 | /// create a path between two configurations | ||
76 | virtual PathPtr_t impl_compute(ConfigurationIn_t q1, | ||
77 | ConfigurationIn_t q2) const; | ||
78 | |||
79 | /// create a path between two configurations with desired derivatives at the | ||
80 | /// limits | ||
81 | /// \param q1, q2 robot configuration at each end | ||
82 | /// \param order1, order2 list of derivative orders | ||
83 | /// \param derivatives1, derivatives2 desired derivatives at each end | ||
84 | /// \param length if positive, this is the length of the returned path. | ||
85 | /// Otherwise, the length is computed using \r Problem::distance | ||
86 | PathPtr_t steer(ConfigurationIn_t q1, std::vector<int> order1, | ||
87 | matrixIn_t derivatives1, ConfigurationIn_t q2, | ||
88 | std::vector<int> order2, matrixIn_t derivatives2, | ||
89 | value_type length = -1) const; | ||
90 | |||
91 | protected: | ||
92 | /// Constructor | ||
93 | Spline(const ProblemConstPtr_t& problem); | ||
94 | |||
95 | /// Copy constructor | ||
96 | Spline(const Spline& other); | ||
97 | |||
98 | /// Store weak pointer to itself | ||
99 | 41 | void init(WkPtr_t weak) { | |
100 | 41 | SteeringMethod::init(weak); | |
101 | 41 | weak_ = weak; | |
102 | 41 | } | |
103 | |||
104 | private: | ||
105 | /// create a path between two configurations | ||
106 | template <typename Derived> | ||
107 | PathPtr_t impl_compute(ConfigurationIn_t q1, std::vector<int> order1, | ||
108 | const Eigen::MatrixBase<Derived>& derivatives1, | ||
109 | ConfigurationIn_t q2, std::vector<int> order2, | ||
110 | const Eigen::MatrixBase<Derived>& derivatives2, | ||
111 | value_type length) const; | ||
112 | |||
113 | DeviceWkPtr_t device_; | ||
114 | WkPtr_t weak_; | ||
115 | }; // Spline | ||
116 | /// \} | ||
117 | } // namespace steeringMethod | ||
118 | } // namespace core | ||
119 | } // namespace hpp | ||
120 | #endif // HPP_CORE_STEERING_METHOD_REEDS_SHEPP_HH | ||
121 |