hpp-core  6.0.0
Implement basic classes for canonical path planning for kinematic chains.
constraint.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_CONSTRAINT_HH
31 #define HPP_CORE_CONSTRAINT_HH
32 
33 #include <hpp/core/config.hh>
34 #include <hpp/core/fwd.hh>
35 #include <hpp/util/serialization-fwd.hh>
36 #include <ostream>
37 
38 namespace hpp {
39 namespace core {
42 
50  public:
54  bool apply(ConfigurationOut_t configuration);
56  const std::string& name() const { return name_; }
57 
61  virtual bool isSatisfied(ConfigurationIn_t config) = 0;
62 
68  virtual bool isSatisfied(ConfigurationIn_t config, vector_t& error) = 0;
69 
71  virtual ConstraintPtr_t copy() const = 0;
72 
73  virtual ~Constraint() {};
74 
75  protected:
77  virtual bool impl_compute(ConfigurationOut_t configuration) = 0;
79  Constraint(const std::string& name) : name_(name), weak_() {}
80  Constraint(const Constraint& constraint) : name_(constraint.name_), weak_() {}
82  void init(const ConstraintPtr_t& self) { weak_ = self; }
83 
84  private:
85  virtual std::ostream& print(std::ostream& os) const = 0;
86 
87  virtual void addLockedJoint(const LockedJointPtr_t&) {}
88 
89  std::string name_;
90  ConstraintWkPtr_t weak_;
91  friend class ConstraintSet;
93  friend class ConfigProjector;
94  friend std::ostream& operator<<(std::ostream& os, const Constraint&);
95 
96  Constraint() {}
97  HPP_SERIALIZABLE();
98 }; // class Constraint
99 inline std::ostream& operator<<(std::ostream& os,
100  const Constraint& constraint) {
101  return constraint.print(os);
102 }
104 } // namespace core
105 } // namespace hpp
106 #endif // HPP_CORE_CONSTRAINT_HH
Definition: config-projector.hh:66
Definition: constraint-set.hh:47
Definition: constraint.hh:49
virtual bool isSatisfied(ConfigurationIn_t config, vector_t &error)=0
virtual bool impl_compute(ConfigurationOut_t configuration)=0
User defined implementation of the constraint.
Constraint(const Constraint &constraint)
Definition: constraint.hh:80
bool apply(ConfigurationOut_t configuration)
void init(const ConstraintPtr_t &self)
Store shared pointer to itself.
Definition: constraint.hh:82
virtual bool isSatisfied(ConfigurationIn_t config)=0
Constraint(const std::string &name)
Constructor.
Definition: constraint.hh:79
virtual ~Constraint()
Definition: constraint.hh:73
virtual ConstraintPtr_t copy() const =0
return shared pointer to copy
const std::string & name() const
Get name of constraint.
Definition: constraint.hh:56
#define HPP_CORE_DLLAPI
Definition: config.hh:88
std::ostream & operator<<(std::ostream &os, const Constraint &constraint)
Definition: constraint.hh:99
shared_ptr< Constraint > ConstraintPtr_t
Definition: fwd.hh:129
constraints::LockedJoint LockedJoint
Definition: fwd.hh:158
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition: fwd.hh:109
pinocchio::vector_t vector_t
Definition: fwd.hh:220
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:108
constraints::LockedJointPtr_t LockedJointPtr_t
Definition: fwd.hh:159
Definition: bi-rrt-planner.hh:35