Directory: | ./ |
---|---|
File: | include/hpp/core/steering-method/straight.hh |
Date: | 2024-08-10 11:29:48 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 18 | 18 | 100.0% |
Branches: | 2 | 4 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2014 CNRS | ||
3 | // Authors: Florent Lamiraux | ||
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_STRAIGHT_HH | ||
31 | #define HPP_CORE_STEERING_METHOD_STRAIGHT_HH | ||
32 | |||
33 | #include <hpp/core/config.hh> | ||
34 | #include <hpp/core/fwd.hh> | ||
35 | #include <hpp/core/steering-method.hh> | ||
36 | #include <hpp/core/steering-method/fwd.hh> | ||
37 | |||
38 | namespace hpp { | ||
39 | namespace core { | ||
40 | namespace steeringMethod { | ||
41 | /// \addtogroup steering_method | ||
42 | /// \{ | ||
43 | |||
44 | /// Steering method that creates StraightPath instances | ||
45 | /// | ||
46 | class HPP_CORE_DLLAPI Straight : public SteeringMethod { | ||
47 | public: | ||
48 | /// Create instance and return shared pointer | ||
49 | 64 | static StraightPtr_t create(const ProblemConstPtr_t& problem) { | |
50 | 64 | Straight* ptr = new Straight(problem); | |
51 | 64 | StraightPtr_t shPtr(ptr); | |
52 | 64 | ptr->init(shPtr); | |
53 | 64 | return shPtr; | |
54 | } | ||
55 | /// Copy instance and return shared pointer | ||
56 | 8 | static StraightPtr_t createCopy(const StraightPtr_t& other) { | |
57 |
1/2✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
|
8 | Straight* ptr = new Straight(*other); |
58 | 8 | StraightPtr_t shPtr(ptr); | |
59 | 8 | ptr->init(shPtr); | |
60 | 8 | return shPtr; | |
61 | } | ||
62 | /// Copy instance and return shared pointer | ||
63 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | virtual SteeringMethodPtr_t copy() const { return createCopy(weak_.lock()); } |
64 | |||
65 | /// create a path between two configurations | ||
66 | virtual PathPtr_t impl_compute(ConfigurationIn_t q1, | ||
67 | ConfigurationIn_t q2) const; | ||
68 | |||
69 | protected: | ||
70 | /// Constructor with robot | ||
71 | /// Weighed distance is created from robot | ||
72 | 64 | Straight(const ProblemConstPtr_t& problem) | |
73 | 64 | : SteeringMethod(problem), weak_() {} | |
74 | /// Copy constructor | ||
75 | 8 | Straight(const Straight& other) : SteeringMethod(other), weak_() {} | |
76 | |||
77 | /// Store weak pointer to itself | ||
78 | 72 | void init(StraightWkPtr_t weak) { | |
79 | 72 | SteeringMethod::init(weak); | |
80 | 72 | weak_ = weak; | |
81 | 72 | } | |
82 | |||
83 | private: | ||
84 | StraightWkPtr_t weak_; | ||
85 | }; // Straight | ||
86 | } // namespace steeringMethod | ||
87 | /// \} | ||
88 | } // namespace core | ||
89 | } // namespace hpp | ||
90 | #endif // HPP_CORE_STEERING_METHOD_STRAIGHT_HH | ||
91 |