hpp-core  4.9.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 // This file is part of hpp-core
6 // hpp-core is free software: you can redistribute it
7 // and/or modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation, either version
9 // 3 of the License, or (at your option) any later version.
10 //
11 // hpp-core is distributed in the hope that it will be
12 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Lesser Public License for more details. You should have
15 // received a copy of the GNU Lesser General Public License along with
16 // hpp-core If not, see
17 // <http://www.gnu.org/licenses/>.
18 
19 #ifndef HPP_CORE_STEERING_METHOD_HH
20 # define HPP_CORE_STEERING_METHOD_HH
21 
22 # include <hpp/util/debug.hh>
23 
24 # include <hpp/core/fwd.hh>
25 # include <hpp/core/path.hh>
27 
28 namespace hpp {
29  namespace core {
32 
38  class HPP_CORE_DLLAPI SteeringMethod
39  {
40  public:
46  PathPtr_t operator() (ConfigurationIn_t q1,
47  ConfigurationIn_t q2) const
48  {
49  PathPtr_t path;
50  try {
51  path = impl_compute (q1, q2);
52  } catch (const projection_error& e) {
53  hppDout (info, "Could not build path: " << e.what());
54  }
55  assert (q1 != q2 || path);
56  return path;
57  }
58 
61  {
62  return this->operator() (q1, q2);
63  }
64 
65  virtual ~SteeringMethod () {};
66 
68  virtual SteeringMethodPtr_t copy () const = 0;
69 
70  const Problem& problem() const
71  {
72  return problem_;
73  }
74 
79 
81  void constraints (const ConstraintSetPtr_t& constraints)
82  {
83  constraints_ = constraints;
84  }
85 
88  {
89  return constraints_;
90  }
92 
93  protected:
95  SteeringMethod (const Problem& problem) :
96  problem_ (problem), constraints_ (), weak_ ()
97  {
98  }
103  problem_ (other.problem_), constraints_ (), weak_ ()
104  {
105  if (other.constraints_) {
106  constraints_ = HPP_DYNAMIC_PTR_CAST (ConstraintSet,
107  other.constraints_->copy ());
108  }
109  }
111  virtual PathPtr_t impl_compute (ConfigurationIn_t q1,
112  ConfigurationIn_t q2) const = 0;
114  void init (SteeringMethodWkPtr_t weak)
115  {
116  weak_ = weak;
117  }
118 
120 
121  private:
123  ConstraintSetPtr_t constraints_;
125  SteeringMethodWkPtr_t weak_;
126  }; // class SteeringMethod
128  } // namespace core
129 } // namespace hpp
130 #endif // HPP_CORE_STEERING_METHOD_HH
boost::shared_ptr< Path > PathPtr_t
Definition: fwd.hh:170
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:97
#define hppDout(channel, data)
Definition: problem.hh:48
virtual ~SteeringMethod()
Definition: steering-method.hh:65
Definition: steering-method.hh:38
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:110
const ConstraintSetPtr_t & constraints() const
Get constraint set.
Definition: steering-method.hh:87
#define HPP_DYNAMIC_PTR_CAST(t, x)
SteeringMethod(const Problem &problem)
Constructor.
Definition: steering-method.hh:95
Definition: projection-error.hh:26
virtual const char * what() const
Definition: projection-error.hh:40
assert(d.lhs()._blocks()==d.rhs()._blocks())
void init(SteeringMethodWkPtr_t weak)
Store weak pointer to itself.
Definition: steering-method.hh:114
PathPtr_t steer(ConfigurationIn_t q1, ConfigurationIn_t q2) const
Definition: steering-method.hh:60
SteeringMethod(const SteeringMethod &other)
Definition: steering-method.hh:102
const Problem & problem() const
Definition: steering-method.hh:70
boost::shared_ptr< SteeringMethod > SteeringMethodPtr_t
Definition: fwd.hh:194
Definition: constraint-set.hh:36
const Problem & problem_
Definition: steering-method.hh:119
void constraints(const ConstraintSetPtr_t &constraints)
Set constraint set.
Definition: steering-method.hh:81