hpp-manipulation  6.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 
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:
128 
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 
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>
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:
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;
190 
192  void add(const RoadmapNodePtr_t& n);
193 
194  std::ostream& print(std::ostream& os) const;
195 
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
Definition: roadmap-node.hh:42
Definition: statistics.hh:122
void parametrizer(const ConstraintSetPtr_t p)
vector_t parameter(ConfigurationIn_t q) const
Whether the configuration is the submanifold $\mathcal{M}$.
ConstraintSetPtr_t condition() const
void condition(const ConstraintSetPtr_t c)
bool contains(ConfigurationIn_t q) const
Whether the configuration is the submanifold $\mathcal{M}$.
ConstraintSetPtr_t parametrizer() const
Definition: statistics.hh:104
virtual void add(const RoadmapNodePtr_t &node)=0
virtual ~Histogram()
Definition: statistics.hh:106
virtual HistogramPtr_t clone() const =0
Definition: statistics.hh:46
LeafBin(const vector_t &v, value_type *threshold_)
std::ostream & print(std::ostream &os) const
std::list< RoadmapNodePtr_t > RoadmapNodes_t
Definition: statistics.hh:49
::hpp::statistics::Bin Parent
Definition: statistics.hh:48
bool operator==(const LeafBin &rhs) const
const vector_t & value() const
bool operator<(const LeafBin &rhs) const
void push_back(const RoadmapNodePtr_t &n)
unsigned int numberOfObsOutOfConnectedComponent(const core::ConnectedComponentPtr_t &cc) const
const RoadmapNodes_t & nodes() const
Definition: statistics.hh:144
void clear()
Definition: statistics.hh:163
statistics::DiscreteDistribution< RoadmapNodePtr_t > getDistrib() const
::hpp::statistics::Statistics< LeafBin > Parent
Definition: statistics.hh:146
const Foliation & foliation() const
Definition: statistics.hh:165
static LeafHistogramPtr_t create(const Foliation f)
statistics::DiscreteDistribution< RoadmapNodePtr_t > getDistribOutOfConnectedComponent(const core::ConnectedComponentPtr_t &cc) const
void add(const RoadmapNodePtr_t &n)
Insert an occurence of a value in the histogram.
virtual HistogramPtr_t clone() const
std::ostream & print(std::ostream &os) const
Definition: statistics.hh:80
NodeBin(const StatePtr_t &n)
bool operator==(const NodeBin &rhs) const
std::ostream & print(std::ostream &os) const
void push_back(const RoadmapNodePtr_t &n)
bool operator<(const NodeBin &rhs) const
const StatePtr_t & state() const
::hpp::statistics::Bin Parent
Definition: statistics.hh:82
Definition: statistics.hh:183
const graph::GraphPtr_t & constraintGraph() const
virtual HistogramPtr_t clone() const
void clear()
Definition: statistics.hh:200
StateHistogram(const graph::GraphPtr_t &graph)
std::ostream & print(std::ostream &os) const
void add(const RoadmapNodePtr_t &n)
Insert an occurence of a value in the histogram.
::hpp::statistics::Statistics< NodeBin > Parent
Definition: statistics.hh:185
#define HPP_MANIPULATION_DLLLOCAL
Definition: config.hh:64
#define HPP_MANIPULATION_DLLAPI
Definition: config.hh:88
shared_ptr< State > StatePtr_t
Definition: fwd.hh:48
shared_ptr< StateHistogram > NodeHistogramPtr_t
Definition: statistics.hh:206
shared_ptr< Histogram > HistogramPtr_t
Definition: fwd.hh:69
shared_ptr< Graph > GraphPtr_t
Definition: fwd.hh:47
shared_ptr< LeafHistogram > LeafHistogramPtr_t
Definition: fwd.hh:72
shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:138
shared_ptr< ConnectedComponent > ConnectedComponentPtr_t
Definition: fwd.hh:73
core::value_type value_type
Definition: fwd.hh:89
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:49
core::vector_t vector_t
Definition: fwd.hh:92
std::vector< RoadmapNodePtr_t > RoadmapNodes_t
Definition: fwd.hh:71
Definition: main.hh:1