hpp-manipulation  4.9.0
Classes for manipulation planning.
leaf-connected-comp.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2016 CNRS
3 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
4 //
5 // This file is part of hpp-manipulation
6 // hpp-manipulation 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-manipulation 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-manipulation If not, see
17 // <http://www.gnu.org/licenses/>.
18 
19 #ifndef HPP_MANIPULATION_LEAF_CONNECTED_COMP_HH
20 #define HPP_MANIPULATION_LEAF_CONNECTED_COMP_HH
21 
22 #include <hpp/manipulation/config.hh>
23 #include <hpp/manipulation/fwd.hh>
25 
27 
28 namespace hpp {
29  namespace manipulation {
34  class HPP_MANIPULATION_DLLAPI LeafConnectedComp
35  {
36  public:
38  typedef std::set <RawPtr_t> LeafConnectedComps_t;
40  static LeafConnectedCompPtr_t create (const RoadmapPtr_t& roadmap);
41 
45  virtual void merge (const LeafConnectedCompPtr_t& otherCC);
46 
49  bool canReach (const LeafConnectedCompPtr_t& cc);
50 
55  bool canReach (const LeafConnectedCompPtr_t& cc,
57 
60  void addNode (const RoadmapNodePtr_t& node);
61 
62  virtual void setFirstNode (const RoadmapNodePtr_t& node);
63 
65  {
66  assert (!nodes_.empty());
67  return nodes_.front()->connectedComponent();
68  };
69 
70  const RoadmapNodes_t& nodes() const
71  {
72  return nodes_;
73  }
74 
76  {
77  return weak_.lock ();
78  }
79 
81  {
82  return from_;
83  }
84 
86  {
87  return to_;
88  }
89  protected:
91  : roadmap_(r) {}
92 
93  void init (const LeafConnectedCompWkPtr_t& shPtr)
94  {
95  weak_ = shPtr;
96  }
97 
100 
101  private:
102  static void clean (LeafConnectedComps_t& set);
103  // status variable to indicate whether or not CC has been visited
104  mutable bool explored_;
105  RoadmapWkPtr_t roadmap_;
106  LeafConnectedComps_t to_, from_;
107  LeafConnectedCompWkPtr_t weak_;
108  friend class Roadmap;
109  }; // class LeafConnectedComp
110 
111  class HPP_MANIPULATION_DLLAPI WeighedLeafConnectedComp :
112  public LeafConnectedComp
113  {
114  public:
115  void merge (const LeafConnectedCompPtr_t& otherCC);
116 
117  void setFirstNode (const RoadmapNodePtr_t& node);
118 
119  static WeighedLeafConnectedCompPtr_t create (const RoadmapPtr_t& roadmap);
120 
121  std::size_t indexOf (const graph::EdgePtr_t e) const;
122 
124  {
125  const value_type s = p_.sum();
126  p_ /= s;
127  }
128 
132  std::vector<graph::EdgePtr_t> edges_;
133 
134  protected:
136  : LeafConnectedComp(r), weight_(1) {}
137 
138  private:
139  }; // class LeafConnectedComp
140  } // namespace manipulation
141 } // namespace hpp
142 #endif // HPP_MANIPULATION_LEAF_CONNECTED_COMP_HH
const RoadmapNodes_t & nodes() const
Definition: leaf-connected-comp.hh:70
std::set< RawPtr_t > LeafConnectedComps_t
Definition: leaf-connected-comp.hh:38
core::vector_t vector_t
Definition: fwd.hh:82
boost::shared_ptr< State > StatePtr_t
Definition: fwd.hh:36
FCL_REAL r
Definition: leaf-connected-comp.hh:34
core::value_type value_type
Definition: fwd.hh:79
boost::shared_ptr< LeafConnectedComp > LeafConnectedCompPtr_t
Definition: fwd.hh:64
boost::shared_ptr< WeighedLeafConnectedComp > WeighedLeafConnectedCompPtr_t
Definition: fwd.hh:69
boost::shared_ptr< ConnectedComponent > ConnectedComponentPtr_t
void init(const LeafConnectedCompWkPtr_t &shPtr)
Definition: leaf-connected-comp.hh:93
assert(d.lhs()._blocks()==d.rhs()._blocks())
LeafConnectedComp * RawPtr_t
Definition: leaf-connected-comp.hh:37
value_type weight_
Definition: leaf-connected-comp.hh:129
WeighedLeafConnectedComp(const RoadmapPtr_t &r)
Definition: leaf-connected-comp.hh:135
const LeafConnectedComp::LeafConnectedComps_t & from() const
Definition: leaf-connected-comp.hh:80
boost::shared_ptr< Roadmap > RoadmapPtr_t
Definition: fwd.hh:57
RoadmapNodes_t nodes_
Definition: leaf-connected-comp.hh:99
Definition: roadmap.hh:35
static GradientBasedPtr_t create(const Problem &problem)
core::ConnectedComponentPtr_t connectedComponent() const
Definition: leaf-connected-comp.hh:64
boost::shared_ptr< Edge > EdgePtr_t
Definition: fwd.hh:37
std::vector< RoadmapNodePtr_t > RoadmapNodes_t
Definition: fwd.hh:60
graph::StatePtr_t state_
Definition: leaf-connected-comp.hh:98
Definition: leaf-connected-comp.hh:111
void normalizeProba()
Definition: leaf-connected-comp.hh:123
LeafConnectedComp(const RoadmapPtr_t &r)
Definition: leaf-connected-comp.hh:90
vector_t p_
Transition probabilities.
Definition: leaf-connected-comp.hh:131
std::vector< graph::EdgePtr_t > edges_
Definition: leaf-connected-comp.hh:132
const LeafConnectedComp::LeafConnectedComps_t & to() const
Definition: leaf-connected-comp.hh:85
Definition: roadmap-node.hh:32