hpp-core: include/hpp/core/steering-method.hh Source File

hpp-core 9.0.2 Implement basic classes for canonical path planning for kinematic chains.

Loading...
Searching...
No Matches
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>
35#include <hpp/core/projection-error.hh>
36#include <hpp/util/debug.hh>
37
38namespace hpp {
39namespace core {
42
48 class HPP_CORE_DLLAPI SteeringMethod {
49 public:
55 PathPtr_t operator()(ConfigurationIn_t q1, ConfigurationIn_t q2) const {
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
67 PathPtr_t steer(ConfigurationIn_t q1, ConfigurationIn_t q2) const {
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:
94 SteeringMethod(const ProblemConstPtr_t& problem)
95 : problem_(problem), constraints_(), weak_() {}
99 SteeringMethod(const SteeringMethod& other)
100 : problem_(other.problem_), constraints_(), weak_() {
101 if (other.constraints_) {
102 constraints_ =
103 HPP_DYNAMIC_PTR_CAST(ConstraintSet, other.constraints_->copy());
104 }
105 }
107 virtual PathPtr_t impl_compute(ConfigurationIn_t q1,
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
hpp::core::ConstraintSet
Definition constraint-set.hh:47
hpp::core::SteeringMethod
Definition steering-method.hh:48
hpp::core::SteeringMethod::~SteeringMethod
virtual ~SteeringMethod()
Definition steering-method.hh:71
hpp::core::SteeringMethod::SteeringMethod
SteeringMethod(const ProblemConstPtr_t &problem)
Constructor.
Definition steering-method.hh:94
hpp::core::SteeringMethod::steer
PathPtr_t steer(ConfigurationIn_t q1, ConfigurationIn_t q2) const
Definition steering-method.hh:67
hpp::core::SteeringMethod::problem
ProblemConstPtr_t problem() const
Definition steering-method.hh:76
hpp::core::SteeringMethod::copy
virtual SteeringMethodPtr_t copy() const =0
Copy instance and return shared pointer.
hpp::core::SteeringMethod::init
void init(SteeringMethodWkPtr_t weak)
Store weak pointer to itself.
Definition steering-method.hh:110
hpp::core::SteeringMethod::operator()
PathPtr_t operator()(ConfigurationIn_t q1, ConfigurationIn_t q2) const
Definition steering-method.hh:55
hpp::core::SteeringMethod::constraints
const ConstraintSetPtr_t & constraints() const
Get constraint set.
Definition steering-method.hh:89
hpp::core::SteeringMethod::impl_compute
virtual PathPtr_t impl_compute(ConfigurationIn_t q1, ConfigurationIn_t q2) const =0
create a path between two configurations
hpp::core::SteeringMethod::constraints
void constraints(const ConstraintSetPtr_t &constraints)
Set constraint set.
Definition steering-method.hh:84
hpp::core::SteeringMethod::SteeringMethod
SteeringMethod(const SteeringMethod &other)
Definition steering-method.hh:99
HPP_CORE_DLLAPI
#define HPP_CORE_DLLAPI
Definition config.hh:88
debug.hh
fwd.hh
hppDout
#define hppDout(channel, data)
hpp
hpp::core::SteeringMethodPtr_t
shared_ptr< SteeringMethod > SteeringMethodPtr_t
Definition fwd.hh:213
hpp::core::ConfigurationIn_t
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition fwd.hh:108
hpp::core::ProblemConstPtr_t
shared_ptr< const Problem > ProblemConstPtr_t
Definition fwd.hh:197
hpp::core::ConstraintSetPtr_t
shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition fwd.hh:130
hpp::core::PathPtr_t
shared_ptr< Path > PathPtr_t
Definition fwd.hh:187
path.hh
HPP_DYNAMIC_PTR_CAST
#define HPP_DYNAMIC_PTR_CAST(t, x)
projection-error.hh
hpp::core::projection_error
Definition projection-error.hh:37
hpp::core::projection_error::what
virtual const char * what() const noexcept
Definition projection-error.hh:46