hpp-core  4.9.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 
26 namespace hpp {
27  namespace core {
30 
37  class HPP_CORE_DLLAPI Constraint
38  {
39  public:
43  bool apply (ConfigurationOut_t configuration);
45  const std::string& name () const
46  {
47  return name_;
48  }
49 
53  virtual bool isSatisfied (ConfigurationIn_t config) = 0;
54 
60  virtual bool isSatisfied (ConfigurationIn_t config, vector_t& error) = 0;
61 
63  virtual ConstraintPtr_t copy () const = 0;
64 
65  virtual ~Constraint () {};
66 
67  protected:
69  virtual bool impl_compute (ConfigurationOut_t configuration) = 0;
71  Constraint (const std::string& name) : name_ (name), weak_ ()
72  {
73  }
74  Constraint (const Constraint& constraint) : name_ (constraint.name_),
75  weak_ ()
76  {
77  }
79  void init (const ConstraintPtr_t& self)
80  {
81  weak_ = self;
82  }
83  private:
84  virtual std::ostream& print (std::ostream& os) const = 0;
85  virtual void addToConstraintSet (const ConstraintSetPtr_t& constraintSet);
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  }; // class Constraint
98  inline std::ostream& operator<< (std::ostream& os,
99  const Constraint& constraint)
100  {
101  return constraint.print (os);
102  }
104  } // namespace core
105 } // namespace core
106 #endif // HPP_CORE_CONSTRAINT_HH
constraints::LockedJointPtr_t LockedJointPtr_t
Definition: fwd.hh:142
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:97
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:110
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition: fwd.hh:98
Definition: config-projector.hh:57
Definition: constraint.hh:37
void init(const ConstraintPtr_t &self)
Store shared pointer to itself.
Definition: constraint.hh:79
boost::shared_ptr< Constraint > ConstraintPtr_t
Definition: fwd.hh:109
const std::string & name() const
Get name of constraint.
Definition: constraint.hh:45
pinocchio::vector_t vector_t
Definition: fwd.hh:201
Constraint(const Constraint &constraint)
Definition: constraint.hh:74
virtual ~Constraint()
Definition: constraint.hh:65
Constraint(const std::string &name)
Constructor.
Definition: constraint.hh:71
std::ostream & operator<<(std::ostream &os, const Constraint &constraint)
Definition: constraint.hh:98
Definition: constraint-set.hh:36