hpp-manipulation  5.0.0
Classes for manipulation planning.
statistics.hh
Go to the documentation of this file.
1 // Copyright (c) 2014, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // 1. Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28 
29 #ifndef HPP_MANIPULATION_GRAPH_STATISTICS_HH
30 #define HPP_MANIPULATION_GRAPH_STATISTICS_HH
31 
33 #include <hpp/statistics/bin.hh>
34 #include <hpp/util/debug.hh>
35 
37 #include "hpp/manipulation/fwd.hh"
40 
41 namespace hpp {
42 namespace manipulation {
43 namespace graph {
46 class HPP_MANIPULATION_DLLAPI LeafBin : public ::hpp::statistics::Bin {
47  public:
48  typedef ::hpp::statistics::Bin Parent;
49  typedef std::list<RoadmapNodePtr_t> RoadmapNodes_t;
50 
51  LeafBin(const vector_t& v, value_type* threshold_);
52 
53  void push_back(const RoadmapNodePtr_t& n);
54 
55  bool operator<(const LeafBin& rhs) const;
56 
57  bool operator==(const LeafBin& rhs) const;
58 
59  const vector_t& value() const;
60 
61  std::ostream& print(std::ostream& os) const;
62 
63  unsigned int numberOfObsOutOfConnectedComponent(
64  const core::ConnectedComponentPtr_t& cc) const;
65 
66  const RoadmapNodes_t& nodes() const;
67 
68  private:
69  vector_t value_;
70 
71  RoadmapNodes_t nodes_;
72 
73  value_type* thr_;
74 
75  std::ostream& printValue(std::ostream& os) const;
76 };
77 
80 class HPP_MANIPULATION_DLLLOCAL NodeBin : public ::hpp::statistics::Bin {
81  public:
82  typedef ::hpp::statistics::Bin Parent;
83  NodeBin(const StatePtr_t& n);
84 
85  void push_back(const RoadmapNodePtr_t& n);
86 
87  bool operator<(const NodeBin& rhs) const;
88 
89  bool operator==(const NodeBin& rhs) const;
90 
91  const StatePtr_t& state() const;
92 
93  std::ostream& print(std::ostream& os) const;
94 
95  private:
96  StatePtr_t state_;
97 
98  typedef std::list<RoadmapNodePtr_t> RoadmapNodes_t;
99  RoadmapNodes_t roadmapNodes_;
100 
101  std::ostream& printValue(std::ostream& os) const;
102 };
103 
105  public:
106  virtual ~Histogram(){};
107 
108  virtual void add(const RoadmapNodePtr_t& node) = 0;
109 
110  virtual HistogramPtr_t clone() const = 0;
111 
112  virtual void clear() = 0;
113 };
114 
123  public:
125  bool contains(ConfigurationIn_t q) const;
127  vector_t parameter(ConfigurationIn_t q) const;
128 
129  void condition(const ConstraintSetPtr_t c);
130  ConstraintSetPtr_t condition() const;
131  void parametrizer(const ConstraintSetPtr_t p);
132  ConstraintSetPtr_t parametrizer() const;
133 
134  private:
135  // condition_ contains the constraints defining the submanifold
136  // containing all the leaf.
137  // parametrizer_ contains the constraints providing a parametrization
138  // of the foliation.
139  ConstraintSetPtr_t condition_, parametrizer_;
140 };
141 
143  : public ::hpp::statistics::Statistics<LeafBin>,
144  public Histogram {
145  public:
146  typedef ::hpp::statistics::Statistics<LeafBin> Parent;
147 
148  static LeafHistogramPtr_t create(const Foliation f);
149 
151  void add(const RoadmapNodePtr_t& n);
152 
153  std::ostream& print(std::ostream& os) const;
154 
155  virtual HistogramPtr_t clone() const;
156 
157  statistics::DiscreteDistribution<RoadmapNodePtr_t>
158  getDistribOutOfConnectedComponent(
159  const core::ConnectedComponentPtr_t& cc) const;
160 
161  statistics::DiscreteDistribution<RoadmapNodePtr_t> getDistrib() const;
162 
163  void clear() { Parent::clear(); }
164 
165  const Foliation& foliation() const { return f_; }
166 
167  protected:
172  LeafHistogram(const Foliation f);
173 
174  private:
175  Foliation f_;
176 
178  value_type threshold_;
179 };
180 
182  : public ::hpp::statistics::Statistics<NodeBin>,
183  public Histogram {
184  public:
185  typedef ::hpp::statistics::Statistics<NodeBin> Parent;
189  StateHistogram(const graph::GraphPtr_t& graph);
190 
192  void add(const RoadmapNodePtr_t& n);
193 
194  std::ostream& print(std::ostream& os) const;
195 
196  const graph::GraphPtr_t& constraintGraph() const;
197 
198  virtual HistogramPtr_t clone() const;
199 
200  void clear() { Parent::clear(); }
201 
202  private:
204  graph::GraphPtr_t graph_;
205 };
206 typedef shared_ptr<StateHistogram> NodeHistogramPtr_t;
207 } // namespace graph
208 } // namespace manipulation
209 } // namespace hpp
210 
211 #endif // HPP_MANIPULATION_GRAPH_STATISTICS_HH
shared_ptr< StateHistogram > NodeHistogramPtr_t
Definition: statistics.hh:206
Definition: main.hh:1
::hpp::statistics::Bin Parent
Definition: statistics.hh:48
void clear()
Definition: statistics.hh:163
Definition: statistics.hh:104
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:49
core::vector_t vector_t
Definition: fwd.hh:92
shared_ptr< ConnectedComponent > ConnectedComponentPtr_t
Definition: fwd.hh:73
shared_ptr< Histogram > HistogramPtr_t
Definition: fwd.hh:69
core::value_type value_type
Definition: fwd.hh:89
::hpp::statistics::Bin Parent
Definition: statistics.hh:82
#define HPP_MANIPULATION_DLLAPI
Definition: config.hh:88
const Foliation & foliation() const
Definition: statistics.hh:165
Definition: statistics.hh:80
#define HPP_MANIPULATION_DLLLOCAL
Definition: config.hh:64
Definition: statistics.hh:122
void clear()
Definition: statistics.hh:200
Definition: statistics.hh:142
::hpp::statistics::Statistics< NodeBin > Parent
Definition: statistics.hh:185
shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:138
virtual ~Histogram()
Definition: statistics.hh:106
std::list< RoadmapNodePtr_t > RoadmapNodes_t
Definition: statistics.hh:49
shared_ptr< LeafHistogram > LeafHistogramPtr_t
Definition: fwd.hh:72
Definition: statistics.hh:46
std::vector< RoadmapNodePtr_t > RoadmapNodes_t
Definition: fwd.hh:71
shared_ptr< Graph > GraphPtr_t
Definition: fwd.hh:47
shared_ptr< State > StatePtr_t
Definition: fwd.hh:48
Definition: statistics.hh:181
::hpp::statistics::Statistics< LeafBin > Parent
Definition: statistics.hh:146
Definition: roadmap-node.hh:42