Go to the documentation of this file.
19 #include <gtest/gtest.h>
45 const string ini_fil =
49 cerr <<
"WARNING: Skipping test due to missing file: " << ini_fil
61 string iniSectionName(
"LocalizationExperiment");
65 iniSectionName,
"particles_count", std::vector<int>(1, 0),
69 iniSectionName,
"rawlog_file",
"",
true);
74 string MAP_FILE =
iniFile.read_string(iniSectionName,
"map_file",
"");
78 size_t rawlog_offset =
iniFile.read_int(iniSectionName,
"rawlog_offset", 0);
79 int NUM_REPS =
iniFile.read_int(iniSectionName,
"experimentRepetitions", 1);
102 size_t rawlogEntry, rawlogEntries;
123 if (!mapExt.compare(
"simplemap"))
133 else if (!mapExt.compare(
"gridmap"))
144 "Map file has unknown extension: '%s'", mapExt.c_str());
152 rawlogEntries = rawlog.
size();
155 itNum != particles_count.end(); ++itNum)
157 int PARTICLE_COUNT = *itNum;
160 vector<double> covergenceErrors;
161 covergenceErrors.reserve(NUM_REPS);
166 for (
int repetition = 0; repetition < NUM_REPS; repetition++)
168 int M = PARTICLE_COUNT;
172 pdf.
options = pdfPredictionOptions;
187 iniSectionName,
"init_PDF_mode",
false,
190 metricMap.
m_gridMaps[0].get(), 0.7f, PARTICLE_COUNT,
192 iniSectionName,
"init_PDF_min_x", 0,
true),
194 iniSectionName,
"init_PDF_max_x", 0,
true),
196 iniSectionName,
"init_PDF_min_y", 0,
true),
198 iniSectionName,
"init_PDF_max_y", 0,
true),
201 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),
217 iniSectionName,
"init_PDF_min_phi_deg", -180)),
220 iniSectionName,
"init_PDF_max_phi_deg", 180)),
232 while (rawlogEntry < (rawlogEntries - 1) && !
end)
237 action, observations, rawlogEntry))
246 if (step >= rawlog_offset)
251 if (step > rawlog_offset)
280 TEST(MonteCarlo2D, RunSampleDataset)
282 #if MRPT_IS_BIG_ENDIAN
283 MRPT_TODO(
"Debug this issue in big endian platforms")
297 for (
int op = 0; op < 3; op++)
301 const double final_pf_cov_trace =
cov.trace();
302 const CPose2D final_pf_pose = meanPose;
304 bool pass1 = (final_pf_pose - GT_endpose).
norm() < 0.10;
305 bool pass2 = final_pf_cov_trace < 0.01;
307 if (pass1 && pass2)
return;
310 cout <<
"\n*Warning: Test failed. Will give it another chance, since "
311 "after all it's nondeterministic!\n";
314 FAIL() <<
"Failed to converge after 3 opportunities!!" << endl;
This class stores a rawlog (robotic datasets) in one of two possible formats:
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.
void executeOn(CParticleFilterCapable &obj, const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, TParticleFilterStats *stats=nullptr)
Executes a complete prediction + update step of the selected particle filtering algorithm.
void run_test_pf_localization(CPose2D &meanPose, CMatrixDouble33 &cov)
std::shared_ptr< CSensoryFrame > Ptr
A high-performance stopwatch, with typical resolution of nanoseconds.
void loadFromProbabilisticPosesAndObservations(const mrpt::maps::CSimpleMap &Map)
Load the map contents from a CSimpleMap object, erasing all previous content of the map.
Statistics for being returned from the "execute" method.
CParticleFilter::TParticleFilterOptions m_options
The options to be used in the PF, must be set before executing any step of the particle filter.
This class acts as a common interface to the different interfaces (see CParticleFilter::TParticleFilt...
Declares a class that represents a Probability Density Function (PDF) over a 2D pose (x,...
ProxyFilterContainerByClass< mrpt::maps::COccupancyGridMap2D::Ptr, TListMaps > m_gridMaps
STL-like proxy to access this kind of maps in maps.
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define THROW_EXCEPTION(msg)
#define ASSERT_(f)
Defines an assertion mechanism.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
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 namespace contains representation of robot actions and observations.
std::string lowerCase(const std::string &str)
Returns an lower-case version of a string.
void randomize(const uint32_t seed)
Initialize the PRNG from the given random seed.
A set of TMetricMapInitializer structures, passed to the constructor CMultiMetricMap::CMultiMetricMap...
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...
CONTAINER::Scalar norm(const CONTAINER &v)
bool loadFromRawLogFile(const std::string &fileName, bool non_obs_objects_are_legal=false)
Load the contents from a file containing one of these possibilities:
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
This class stores any customizable set of metric maps.
size_t size() const
Returns the number of actions / observations object in the sequence.
void loadFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string §ion) override
This method load the options from a ".ini"-like file or memory-stored string list.
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.
string iniFile(myDataDir+string("benchmark-options.ini"))
void loadFromConfigFile(const mrpt::config::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.
size_t size() const
Returns the count of pairs (pose,sensory data)
std::string MRPT_GLOBAL_UNITTEST_SRC_DIR
void Tic() noexcept
Starts the stopwatch.
std::string extractFileExtension(const std::string &filePath, bool ignore_gz=false)
Extract the extension of a filename.
TEST(MonteCarlo2D, RunSampleDataset)
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream,...
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
TMonteCarloLocalizationParams options
MCL parameters.
The namespace for Bayesian filtering algorithm: different particle filters and Kalman filter algorith...
The struct for passing extra simulation parameters to the prediction stage when running a particle fi...
This class allows loading and storing values and vectors of different types from "....
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
This base provides a set of functions for maths stuff.
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.
GLsizei const GLchar ** string
void setListOfMaps(const mrpt::maps::TSetOfMetricMapInitializers *initializers)
Sets the list of internal map according to the passed list of map initializers (Current maps' content...
A namespace of pseudo-random numbers generators of diferent distributions.
mrpt::maps::CMetricMap * metricMap
[update stage] Must be set to a metric map used to estimate the likelihood of observations
void loadFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string §ion) override
This method load the options from a ".ini"-like file or memory-stored string list.
std::shared_ptr< CActionCollection > Ptr
The configuration of a particle filter.
TKLDParams KLD_params
Parameters for dynamic sample size, KLD method.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
double DEG2RAD(const double x)
Degrees to radians.
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 | |