MRPT  2.0.0
List of all members | Public Member Functions | Static Protected Member Functions | Private Attributes
mrpt::graphslam::TSlidingWindow Struct Reference

Detailed Description

Class to monitor the evolution of a statistical quantity.

Keeps track of the last N incoming measurements of the quantity at hand and upon request returns statistical properties of these measurements (mean, median, etc.)

Class also contains methods for evaluating incoming measurements (whether to accept or reject those)

The configuration parameters of the current decider class are listed below. These parameters are parsed from an external .ini configuration file from their respective section. If an optional parameter is not found a default value is used instead. If a mandatory/required parameter is not found a runtime error is raised. For a sample configuration file see $mrpt/share/mrpt/config_files/graphslam-engine/laser_odometry.ini (Modify $mrpt according to the path of your mrpt source directory).

Definition at line 42 of file TSlidingWindow.h.

#include <mrpt/graphslam/misc/TSlidingWindow.h>

Inheritance diagram for mrpt::graphslam::TSlidingWindow:

Public Member Functions

 TSlidingWindow (const std::string &name="window")
 
 ~TSlidingWindow () override=default
 
double getMedian ()
 Return the current median value. More...
 
double getMean ()
 Return the current mean value. More...
 
double getStdDev ()
 Return the Standard deviation of the current measurement vector. More...
 
bool evaluateMeasurementInGaussian (double measurement)
 Determine whether the incoming measurement is inside the [-3sigma, +3sigma] boundaries from the current mean value. More...
 
bool evaluateMeasurementAbove (double value)
 Determine whether the incoming measurement is over the current mean value. More...
 
bool evaluateMeasurementBelow (double value)
 Determine whether the incoming measurement is less or equal to the current mean value. More...
 
void addNewMeasurement (double measurement)
 Update the sliding window by appending a new measurement. More...
 
void resizeWindow (size_t new_size)
 Resize the window. More...
 
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. More...
 
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. More...
 
size_t getWindowSize () const
 Return the size of the window. More...
 
bool windowIsFull () const
 Check if the window has reached its limit. More...
 
void loadFromConfigFileName (const std::string &config_file, const std::string &section)
 Behaves like loadFromConfigFile, but you can pass directly a file name and a temporary CConfigFile object will be created automatically to load the file. More...
 
virtual void saveToConfigFile (mrpt::config::CConfigFileBase &target, const std::string &section) const
 This method saves the options to a ".ini"-like file or memory-stored string list. More...
 
void saveToConfigFileName (const std::string &config_file, const std::string &section) const
 Behaves like saveToConfigFile, but you can pass directly a file name and a temporary CConfigFile object will be created automatically to save the file. More...
 
void dumpToConsole () const
 Just like dumpToTextStream() but sending the text to the console (std::cout) More...
 

Static Protected Member Functions

static void dumpVar_int (std::ostream &out, const char *varName, int v)
 Used to print variable info from dumpToTextStream with the macro LOADABLEOPTS_DUMP_VAR. More...
 
static void dumpVar_float (std::ostream &out, const char *varName, float v)
 
static void dumpVar_double (std::ostream &out, const char *varName, double v)
 
static void dumpVar_bool (std::ostream &out, const char *varName, bool v)
 
static void dumpVar_string (std::ostream &out, const char *varName, const std::string &v)
 

Private Attributes

size_t m_win_size = 5
 
std::vector< double > m_measurements_vec
 
std::string m_name
 Name of the TSlidingWindow Instance at hand. More...
 
double m_mean_cached = 0.0f
 Cached mean value. More...
 
double m_median_cached = 0.0f
 Cached median value. More...
 
double m_std_dev_cached
 Cached version of the standard deviation. More...
 
bool m_mean_updated = false
 Is the mean up-to-date? More...
 
bool m_median_updated = false
 Is the median up-to-date? More...
 
bool m_std_dev_updated
 Is the standard deviation up-to-date? More...
 
bool m_is_initialized = false
 flag is raised the first time that TSlidingWindow::addNewMeasurement is called More...
 

Constructor & Destructor Documentation

◆ TSlidingWindow()

TSlidingWindow::TSlidingWindow ( const std::string &  name = "window")

Definition at line 22 of file TSlidingWindow.cpp.

◆ ~TSlidingWindow()

mrpt::graphslam::TSlidingWindow::~TSlidingWindow ( )
overridedefault

Member Function Documentation

◆ addNewMeasurement()

void TSlidingWindow::addNewMeasurement ( double  measurement)

Update the sliding window by appending a new measurement.

Definition at line 135 of file TSlidingWindow.cpp.

References m_is_initialized, m_mean_updated, m_measurements_vec, m_median_updated, m_std_dev_updated, m_win_size, MRPT_END, and MRPT_START.

◆ dumpToConsole()

void CLoadableOptions::dumpToConsole ( ) const
inherited

Just like dumpToTextStream() but sending the text to the console (std::cout)

Definition at line 43 of file CLoadableOptions.cpp.

References mrpt::config::CLoadableOptions::dumpToTextStream().

Referenced by mrpt::hmtslam::CTopLCDetector_GridMatching::computeTopologicalObservationModel(), mrpt::ros1bridge::MapHdl::loadMap(), mrpt::graphslam::deciders::CICPCriteriaNRD< GRAPH_T >::printParams(), and mrpt::apps::CGridMapAlignerApp::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dumpToTextStream()

void TSlidingWindow::dumpToTextStream ( std::ostream &  out) const
overridevirtual

This method should clearly display all the contents of the structure in textual form, sending it to a std::ostream.

The default implementation in this base class relies on saveToConfigFile() to generate a plain text representation of all the parameters.

Reimplemented from mrpt::config::CLoadableOptions.

Definition at line 191 of file TSlidingWindow.cpp.

References mrpt::format(), m_is_initialized, m_mean_cached, m_mean_updated, m_measurements_vec, m_median_cached, m_median_updated, m_name, m_std_dev_cached, m_std_dev_updated, m_win_size, MRPT_END, MRPT_START, and out.

Here is the call graph for this function:

◆ dumpVar_bool()

void CLoadableOptions::dumpVar_bool ( std::ostream &  out,
const char *  varName,
bool  v 
)
staticprotectedinherited

Definition at line 62 of file CLoadableOptions.cpp.

References mrpt::format(), LOADABLEOPTS_COLUMN_WIDTH, and out.

Here is the call graph for this function:

◆ dumpVar_double()

void CLoadableOptions::dumpVar_double ( std::ostream &  out,
const char *  varName,
double  v 
)
staticprotectedinherited

Definition at line 56 of file CLoadableOptions.cpp.

References mrpt::format(), LOADABLEOPTS_COLUMN_WIDTH, and out.

Here is the call graph for this function:

◆ dumpVar_float()

void CLoadableOptions::dumpVar_float ( std::ostream &  out,
const char *  varName,
float  v 
)
staticprotectedinherited

Definition at line 50 of file CLoadableOptions.cpp.

References mrpt::format(), LOADABLEOPTS_COLUMN_WIDTH, and out.

Here is the call graph for this function:

◆ dumpVar_int()

void CLoadableOptions::dumpVar_int ( std::ostream &  out,
const char *  varName,
int  v 
)
staticprotectedinherited

Used to print variable info from dumpToTextStream with the macro LOADABLEOPTS_DUMP_VAR.

Definition at line 44 of file CLoadableOptions.cpp.

References mrpt::format(), LOADABLEOPTS_COLUMN_WIDTH, and out.

Here is the call graph for this function:

◆ dumpVar_string()

void CLoadableOptions::dumpVar_string ( std::ostream &  out,
const char *  varName,
const std::string &  v 
)
staticprotectedinherited

Definition at line 69 of file CLoadableOptions.cpp.

References mrpt::format(), LOADABLEOPTS_COLUMN_WIDTH, and out.

Here is the call graph for this function:

◆ evaluateMeasurementAbove()

bool TSlidingWindow::evaluateMeasurementAbove ( double  value)

Determine whether the incoming measurement is over the current mean value.

Returns
True if it's above the mean

Definition at line 121 of file TSlidingWindow.cpp.

References getMean(), MRPT_END, and MRPT_START.

Referenced by evaluateMeasurementBelow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evaluateMeasurementBelow()

bool TSlidingWindow::evaluateMeasurementBelow ( double  value)

Determine whether the incoming measurement is less or equal to the current mean value.

Returns
True if it's <= to the mean

Definition at line 130 of file TSlidingWindow.cpp.

References evaluateMeasurementAbove().

Here is the call graph for this function:

◆ evaluateMeasurementInGaussian()

bool TSlidingWindow::evaluateMeasurementInGaussian ( double  measurement)

Determine whether the incoming measurement is inside the [-3sigma, +3sigma] boundaries from the current mean value.

