hpp-manipulation  4.12.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 
23 #include <hpp/manipulation/fwd.hh>
25 
27 
28 namespace hpp {
29  namespace manipulation {
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 
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 
103 
104  private:
105  static void clean (LeafConnectedComps_t& set);
106  // status variable to indicate whether or not CC has been visited
107  mutable bool explored_;
108  RoadmapWkPtr_t roadmap_;
109  LeafConnectedComps_t to_, from_;
110  LeafConnectedCompWkPtr_t weak_;
111  friend class Roadmap;
112 
113  HPP_SERIALIZABLE();
114  }; // class LeafConnectedComp
115 
117  public LeafConnectedComp
118  {
119  public:
120  void merge (const LeafConnectedCompPtr_t& otherCC);
121 
122  void setFirstNode (const RoadmapNodePtr_t& node);
123 
125 
126  std::size_t indexOf (const graph::EdgePtr_t e) const;
127 
129  {
130  const value_type s = p_.sum();
131  p_ /= s;
132  }
133 
137  std::vector<graph::EdgePtr_t> edges_;
138 
139  protected:
141  : LeafConnectedComp(r), weight_(1) {}
142 
143  private:
145  HPP_SERIALIZABLE();
146  }; // class LeafConnectedComp
147  } // namespace manipulation
148 } // namespace hpp
149 #endif // HPP_MANIPULATION_LEAF_CONNECTED_COMP_HH
Definition: leaf-connected-comp.hh:35
virtual void setFirstNode(const RoadmapNodePtr_t &node)
RoadmapNodes_t nodes_
Definition: leaf-connected-comp.hh:99
LeafConnectedComp()
For serialization only.
Definition: leaf-connected-comp.hh:102
void init(const LeafConnectedCompWkPtr_t &shPtr)
Definition: leaf-connected-comp.hh:93
const RoadmapNodes_t & nodes() const
Definition: leaf-connected-comp.hh:70
LeafConnectedComp(const RoadmapPtr_t &r)
Definition: leaf-connected-comp.hh:90
bool canReach(const LeafConnectedCompPtr_t &cc)
const LeafConnectedComp::LeafConnectedComps_t & to() const
Definition: leaf-connected-comp.hh:85
const LeafConnectedComp::LeafConnectedComps_t & from() const
Definition: leaf-connected-comp.hh:80
std::set< RawPtr_t > LeafConnectedComps_t
Definition: leaf-connected-comp.hh:38
LeafConnectedComp * RawPtr_t
Definition: leaf-connected-comp.hh:37
void addNode(const RoadmapNodePtr_t &node)
static LeafConnectedCompPtr_t create(const RoadmapPtr_t &roadmap)
return a shared pointer to new instance
graph::StatePtr_t state_
Definition: leaf-connected-comp.hh:98
bool canReach(const LeafConnectedCompPtr_t &cc, LeafConnectedComp::LeafConnectedComps_t &cc2Tocc1)
virtual void merge(const LeafConnectedCompPtr_t &otherCC)
core::ConnectedComponentPtr_t connectedComponent() const
Definition: leaf-connected-comp.hh:64
Definition: roadmap-node.hh:33
Definition: roadmap.hh:36
Definition: leaf-connected-comp.hh:118
static WeighedLeafConnectedCompPtr_t create(const RoadmapPtr_t &roadmap)
void setFirstNode(const RoadmapNodePtr_t &node)
std::vector< graph::EdgePtr_t > edges_
Definition: leaf-connected-comp.hh:137
WeighedLeafConnectedComp(const RoadmapPtr_t &r)
Definition: leaf-connected-comp.hh:140
vector_t p_
Transition probabilities.
Definition: leaf-connected-comp.hh:136
void normalizeProba()
Definition: leaf-connected-comp.hh:128
void merge(const LeafConnectedCompPtr_t &otherCC)
std::size_t indexOf(const graph::EdgePtr_t e) const
value_type weight_
Definition: leaf-connected-comp.hh:134
#define HPP_MANIPULATION_DLLAPI
Definition: config.hh:64
shared_ptr< State > StatePtr_t
Definition: fwd.hh:36
shared_ptr< Edge > EdgePtr_t
Definition: fwd.hh:37
shared_ptr< Roadmap > RoadmapPtr_t
Definition: fwd.hh:58
shared_ptr< WeighedLeafConnectedComp > WeighedLeafConnectedCompPtr_t
Definition: fwd.hh:70
shared_ptr< LeafConnectedComp > LeafConnectedCompPtr_t
Definition: fwd.hh:65
shared_ptr< ConnectedComponent > ConnectedComponentPtr_t
Definition: fwd.hh:63
core::value_type value_type
Definition: fwd.hh:82
std::set< LeafConnectedCompPtr_t > LeafConnectedComps_t
Definition: fwd.hh:68
core::vector_t vector_t
Definition: fwd.hh:85
std::vector< RoadmapNodePtr_t > RoadmapNodes_t
Definition: fwd.hh:61
Definition: main.hh:1