MRPT  1.9.9
TSlidingWindow.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #ifndef TSLIDINGWINDOW_H
11 #define TSLIDINGWINDOW_H
12 
14 
15 #include <string>
16 #include <vector>
17 
18 namespace mrpt::graphslam
19 {
20 /**\brief Class to monitor the evolution of a statistical quantity.
21  *
22  * ## Description
23  *
24  * Keeps track of the last N incoming measurements of the quantity at hand and
25  * upon request returns statistical properties of these measurements (mean,
26  * median, etc.)
27  *
28  * Class also contains methods for evaluating incoming measurements (whether to
29  * accept or reject those)
30  *
31  * ### .ini Configuration Parameters </b>
32  *
33  * \htmlinclude graphslam-engine_config_params_preamble.txt
34  *
35  * - \b sliding_win_size
36  * + \a Default value : 10
37  * + \a Required : FALSE
38  * + \a Description : How many of the latest measurements to take into
39  * account when computing the relevant statistics
40  *
41  * \ingroup mrpt_graphslam_grp
42  */
44 {
45  public:
46  TSlidingWindow(std::string name = "window");
48  /**\brief Return the current median value. */
49  double getMedian();
50  /**\brief Return the current mean value. */
51  double getMean();
52  /**\brief Return the Standard deviation of the current measurement vector*/
53  double getStdDev();
54  /**\brief Determine whether the incoming measurement is inside the
55  * [-3sigma, +3sigma] boundaries from the current mean value.
56  *
57  * \return True if it's inside the uncertainty boundaries
58  */
59  bool evaluateMeasurementInGaussian(double measurement);
60  /**\brief Determine whether the incoming measurement is over the current
61  * mean value.
62  *
63  * \return True if it's above the mean
64  */
65  bool evaluateMeasurementAbove(double value);
66  /**\brief Determine whether the incoming measurement is *less or equal* to
67  * the current mean value.
68  *
69  * \return True if it's <= to the mean
70  */
71  bool evaluateMeasurementBelow(double value);
72  /**\brief Update the sliding window by appending a new measurement */
73  void addNewMeasurement(double measurement);
74  /** Resize the window.
75  *
76  * \note Method affects the underlying vector only if the new_size
77  * specified has already been reached
78  */
79  void resizeWindow(size_t new_size);
80  void loadFromConfigFile(
82  const std::string& section);
83  // TODO - make it use the boundaries
84  void dumpToTextStream(std::ostream& out) const;
85 
86  /**\brief Return the size of the window
87  */
88  size_t getWindowSize() const;
89  /**\brief Check if the window has reached its limit. This limit is set by
90  * the user via the resizeWindow method.
91  *
92  * \sa resizeWindow
93  */
94  bool windowIsFull() const;
95 
96  private:
97  size_t m_win_size;
98  std::vector<double> m_measurements_vec;
99 
100  /**\brief Name of the TSlidingWindow Instance at hand */
102 
103  double m_mean_cached; /**< Cached mean value */
104  double m_median_cached; /**< Cached median value */
105  double m_std_dev_cached; /**< Cached version of the standard deviation */
106  bool m_mean_updated; /**< Is the mean up-to-date? */
107  bool m_median_updated; /**< Is the median up-to-date? */
108  bool m_std_dev_updated; /**< Is the standard deviation up-to-date? */
109 
110  /**\brief flag is raised the first time that
111  * TSlidingWindow::addNewMeasurement is
112  * called
113  */
115 };
116 }
117 #endif /* end of include guard: TSLIDINGWINDOW_H */
118 
119 
void loadFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string &section)
This method load the options from a ".ini"-like file or memory-stored string list.
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
void resizeWindow(size_t new_size)
Resize the window.
std::vector< double > m_measurements_vec
bool evaluateMeasurementInGaussian(double measurement)
Determine whether the incoming measurement is inside the [-3sigma, +3sigma] boundaries from the curre...
bool evaluateMeasurementAbove(double value)
Determine whether the incoming measurement is over the current mean value.
void addNewMeasurement(double measurement)
Update the sliding window by appending a new measurement.
bool m_is_initialized
flag is raised the first time that TSlidingWindow::addNewMeasurement is called
SLAM methods related to graphs of pose constraints.
This class allows loading and storing values and vectors of different types from a configuration text...
double getStdDev()
Return the Standard deviation of the current measurement vector.
double m_mean_cached
Cached mean value.
double getMean()
Return the current mean value.
double m_std_dev_cached
Cached version of the standard deviation.
GLsizei const GLchar ** string
Definition: glext.h:4101
bool m_median_updated
Is the median up-to-date?
TSlidingWindow(std::string name="window")
Class to monitor the evolution of a statistical quantity.
GLuint const GLchar * name
Definition: glext.h:4054
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
std::string m_name
Name of the TSlidingWindow Instance at hand.
bool evaluateMeasurementBelow(double value)
Determine whether the incoming measurement is less or equal to the current mean value.
void dumpToTextStream(std::ostream &out) const
This method should clearly display all the contents of the structure in textual form, sending it to a std::ostream.
GLsizei const GLfloat * value
Definition: glext.h:4117
size_t getWindowSize() const
Return the size of the window.
bool m_mean_updated
Is the mean up-to-date?
bool windowIsFull() const
Check if the window has reached its limit.
double m_median_cached
Cached median value.
double getMedian()
Return the current median value.
bool m_std_dev_updated
Is the standard deviation up-to-date?



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020