Returns
True if it's inside the uncertainty boundaries

Definition at line 111 of file TSlidingWindow.cpp.

References getMean(), and getStdDev().

Here is the call graph for this function:

◆ getMean()

double TSlidingWindow::getMean ( )

Return the current mean value.

Definition at line 57 of file TSlidingWindow.cpp.

References m_mean_cached, m_mean_updated, m_measurements_vec, MRPT_END, and MRPT_START.

Referenced by evaluateMeasurementAbove(), evaluateMeasurementInGaussian(), and getStdDev().

Here is the caller graph for this function:

◆ getMedian()

double TSlidingWindow::getMedian ( )

Return the current median value.

Definition at line 27 of file TSlidingWindow.cpp.

References m_measurements_vec, m_median_cached, m_median_updated, MRPT_END, and MRPT_START.

◆ getStdDev()

double TSlidingWindow::getStdDev ( )

Return the Standard deviation of the current measurement vector.

Definition at line 81 of file TSlidingWindow.cpp.

References getMean(), m_measurements_vec, m_std_dev_cached, m_std_dev_updated, m_win_size, mrpt::math::mean(), MRPT_END, and MRPT_START.

Referenced by evaluateMeasurementInGaussian().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getWindowSize()

size_t TSlidingWindow::getWindowSize ( ) const

Return the size of the window.

Definition at line 222 of file TSlidingWindow.cpp.

References m_win_size.

◆ loadFromConfigFile()

void TSlidingWindow::loadFromConfigFile ( const mrpt::config::CConfigFileBase source,
const std::string &  section 
)
overridevirtual

This method load the options from a ".ini"-like file or memory-stored string list.

Only those parameters found in the given "section" and having the same name that the variable are loaded. Those not found in the file will stay with their previous values (usually the default values loaded at initialization). An example of an ".ini" file:

[section]
resolution = 0.10 // blah blah...
modeSelection = 1 // 0=blah, 1=blah,...
See also
loadFromConfigFileName, saveToConfigFile

Implements mrpt::config::CLoadableOptions.

Definition at line 180 of file TSlidingWindow.cpp.

References MRPT_END, MRPT_START, mrpt::config::CConfigFileBase::read_int(), and resizeWindow().

Here is the call graph for this function:

◆ loadFromConfigFileName()

void CLoadableOptions::loadFromConfigFileName ( const std::string &  config_file,
const std::string &  section 
)
inherited

Behaves like loadFromConfigFile, but you can pass directly a file name and a temporary CConfigFile object will be created automatically to load the file.

See also
loadFromConfigFile

Definition at line 22 of file CLoadableOptions.cpp.

References mrpt::config::CLoadableOptions::loadFromConfigFile().

Referenced by mrpt::graphslam::deciders::CICPCriteriaNRD< GRAPH_T >::loadParams().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resizeWindow()

void TSlidingWindow::resizeWindow ( size_t  new_size)

Resize the window.

Note
Method affects the underlying vector only if the new_size specified has already been reached

Definition at line 159 of file TSlidingWindow.cpp.

References m_mean_updated, m_measurements_vec, m_median_updated, m_win_size, MRPT_END, and MRPT_START.

Referenced by loadFromConfigFile().

Here is the caller graph for this function:

◆ saveToConfigFile()

void CLoadableOptions::saveToConfigFile ( mrpt::config::CConfigFileBase target,
const std::string &  section 
) const
virtualinherited

This method saves the options to a ".ini"-like file or memory-stored string list.

See also
loadFromConfigFile, saveToConfigFileName

