hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
constraint-set.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_SET_HH
20 # define HPP_CORE_CONSTRAINT_SET_HH
21 
22 # include <deque>
23 # include <hpp/core/constraint.hh>
24 
25 namespace hpp {
26  namespace core {
29 
36  class HPP_CORE_DLLAPI ConstraintSet : public Constraint
37  {
38  public:
40  static ConstraintSetPtr_t create (const DevicePtr_t& robot,
41  const std::string& name)
42  {
43  ConstraintSet* ptr = new ConstraintSet (robot, name);
44  ConstraintSetPtr_t shPtr (ptr);
45  ptr->init (shPtr);
46  return shPtr;
47  }
48 
51  {
52  ConstraintSet* ptr = new ConstraintSet (*cs);
53  ConstraintSetPtr_t shPtr (ptr);
54  ptr->init (shPtr);
55  return shPtr;
56  }
57 
59  virtual ConstraintPtr_t copy () const;
60 
62  void addConstraint (const ConstraintPtr_t& constraint)
63  {
64  constraint->addToConstraintSet (weak_.lock ());
65  }
66 
68  ConfigProjectorPtr_t configProjector () const;
69 
71  Constraints_t::iterator begin () {
72  return constraints_.begin ();
73  }
75  Constraints_t::iterator end () {
76  return constraints_.end ();
77  }
78 
80  virtual bool isSatisfied (ConfigurationIn_t config);
81 
86  virtual bool isSatisfied (ConfigurationIn_t config, vector_t& error);
87 
95 
97  size_type numberNonLockedDof () const;
98 
103  void compressVector (vectorIn_t normal, vectorOut_t small) const;
104 
112  void uncompressVector (vectorIn_t small, vectorOut_t normal) const;
113 
119  void compressMatrix (matrixIn_t normal, matrixOut_t small,
120  bool rows = true) const;
121 
127  void uncompressMatrix (matrixIn_t small, matrixOut_t normal,
128  bool rows = true) const;
130 
131  protected:
132  ConstraintSet (const DevicePtr_t& robot, const std::string& name);
134  ConstraintSet (const ConstraintSet& other);
136  void init (const ConstraintSetPtr_t& self)
137  {
138  Constraint::init (self);
139  weak_ = self;
140  }
141  virtual bool impl_compute (ConfigurationOut_t configuration);
142 
143  virtual std::ostream& print (std::ostream& os) const;
144  private:
145  virtual void addToConstraintSet (const ConstraintSetPtr_t& constraintSet)
146  {
147  for (Constraints_t::iterator itConstraint = constraints_.begin ();
148  itConstraint != constraints_.end (); itConstraint ++) {
149  (*itConstraint)->addToConstraintSet (constraintSet);
150  }
151  }
152 
153  void removeFirstElement ();
154 
155  Constraints_t constraints_;
156  Constraints_t::iterator configProjectorIt_;
157  Constraints_t::iterator trivialOrNotConfigProjectorIt_;
158  ConstraintSetWkPtr_t weak_;
159 
161  friend class Constraint;
162  friend class ConfigProjector;
163  }; // class ConstraintSet
165  } // namespace core
166 } // namespace hpp
167 
168 #endif // HPP_CORE_CONSTRAINT_SET_HH
void addConstraint(const ConstraintPtr_t &constraint)
Add a constraint to the set.
Definition: constraint-set.hh:62
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:114
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:97
static ConstraintSetPtr_t create(const DevicePtr_t &robot, const std::string &name)
Return shared pointer to new object.
Definition: constraint-set.hh:40
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:110
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition: fwd.hh:98
pinocchio::size_type size_type
Definition: fwd.hh:156
Constraints_t::iterator end()
Iterator over the constraints.
Definition: constraint-set.hh:75
Definition: config-projector.hh:57
Definition: constraint.hh:37
void init(const ConstraintPtr_t &self)
Store shared pointer to itself.
Definition: constraint.hh:79
pinocchio::vectorIn_t vectorIn_t
Definition: fwd.hh:202
constraints::matrixIn_t matrixIn_t
Definition: fwd.hh:149
static ConstraintSetPtr_t createCopy(const ConstraintSetPtr_t &cs)
Return shared pointer to new object.
Definition: constraint-set.hh:50
boost::shared_ptr< Constraint > ConstraintPtr_t
Definition: fwd.hh:109
pinocchio::vector_t vector_t
Definition: fwd.hh:201
void init(const ConstraintSetPtr_t &self)
Store weak pointer to itself.
Definition: constraint-set.hh:136
constraints::matrixOut_t matrixOut_t
Definition: fwd.hh:150
boost::shared_ptr< ConfigProjector > ConfigProjectorPtr_t
Definition: fwd.hh:104
pinocchio::vectorOut_t vectorOut_t
Definition: fwd.hh:203
Constraints_t::iterator begin()
Iterator over the constraints.
Definition: constraint-set.hh:71
std::deque< ConstraintPtr_t > Constraints_t
Definition: fwd.hh:112
Definition: constraint-set.hh:36