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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST