hpp-core  6.0.0
Implement basic classes for canonical path planning for kinematic chains.
steering-method.hh
Go to the documentation of this file.
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_HH
31 #define HPP_CORE_STEERING_METHOD_HH
32 
33 #include <hpp/core/fwd.hh>
34 #include <hpp/core/path.hh>
36 #include <hpp/util/debug.hh>
37 
38 namespace hpp {
39 namespace core {
42 
49  public:
56  PathPtr_t path;
57  try {
58  path = impl_compute(q1, q2);
59  } catch (const projection_error& e) {
60  hppDout(info, "Could not build path: " << e.what());
61  }
62  assert(q1 != q2 || path);
63  return path;
64  }
65 
68  return this->operator()(q1, q2);
69  }
70 
71  virtual ~SteeringMethod() {};
72 
74  virtual SteeringMethodPtr_t copy() const = 0;
75 
76  ProblemConstPtr_t problem() const { return problem_.lock(); }
77 
82 
84  void constraints(const ConstraintSetPtr_t& constraints) {
85  constraints_ = constraints;
86  }
87 
89  const ConstraintSetPtr_t& constraints() const { return constraints_; }
91 
92  protected:
95  : problem_(problem), constraints_(), weak_() {}
100  : problem_(other.problem_), constraints_(), weak_() {
101  if (other.constraints_) {
102  constraints_ =
103  HPP_DYNAMIC_PTR_CAST(ConstraintSet, other.constraints_->copy());
104  }
105  }
108  ConfigurationIn_t q2) const = 0;
110  void init(SteeringMethodWkPtr_t weak) { weak_ = weak; }
111 
112  private:
113  ProblemConstWkPtr_t problem_;
115  ConstraintSetPtr_t constraints_;
117  SteeringMethodWkPtr_t weak_;
118 }; // class SteeringMethod
120 } // namespace core
121 } // namespace hpp
122 #endif // HPP_CORE_STEERING_METHOD_HH
Definition: constraint-set.hh:47
Definition: steering-method.hh:48
virtual ~SteeringMethod()
Definition: steering-method.hh:71
SteeringMethod(const ProblemConstPtr_t &problem)
Constructor.
Definition: steering-method.hh:94
const ConstraintSetPtr_t & constraints() const
Get constraint set.
Definition: steering-method.hh:89
PathPtr_t steer(ConfigurationIn_t q1, ConfigurationIn_t q2) const
Definition: steering-method.hh:67
ProblemConstPtr_t problem() const
Definition: steering-method.hh:76
virtual SteeringMethodPtr_t copy() const =0
Copy instance and return shared pointer.
void init(SteeringMethodWkPtr_t weak)
Store weak pointer to itself.
Definition: steering-method.hh:110
PathPtr_t operator()(ConfigurationIn_t q1, ConfigurationIn_t q2) const
Definition: steering-method.hh:55
virtual PathPtr_t impl_compute(ConfigurationIn_t q1, ConfigurationIn_t q2) const =0
create a path between two configurations
void constraints(const ConstraintSetPtr_t &constraints)
Set constraint set.
Definition: steering-method.hh:84
SteeringMethod(const SteeringMethod &other)
Definition: steering-method.hh:99
#define HPP_CORE_DLLAPI
Definition: config.hh:88
shared_ptr< SteeringMethod > SteeringMethodPtr_t
Definition: fwd.hh:213
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:108
shared_ptr< const Problem > ProblemConstPtr_t
Definition: fwd.hh:197
shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:130
shared_ptr< Path > PathPtr_t
Definition: fwd.hh:187
Definition: bi-rrt-planner.hh:35
Definition: projection-error.hh:37
virtual const char * what() const noexcept
Definition: projection-error.hh:46