MRPT  1.9.9
TSlidingWindow.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
13 
14 #include <string>
15 #include <vector>
16 
17 namespace mrpt::graphslam
18 {
19 /**\brief Class to monitor the evolution of a statistical quantity.
20  *
21  * ## Description
22  *
23  * Keeps track of the last N incoming measurements of the quantity at hand and
24  * upon request returns statistical properties of these measurements (mean,
25  * median, etc.)
26  *
27  * Class also contains methods for evaluating incoming measurements (whether to
28  * accept or reject those)
29  *
30  * ### .ini Configuration Parameters </b>
31  *
32  * \htmlinclude graphslam-engine_config_params_preamble.txt
33  *
34  * - \b sliding_win_size
35  * + \a Default value : 10
36  * + \a Required : FALSE
37  * + \a Description : How many of the latest measurements to take into
38  * account when computing the relevant statistics
39  *
40  * \ingroup mrpt_graphslam_grp
41  */
43 {
44  public:
45  TSlidingWindow(const std::string& name = "window");
46  ~TSlidingWindow() override = default;
47  /**\brief Return the current median value. */
48  double getMedian();
49  /**\brief Return the current mean value. */
50  double getMean();
51  /**\brief Return the Standard deviation of the current measurement vector*/
52  double getStdDev();
53  /**\brief Determine whether the incoming measurement is inside the
54  * [-3sigma, +3sigma] boundaries from the current mean value.
55  *
56  * \return True if it's inside the uncertainty boundaries
57  */
58  bool evaluateMeasurementInGaussian(double measurement);
59  /**\brief Determine whether the incoming measurement is over the current
60  * mean value.
61  *
62  * \return True if it's above the mean
63  */
64  bool evaluateMeasurementAbove(double value);
65  /**\brief Determine whether the incoming measurement is *less or equal* to
66  * the current mean value.
67  *
68  * \return True if it's <= to the mean
69  */
70  bool evaluateMeasurementBelow(double value);
71  /**\brief Update the sliding window by appending a new measurement */
72  void addNewMeasurement(double measurement);
73  /** Resize the window.
74  *
75  * \note Method affects the underlying vector only if the new_size
76  * specified has already been reached
77  */
78  void resizeWindow(size_t new_size);
79  void loadFromConfigFile(
80  const mrpt::config::CConfigFileBase& source,
81  const std::string& section) override;
82  void dumpToTextStream(std::ostream& out) const override;
83 
84  /**\brief Return the size of the window
85  */
86  size_t getWindowSize() const;
87  /**\brief Check if the window has reached its limit. This limit is set by
88  * the user via the resizeWindow method.
89  *
90  * \sa resizeWindow
91  */
92  bool windowIsFull() const;
93 
94  private:
95  size_t m_win_size = 5;
96  std::vector<double> m_measurements_vec;
97 
98  /**\brief Name of the TSlidingWindow Instance at hand */
99  std::string m_name;
100 
101  double m_mean_cached = 0.0f; /**< Cached mean value */
102  double m_median_cached = 0.0f; /**< Cached median value */
104  0.0f; /**< Cached version of the standard deviation */
105  bool m_mean_updated = false; /**< Is the mean up-to-date? */
106  bool m_median_updated = false; /**< Is the median up-to-date? */
108  false; /**< Is the standard deviation up-to-date? */
109 
110  /**\brief flag is raised the first time that
111  * TSlidingWindow::addNewMeasurement is called
112  */
113  bool m_is_initialized = false;
114 };
115 } // namespace mrpt::graphslam
void loadFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string &section) override
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.
void dumpToTextStream(std::ostream &out) const override
This method should clearly display all the contents of the structure in textual form, sending it to a std::ostream.
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.
bool m_median_updated
Is the median up-to-date?
mrpt::vision::TStereoCalibResults out
Class to monitor the evolution of a statistical quantity.
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.
~TSlidingWindow() override=default
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.
TSlidingWindow(const std::string &name="window")
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: d1962bc6a Wed Jan 15 17:38:30 2020 +0100 at miƩ ene 15 17:45:11 CET 2020