19 #include <gtest/gtest.h> 49 const string ini_fil =
53 cerr <<
"WARNING: Skipping test due to missing file: " << ini_fil
64 string iniSectionName(
"LocalizationExperiment");
68 iniSectionName,
"particles_count",
vector_int(1, 0), particles_count,
71 iniSectionName,
"rawlog_file",
"",
true);
76 string MAP_FILE = iniFile.
read_string(iniSectionName,
"map_file",
"");
80 size_t rawlog_offset = iniFile.
read_int(iniSectionName,
"rawlog_offset", 0);
81 int NUM_REPS = iniFile.
read_int(iniSectionName,
"experimentRepetitions", 1);
104 size_t rawlogEntry, rawlogEntries;
124 if (!mapExt.compare(
"simplemap"))
136 else if (!mapExt.compare(
"gridmap"))
146 "Map file has unknown extension: '%s'", mapExt.c_str());
154 rawlogEntries = rawlog.
size();
157 itNum != particles_count.end(); ++itNum)
159 int PARTICLE_COUNT = *itNum;
162 vector<double> covergenceErrors;
163 covergenceErrors.reserve(NUM_REPS);
168 for (
int repetition = 0; repetition < NUM_REPS; repetition++)
170 int M = PARTICLE_COUNT;
174 pdf.
options = pdfPredictionOptions;
189 iniSectionName,
"init_PDF_mode",
false,
192 metricMap.
m_gridMaps[0].get(), 0.7f, PARTICLE_COUNT,
194 iniSectionName,
"init_PDF_min_x", 0,
true),
196 iniSectionName,
"init_PDF_max_x", 0,
true),
198 iniSectionName,
"init_PDF_min_y", 0,
true),
200 iniSectionName,
"init_PDF_max_y", 0,
true),
202 iniSectionName,
"init_PDF_min_phi_deg", -180)),
204 iniSectionName,
"init_PDF_max_phi_deg", 180)));
208 iniSectionName,
"init_PDF_min_x", 0,
true),
210 iniSectionName,
"init_PDF_max_x", 0,
true),
212 iniSectionName,
"init_PDF_min_y", 0,
true),
214 iniSectionName,
"init_PDF_max_y", 0,
true),
216 iniSectionName,
"init_PDF_min_phi_deg", -180)),
218 iniSectionName,
"init_PDF_max_phi_deg", 180)),
230 while (rawlogEntry < (rawlogEntries - 1) && !
end)
235 action, observations, rawlogEntry))
244 if (step >= rawlog_offset)
249 if (step > rawlog_offset)
279 TEST(MonteCarlo2D, RunSampleDataset)
281 #if MRPT_IS_BIG_ENDIAN 282 MRPT_TODO(
"Debug this issue in big endian platforms")
296 for (
int op = 0; op < 3; op++)
300 const double final_pf_cov_trace =
cov.trace();
301 const CPose2D final_pf_pose = meanPose;
303 bool pass1 = (final_pf_pose - GT_endpose).
norm() < 0.10;
304 bool pass2 = final_pf_cov_trace < 0.01;
306 if (pass1 && pass2)
return;
309 cout <<
"\n*Warning: Test failed. Will give it another chance, since " 310 "after all it's nondeterministic!\n";
313 FAIL() <<
"Failed to converge after 3 opportunities!!" << endl;
A namespace of pseudo-random numbers genrators of diferent distributions.
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string §ion) override
This method load the options from a ".ini"-like file or memory-stored string list.
bool read_bool(const std::string §ion, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
std::string MRPT_GLOBAL_UNITTEST_SRC_DIR
The struct for passing extra simulation parameters to the prediction stage when running a particle fi...
bool getActionObservationPair(CActionCollection::Ptr &action, CSensoryFrame::Ptr &observations, size_t &rawlogEntry) const
Gets the next consecutive pair action / observation from the rawlog loaded into this object...
void loadFromProbabilisticPosesAndObservations(const mrpt::maps::CSimpleMap &Map)
Load the map contents from a CSimpleMap object, erasing all previous content of the map...
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
float read_float(const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
TEST(MonteCarlo2D, RunSampleDataset)
The namespace for Bayesian filtering algorithm: different particle filters and Kalman filter algorith...
This class allows loading and storing values and vectors of different types from ".ini" files easily.
#define THROW_EXCEPTION(msg)
void randomize(const uint32_t seed)
Initialize the PRNG from the given random seed.
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov, CPose2D &mean_point) const override
Returns an estimate of the pose covariance matrix (3x3 cov matrix) and the mean, both at once...
std::string read_string(const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
TMonteCarloLocalizationParams options
MCL parameters.
Statistics for being returned from the "execute" method.
void Tic()
Starts the stopwatch.
A set of TMetricMapInitializer structures, passed to the constructor CMultiMetricMap::CMultiMetricMap...
mrpt::maps::CMetricMap * metricMap
[update stage] Must be set to a metric map used to estimate the likelihood of observations ...
void run_test_pf_localization(CPose2D &meanPose, CMatrixDouble33 &cov)
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
void resetUniformFreeSpace(mrpt::maps::COccupancyGridMap2D *theMap, const double freeCellsThreshold=0.7, const int particlesCount=-1, const double x_min=-1e10f, const double x_max=1e10f, const double y_min=-1e10f, const double y_max=1e10f, const double phi_min=-M_PI, const double phi_max=M_PI)
Reset the PDF to an uniformly distributed one, but only in the free-space of a given 2D occupancy-gri...
bool loadFromRawLogFile(const std::string &fileName, bool non_obs_objects_are_legal=false)
Load the contents from a file containing one of these possibilities:
This base provides a set of functions for maths stuff.
std::string lowerCase(const std::string &str)
Returns an lower-case version of a string.
void read_vector(const std::string §ion, const std::string &name, const VECTOR_TYPE &defaultValue, VECTOR_TYPE &outValues, bool failIfNotFound=false) const
Reads a configuration parameter of type vector, stored in the file as a string: "[v1 v2 v3 ...
This class implements a high-performance stopwatch.
This class stores a rawlog (robotic datasets) in one of two possible formats:
This namespace contains representation of robot actions and observations.
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string §ion) override
This method load the options from a ".ini"-like file or memory-stored string list.
void resetUniform(const double &x_min, const double &x_max, const double &y_min, const double &y_max, const double &phi_min=-M_PI, const double &phi_max=M_PI, const int &particlesCount=-1)
Reset the PDF to an uniformly distributed one, inside of the defined cube.
std::shared_ptr< CSensoryFrame > Ptr
ProxyFilterContainerByClass< mrpt::maps::COccupancyGridMap2D::Ptr, TListMaps > m_gridMaps
STL-like proxy to access this kind of maps in maps.
std::string extractFileExtension(const std::string &filePath, bool ignore_gz=false)
Extract the extension of a filename.
size_t size() const
Returns the count of pairs (pose,sensory data)
This class acts as a common interface to the different interfaces (see CParticleFilter::TParticleFilt...
GLsizei const GLchar ** string
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
mrpt::poses::CPosePDFParticles m_poseParticles
Declares a class that represents a Probability Density Function (PDF) over a 2D pose (x...
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string §ionName) override
Loads the configuration for the set of internal maps from a textual definition in an INI-like file...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::shared_ptr< CActionCollection > Ptr
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
void setListOfMaps(const mrpt::maps::TSetOfMetricMapInitializers *initializers)
Sets the list of internal map according to the passed list of map initializers (Current maps' content...
The configuration of a particle filter.
std::vector< int32_t > vector_int
Eigen::Matrix< typename MATRIX::Scalar, MATRIX::ColsAtCompileTime, MATRIX::ColsAtCompileTime > cov(const MATRIX &v)
Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample...
This class stores any customizable set of metric maps.
CParticleFilter::TParticleFilterOptions m_options
The options to be used in the PF, must be set before executing any step of the particle filter...
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
size_t size() const
Returns the number of actions / observations object in the sequence.
TParticleFilterAlgorithm PF_algorithm
The PF algorithm to use (default=pfStandardProposal) See TParticleFilterAlgorithm for the posibilitie...
void executeOn(mrpt::bayes::CParticleFilter &pf, const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, mrpt::bayes::CParticleFilter::TParticleFilterStats *stats, mrpt::bayes::CParticleFilter::TParticleFilterAlgorithm PF_algorithm)
TKLDParams KLD_params
Parameters for dynamic sample size, KLD method.
CONTAINER::Scalar norm(const CONTAINER &v)