hpp-manipulation  4.9.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 // This file is part of hpp-manipulation.
5 // hpp-manipulation is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-manipulation is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-manipulation. If not, see <http://www.gnu.org/licenses/>.
16 
17 
18 #ifndef HPP_MANIPULATION_GRAPH_STATISTICS_HH
19 # define HPP_MANIPULATION_GRAPH_STATISTICS_HH
20 
21 # include <hpp/util/debug.hh>
22 
23 # include <hpp/statistics/bin.hh>
24 
25 # include "hpp/manipulation/config.hh"
26 # include "hpp/manipulation/fwd.hh"
30 
31 namespace hpp {
32  namespace manipulation {
33  namespace graph {
36  class HPP_MANIPULATION_DLLAPI LeafBin : public ::hpp::statistics::Bin
37  {
38  public :
39  typedef ::hpp::statistics::Bin Parent;
40  typedef std::list <RoadmapNodePtr_t> RoadmapNodes_t;
41 
42  LeafBin(const vector_t& v, value_type* threshold_);
43 
44  void push_back(const RoadmapNodePtr_t& n);
45 
46  bool operator<(const LeafBin& rhs) const;
47 
48  bool operator==(const LeafBin& rhs) const;
49 
50  const vector_t& value () const;
51 
52  std::ostream& print (std::ostream& os) const;
53 
54  unsigned int numberOfObsOutOfConnectedComponent (const core::ConnectedComponentPtr_t& cc) const;
55 
56  const RoadmapNodes_t& nodes () const;
57 
58  private:
59  vector_t value_;
60 
61  RoadmapNodes_t nodes_;
62 
63  value_type* thr_;
64 
65  std::ostream& printValue (std::ostream& os) const;
66  };
67 
70  class HPP_MANIPULATION_DLLLOCAL NodeBin : public ::hpp::statistics::Bin
71  {
72  public :
73  typedef ::hpp::statistics::Bin Parent;
74  NodeBin(const StatePtr_t& n);
75 
76  void push_back(const RoadmapNodePtr_t& n);
77 
78  bool operator<(const NodeBin& rhs) const;
79 
80  bool operator==(const NodeBin& rhs) const;
81 
82  const StatePtr_t& state () const;
83 
84  std::ostream& print (std::ostream& os) const;
85 
86  private:
87  StatePtr_t state_;
88 
89  typedef std::list <RoadmapNodePtr_t> RoadmapNodes_t;
90  RoadmapNodes_t roadmapNodes_;
91 
92  std::ostream& printValue (std::ostream& os) const;
93  };
94 
95  class HPP_MANIPULATION_DLLLOCAL Histogram
96  {
97  public:
98  virtual ~Histogram () {};
99 
100  virtual void add (const RoadmapNodePtr_t& node) = 0;
101 
102  virtual HistogramPtr_t clone () const = 0;
103 
104  virtual void clear () = 0;
105  };
106 
114  class HPP_MANIPULATION_DLLAPI Foliation
115  {
116  public:
118  bool contains (ConfigurationIn_t q) const;
120  vector_t parameter (ConfigurationIn_t q) const;
121 
122  void condition (const ConstraintSetPtr_t c);
123  ConstraintSetPtr_t condition () const;
124  void parametrizer (const ConstraintSetPtr_t p);
125  ConstraintSetPtr_t parametrizer () const;
126 
127  private:
128  // condition_ contains the constraints defining the submanifold
129  // containing all the leaf.
130  // parametrizer_ contains the constraints providing a parametrization
131  // of the foliation.
132  ConstraintSetPtr_t condition_, parametrizer_;
133  };
134 
135  class HPP_MANIPULATION_DLLAPI LeafHistogram : public ::hpp::statistics::Statistics < LeafBin >
136  , public Histogram
137  {
138  public:
139  typedef ::hpp::statistics::Statistics < LeafBin > Parent;
140 
141  static LeafHistogramPtr_t create (const Foliation f);
142 
144  void add (const RoadmapNodePtr_t& n);
145 
146  std::ostream& print (std::ostream& os) const;
147 
148  virtual HistogramPtr_t clone () const;
149 
150  statistics::DiscreteDistribution < RoadmapNodePtr_t > getDistribOutOfConnectedComponent (
151  const core::ConnectedComponentPtr_t& cc) const;
152 
154 
155  void clear () { Parent::clear(); }
156 
157  const Foliation& foliation () const {
158  return f_;
159  }
160 
161  protected:
166  LeafHistogram (const Foliation f);
167 
168  private:
169  Foliation f_;
170 
172  value_type threshold_;
173  };
174 
175  class HPP_MANIPULATION_DLLLOCAL StateHistogram : public ::hpp::statistics::Statistics < NodeBin >
176  , public Histogram
177  {
178  public:
179  typedef ::hpp::statistics::Statistics < NodeBin > Parent;
183  StateHistogram (const graph::GraphPtr_t& graph);
184 
186  void add (const RoadmapNodePtr_t& n);
187 
188  std::ostream& print (std::ostream& os) const;
189 
190  const graph::GraphPtr_t& constraintGraph () const;
191 
192  virtual HistogramPtr_t clone () const;
193 
194  void clear () { Parent::clear(); }
195 
196  private:
198  graph::GraphPtr_t graph_;
199  };
201  typedef boost::shared_ptr <StateHistogram> NodeHistogramPtr_t;
202  } // namespace graph
203  } // namespace manipulation
204 } // namespace hpp
205 
206 #endif // HPP_MANIPULATION_GRAPH_STATISTICS_HH
StateHistogram NodeHistogram HPP_MANIPULATION_DEPRECATED
Definition: statistics.hh:200
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:112
Vec3f n
::hpp::statistics::Bin Parent
Definition: statistics.hh:39
void clear()
Definition: statistics.hh:155
Definition: statistics.hh:95
::hpp::statistics::Statistics< LeafBin > Parent
Definition: statistics.hh:139
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:38
core::vector_t vector_t
Definition: fwd.hh:82
::hpp::statistics::Statistics< NodeBin > Parent
Definition: statistics.hh:179
boost::shared_ptr< State > StatePtr_t
Definition: fwd.hh:36
core::value_type value_type
Definition: fwd.hh:79
Vec3f c
::hpp::statistics::Bin Parent
Definition: statistics.hh:73
boost::shared_ptr< Histogram > HistogramPtr_t
Definition: fwd.hh:58
const Foliation & foliation() const
Definition: statistics.hh:157
Definition: statistics.hh:70
boost::shared_ptr< ConnectedComponent > ConnectedComponentPtr_t
Definition: statistics.hh:114
void clear()
Definition: statistics.hh:194
Definition: statistics.hh:135
virtual ~Histogram()
Definition: statistics.hh:98
std::list< RoadmapNodePtr_t > RoadmapNodes_t
Definition: statistics.hh:40
static GradientBasedPtr_t create(const Problem &problem)
boost::shared_ptr< StateHistogram > NodeHistogramPtr_t
Definition: statistics.hh:201
Definition: statistics.hh:36
std::vector< RoadmapNodePtr_t > RoadmapNodes_t
Definition: fwd.hh:60
boost::shared_ptr< Graph > GraphPtr_t
Definition: fwd.hh:35
Definition: statistics.hh:175
boost::shared_ptr< LeafHistogram > LeafHistogramPtr_t
Definition: fwd.hh:61
Definition: roadmap-node.hh:32