hpp-constraints  4.9.1
Definition of basic geometric constraints for motion planning
implicit-constraint-set.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2016 - 2018 CNRS
3 // Authors: Joseph Mirabel, Florent Lamiraux
4 //
5 // This file is part of hpp-constraints.
6 // hpp-constraints 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-constraints 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-constraints. If not, see
17 // <http://www.gnu.org/licenses/>.
18 
19 #ifndef HPP_CONSTRAINTS_IMPLICIT_CONSTRAINT_SET_HH
20 # define HPP_CONSTRAINTS_IMPLICIT_CONSTRAINT_SET_HH
21 
22 # include <hpp/constraints/fwd.hh>
25 
26 namespace hpp {
27  namespace constraints {
30 
34  class HPP_CONSTRAINTS_DLLAPI ImplicitConstraintSet :
35  public Implicit
36  {
37  public:
38  typedef std::vector<ImplicitPtr_t> Implicits_t;
39 
43  static ImplicitConstraintSetPtr_t create (const std::string& name)
44  {
46  (new ImplicitConstraintSet(name));
47  }
48 
49  virtual ~ImplicitConstraintSet () {}
50 
53 
54  void add (const ImplicitPtr_t& constraint)
55  {
57  function_));
60  functions->add (constraint->functionPtr ());
61  constraints_.push_back(constraint);
62  // Handle comparison types
63  const ComparisonTypes_t& comp (constraint->comparisonType ());
64  for (std::size_t i = 0; i < comp.size(); ++i) {
65  switch (comp[i]) {
66  case Superior:
67  case Inferior:
68  inequalityIndices_.push_back (comparison_.size());
69  break;
70  case Equality:
71  equalityIndices_.addRow(comparison_.size(), 1);
72  break;
73  default:
74  break;
75  }
76  comparison_.push_back (comp[i]);
77  }
78  equalityIndices_.updateRows<true, true, true>();
79  }
80 
82  const std::vector<std::size_t>& inequalityIndices () const
83  {
84  return inequalityIndices_;
85  }
88  {
89  return equalityIndices_;
90  }
92  const Implicits_t& constraints () const
93  {
94  return constraints_;
95  }
96 
98  void merge (const ImplicitConstraintSetPtr_t& other)
99  {
100  const Implicits_t& constraints = other->constraints();
101  for (Implicits_t::const_iterator constraint = constraints.begin();
102  constraint != constraints.end(); ++constraint)
103  add (*constraint);
104  }
105 
107 
108  std::ostream& print (std::ostream& os) const
109  {
110  function_->print (os);
111  return os;
112  }
113 
117  ImplicitConstraintSet (const std::string& name)
120  {
121  }
122 
126  {}
127 
131  {
132  const Implicits_t& constraints = o.constraints();
133  for (Implicits_t::const_iterator constraint = constraints.begin();
134  constraint != constraints.end(); ++constraint)
135  add (*constraint);
136  }
137 
138  private:
139  Implicits_t constraints_;
140  mutable std::vector <LiegroupElement> result_;
141  ComparisonTypes_t comparison_;
142  std::vector<std::size_t> inequalityIndices_;
143  Eigen::RowBlockIndices equalityIndices_;
144  }; // class ImplicitConstraintSet
146  } // namespace constraints
147 } // namespace hpp
148 
149 #endif // HPP_CONSTRAINTS_IMPLICIT_CONSTRAINT_SET_HH
std::vector< ImplicitPtr_t > Implicits_t
Definition: implicit-constraint-set.hh:38
Definition: implicit-constraint-set.hh:34
ImplicitConstraintSet(const std::string &name)
Definition: implicit-constraint-set.hh:117
void merge(const ImplicitConstraintSetPtr_t &other)
The output columns selection of other is not taken into account.
Definition: implicit-constraint-set.hh:98
ImplicitConstraintSet(const ImplicitConstraintSet &o)
Definition: implicit-constraint-set.hh:128
Definition: fwd.hh:168
ObjectFactory * create(ObjectFactory *parent=NULL, const XMLElement *element=NULL)
#define HPP_STATIC_PTR_CAST(t, x)
const Eigen::RowBlockIndices & equalityIndices() const
Get indices of constraint coordinates that are equality.
Definition: implicit-constraint-set.hh:87
Definition: fwd.hh:167
#define HPP_DYNAMIC_PTR_CAST(t, x)
Definition: differentiable-function-set.hh:33
const Implicits_t & constraints() const
Get constraints.
Definition: implicit-constraint-set.hh:92
ImplicitConstraintSet()
Definition: implicit-constraint-set.hh:123
std::vector< ComparisonType > ComparisonTypes_t
Definition: fwd.hh:170
assert(d.lhs()._blocks()==d.rhs()._blocks())
boost::shared_ptr< ImplicitConstraintSet > ImplicitConstraintSetPtr_t
Definition: fwd.hh:162
Definition: fwd.hh:165
static ImplicitConstraintSetPtr_t create(const std::string &name)
Definition: implicit-constraint-set.hh:43
std::ostream & print(std::ostream &os) const
Definition: implicit-constraint-set.hh:108
virtual ~ImplicitConstraintSet()
Definition: implicit-constraint-set.hh:49
void add(const ImplicitPtr_t &constraint)
Definition: implicit-constraint-set.hh:54
const std::vector< std::size_t > & inequalityIndices() const
Get indices of constraint coordinates that are inequality.
Definition: implicit-constraint-set.hh:82
Definition: implicit.hh:96
boost::shared_ptr< Implicit > ImplicitPtr_t
Definition: fwd.hh:157
boost::shared_ptr< DifferentiableFunctionSet > DifferentiableFunctionSetPtr_t
Definition: fwd.hh:97
Vec3f o