| Directory: | ./ |
|---|---|
| File: | include/hpp/core/steering-method/hermite.hh |
| Date: | 2025-03-10 11:18:21 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 23 | 23 | 100.0% |
| Branches: | 6 | 12 | 50.0% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright (c) 2016 CNRS | ||
| 2 | // Authors: Joseph Mirabel | ||
| 3 | // | ||
| 4 | |||
| 5 | // Redistribution and use in source and binary forms, with or without | ||
| 6 | // modification, are permitted provided that the following conditions are | ||
| 7 | // met: | ||
| 8 | // | ||
| 9 | // 1. Redistributions of source code must retain the above copyright | ||
| 10 | // notice, this list of conditions and the following disclaimer. | ||
| 11 | // | ||
| 12 | // 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | // notice, this list of conditions and the following disclaimer in the | ||
| 14 | // documentation and/or other materials provided with the distribution. | ||
| 15 | // | ||
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| 20 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
| 27 | // DAMAGE. | ||
| 28 | |||
| 29 | #ifndef HPP_CORE_STEERING_METHOD_HERMITE_HH | ||
| 30 | #define HPP_CORE_STEERING_METHOD_HERMITE_HH | ||
| 31 | |||
| 32 | #include <hpp/core/fwd.hh> | ||
| 33 | #include <hpp/core/path/hermite.hh> | ||
| 34 | #include <hpp/core/problem.hh> | ||
| 35 | #include <hpp/core/steering-method.hh> | ||
| 36 | #include <hpp/core/steering-method/fwd.hh> | ||
| 37 | #include <hpp/core/weighed-distance.hh> | ||
| 38 | |||
| 39 | namespace hpp { | ||
| 40 | namespace core { | ||
| 41 | namespace steeringMethod { | ||
| 42 | /// \addtogroup steering_method | ||
| 43 | /// \{ | ||
| 44 | |||
| 45 | /// Steering method that creates path::Hermite instances | ||
| 46 | /// | ||
| 47 | class HPP_CORE_DLLAPI Hermite : public SteeringMethod { | ||
| 48 | public: | ||
| 49 | /// Create instance and return shared pointer | ||
| 50 | 2 | static HermitePtr_t create(const ProblemConstPtr_t& problem) { | |
| 51 | 2 | Hermite* ptr = new Hermite(problem); | |
| 52 | 2 | HermitePtr_t shPtr(ptr); | |
| 53 | 2 | ptr->init(shPtr); | |
| 54 | 2 | return shPtr; | |
| 55 | } | ||
| 56 | |||
| 57 | /// Copy instance and return shared pointer | ||
| 58 | 4 | static HermitePtr_t createCopy(const HermitePtr_t& other) { | |
| 59 |
1/2✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
4 | Hermite* ptr = new Hermite(*other); |
| 60 | 4 | HermitePtr_t shPtr(ptr); | |
| 61 | 4 | ptr->init(shPtr); | |
| 62 | 4 | return shPtr; | |
| 63 | } | ||
| 64 | |||
| 65 | /// Copy instance and return shared pointer | ||
| 66 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | virtual SteeringMethodPtr_t copy() const { return createCopy(weak_.lock()); } |
| 67 | |||
| 68 | /// create a path between two configurations | ||
| 69 | 1852568 | virtual PathPtr_t impl_compute(ConfigurationIn_t q1, | |
| 70 | ConfigurationIn_t q2) const { | ||
| 71 | path::HermitePtr_t path = | ||
| 72 |
3/6✓ Branch 3 taken 1852568 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1852568 times.
✗ Branch 7 not taken.
✓ Branch 12 taken 1852568 times.
✗ Branch 13 not taken.
|
3705136 | path::Hermite::create(problem()->robot(), q1, q2, constraints()); |
| 73 | |||
| 74 |
1/2✓ Branch 2 taken 1852568 times.
✗ Branch 3 not taken.
|
1852568 | path->computeHermiteLength(); |
| 75 | 3705136 | return path; | |
| 76 | 1852568 | } | |
| 77 | |||
| 78 | protected: | ||
| 79 | /// Constructor with weighed distance | ||
| 80 | 2 | Hermite(const ProblemConstPtr_t& problem) | |
| 81 | 2 | : SteeringMethod(problem), weak_() {} | |
| 82 | |||
| 83 | /// Copy constructor | ||
| 84 | 4 | Hermite(const Hermite& other) : SteeringMethod(other), weak_() {} | |
| 85 | |||
| 86 | /// Store weak pointer to itself | ||
| 87 | 6 | void init(HermiteWkPtr_t weak) { | |
| 88 | 6 | SteeringMethod::init(weak); | |
| 89 | 6 | weak_ = weak; | |
| 90 | 6 | } | |
| 91 | |||
| 92 | private: | ||
| 93 | HermiteWkPtr_t weak_; | ||
| 94 | }; // Hermite | ||
| 95 | /// \} | ||
| 96 | } // namespace steeringMethod | ||
| 97 | } // namespace core | ||
| 98 | } // namespace hpp | ||
| 99 | #endif // HPP_CORE_STEERING_METHOD_HERMITE_HH | ||
| 100 |