hpp-core  4.12.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 // 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_CONSTRAINT_HH
20 # define HPP_CORE_CONSTRAINT_HH
21 
22 # include <ostream>
23 # include <hpp/core/config.hh>
24 # include <hpp/core/fwd.hh>
25 # include <hpp/util/serialization-fwd.hh>
26 
27 namespace hpp {
28  namespace core {
31 
39  {
40  public:
44  bool apply (ConfigurationOut_t configuration);
46  const std::string& name () const
47  {
48  return name_;
49  }
50 
54  virtual bool isSatisfied (ConfigurationIn_t config) = 0;
55 
61  virtual bool isSatisfied (ConfigurationIn_t config, vector_t& error) = 0;
62 
64  virtual ConstraintPtr_t copy () const = 0;
65 
66  virtual ~Constraint () {};
67 
68  protected:
70  virtual bool impl_compute (ConfigurationOut_t configuration) = 0;
72  Constraint (const std::string& name) : name_ (name), weak_ ()
73  {
74  }
75  Constraint (const Constraint& constraint) : name_ (constraint.name_),
76  weak_ ()
77  {
78  }
80  void init (const ConstraintPtr_t& self)
81  {
82  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  }
90 
91  std::string name_;
92  ConstraintWkPtr_t weak_;
93  friend class ConstraintSet;
95  friend class ConfigProjector;
96  friend std::ostream& operator<< (std::ostream& os, const Constraint&);
97 
98  Constraint() {}
99  HPP_SERIALIZABLE();
100  }; // class Constraint
101  inline std::ostream& operator<< (std::ostream& os,
102  const Constraint& constraint)
103  {
104  return constraint.print (os);
105  }
107  } // namespace core
108 } // namespace core
109 #endif // HPP_CORE_CONSTRAINT_HH
constraints::LockedJointPtr_t LockedJointPtr_t
Definition: fwd.hh:142
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:97
Definition: bi-rrt-planner.hh:24
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition: fwd.hh:98
Definition: config-projector.hh:57
Definition: constraint.hh:38
void init(const ConstraintPtr_t &self)
Store shared pointer to itself.
Definition: constraint.hh:80
const std::string & name() const
Get name of constraint.
Definition: constraint.hh:46
pinocchio::vector_t vector_t
Definition: fwd.hh:202
Constraint(const Constraint &constraint)
Definition: constraint.hh:75
virtual ~Constraint()
Definition: constraint.hh:66
Constraint(const std::string &name)
Constructor.
Definition: constraint.hh:72
std::ostream & operator<<(std::ostream &os, const Constraint &constraint)
Definition: constraint.hh:101
Definition: constraint-set.hh:36
#define HPP_CORE_DLLAPI
Definition: config.hh:64
shared_ptr< Constraint > ConstraintPtr_t
Definition: fwd.hh:109
constraints::LockedJoint LockedJoint
Definition: fwd.hh:141