Reimplemented in mrpt::vision::TMultiResDescOptions, mrpt::nav::CPTG_RobotShape_Circular, mrpt::vision::TMultiResDescMatchOptions, mrpt::nav::CPTG_RobotShape_Polygonal, mrpt::nav::CParameterizedTrajectoryGenerator, mrpt::maps::TSetOfMetricMapInitializers, mrpt::maps::COccupancyGridMap3D::TLikelihoodOptions, mrpt::nav::CAbstractNavigator::TAbstractNavigatorParams, mrpt::nav::CAbstractPTGBasedReactive::TAbstractPTGNavigatorParams, mrpt::maps::COccupancyGridMap3D::TInsertionOptions, mrpt::nav::CPTG_DiffDrive_CollisionGridBased, mrpt::nav::CWaypointsNavigator::TWaypointsNavigatorParams, mrpt::nav::CHolonomicFullEval::TOptions, mrpt::bayes::CParticleFilter::TParticleFilterOptions, mrpt::nav::CHolonomicND::TOptions, mrpt::nav::CReactiveNavigationSystem::TReactiveNavigatorParams, mrpt::maps::TMapGenericParams, mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase, mrpt::nav::CHolonomicVFF::TOptions, mrpt::slam::CICP::TConfigParams, mrpt::slam::CIncrementalMapPartitioner::TOptions, mrpt::maps::CPointCloudFilterByDistance::TOptions, mrpt::nav::CPTG_DiffDrive_C, mrpt::maps::TMetricMapInitializer, mrpt::nav::CPTG_DiffDrive_alpha, mrpt::nav::CMultiObjMotionOpt_Scalarization::TParams, mrpt::nav::CPTG_DiffDrive_CC, mrpt::nav::CPTG_DiffDrive_CCS, mrpt::nav::CPTG_DiffDrive_CS, and mrpt::nav::CPTG_Holo_Blend.

Definition at line 29 of file CLoadableOptions.cpp.

Referenced by mrpt::config::CLoadableOptions::dumpToTextStream(), and mrpt::config::CLoadableOptions::saveToConfigFileName().

Here is the caller graph for this function:

◆ saveToConfigFileName()

void CLoadableOptions::saveToConfigFileName ( const std::string &  config_file,
const std::string &  section 
) const
inherited

Behaves like saveToConfigFile, but you can pass directly a file name and a temporary CConfigFile object will be created automatically to save the file.

See also
saveToConfigFile, loadFromConfigFileName

Definition at line 36 of file CLoadableOptions.cpp.

References mrpt::config::CLoadableOptions::saveToConfigFile().

Here is the call graph for this function:

◆ windowIsFull()

bool TSlidingWindow::windowIsFull ( ) const

Check if the window has reached its limit.

This limit is set by the user via the resizeWindow method.

See also
resizeWindow

Definition at line 223 of file TSlidingWindow.cpp.

References m_measurements_vec, and m_win_size.

Member Data Documentation

◆ m_is_initialized

bool mrpt::graphslam::TSlidingWindow::m_is_initialized = false
private

flag is raised the first time that TSlidingWindow::addNewMeasurement is called

Definition at line 113 of file TSlidingWindow.h.

Referenced by addNewMeasurement(), and dumpToTextStream().

◆ m_mean_cached

double mrpt::graphslam::TSlidingWindow::m_mean_cached = 0.0f
private

Cached mean value.

Definition at line 101 of file TSlidingWindow.h.

Referenced by dumpToTextStream(), and getMean().

◆ m_mean_updated

bool mrpt::graphslam::TSlidingWindow::m_mean_updated = false
private

Is the mean up-to-date?

Definition at line 105 of file TSlidingWindow.h.

Referenced by addNewMeasurement(), dumpToTextStream(), getMean(), and resizeWindow().

◆ m_measurements_vec

std::vector<double> mrpt::graphslam::TSlidingWindow::m_measurements_vec
private

◆ m_median_cached

double mrpt::graphslam::TSlidingWindow::m_median_cached = 0.0f
private

Cached median value.

Definition at line 102 of file TSlidingWindow.h.

Referenced by dumpToTextStream(), and getMedian().

◆ m_median_updated

bool mrpt::graphslam::TSlidingWindow::m_median_updated = false
private

Is the median up-to-date?

Definition at line 106 of file TSlidingWindow.h.

Referenced by addNewMeasurement(), dumpToTextStream(), getMedian(), and resizeWindow().

◆ m_name

std::string mrpt::graphslam::TSlidingWindow::m_name
private

Name of the TSlidingWindow Instance at hand.

Definition at line 99 of file TSlidingWindow.h.

Referenced by dumpToTextStream().

◆ m_std_dev_cached

double mrpt::graphslam::TSlidingWindow::m_std_dev_cached
private
Initial value:
=
0.0f

Cached version of the standard deviation.

Definition at line 103 of file TSlidingWindow.h.

Referenced by dumpToTextStream(), and getStdDev().

◆ m_std_dev_updated

bool mrpt::graphslam::TSlidingWindow::m_std_dev_updated
private
Initial value:
=
false

Is the standard deviation up-to-date?

Definition at line 107 of file TSlidingWindow.h.

Referenced by addNewMeasurement(), dumpToTextStream(), and getStdDev().

◆ m_win_size

size_t mrpt::graphslam::TSlidingWindow::m_win_size = 5
private



Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020