49 #include <Eigen/Dense> 67 " pf-localization - Part of the MRPT\n" 68 " MRPT C++ Library: %s - Sources timestamp: %s\n\n",
79 const std::string configFile = std::string(
argv[1]);
117 static constexpr
bool PF_IS_3D =
false;
126 PARTICLE_COUNT, init_min.
x, init_max.
x, init_min.
y, init_max.
y,
127 init_min.
yaw, init_max.
yaw);
136 init_min.
x, init_max.
x, init_min.
y, init_max.
y, init_min.
yaw,
137 init_max.
yaw, PARTICLE_COUNT);
144 static constexpr
bool PF_IS_3D =
true;
163 template <
class MONTECARLO_TYPE>
169 std::vector<int> particles_count;
175 sect,
"particles_count", std::vector<int>(1, 0), particles_count,
177 string OUT_DIR_PREFIX =
178 cfg.read_string(
sect,
"logOutput_dir",
"",
true);
181 string MAP_FILE = cfg.read_string(
sect,
"map_file",
"");
182 size_t rawlog_offset = cfg.read_int(
sect,
"rawlog_offset", 0);
183 string GT_FILE = cfg.read_string(
sect,
"ground_truth_path_file",
"");
184 const auto NUM_REPS = cfg.read_uint64_t(
sect,
"experimentRepetitions", 1);
185 int SCENE3D_FREQ = cfg.read_int(
sect,
"3DSceneFrequency", 10);
186 bool SCENE3D_FOLLOW = cfg.read_bool(
sect,
"3DSceneFollowRobot",
true);
187 unsigned int testConvergenceAt =
188 cfg.read_int(
sect,
"experimentTestConvergenceAtStep", -1);
190 bool SAVE_STATS_ONLY = cfg.read_bool(
sect,
"SAVE_STATS_ONLY",
false);
191 bool DO_RELIABILITY_ESTIMATE =
false;
192 bool DO_SCAN_LIKELIHOOD_DEBUG =
false;
196 bool SHOW_PROGRESS_3D_REAL_TIME =
197 cfg.read_bool(
sect,
"SHOW_PROGRESS_3D_REAL_TIME",
false);
198 int SHOW_PROGRESS_3D_REAL_TIME_DELAY_MS =
199 cfg.read_int(
sect,
"SHOW_PROGRESS_3D_REAL_TIME_DELAY_MS", 1);
200 double STATS_CONF_INTERVAL =
201 cfg.read_double(
sect,
"STATS_CONF_INTERVAL", 0.2);
204 initial_odo.
x(cfg.read_double(
sect,
"initial_odo_x", 0));
205 initial_odo.
y(cfg.read_double(
sect,
"initial_odo_y", 0));
206 initial_odo.
phi(cfg.read_double(
sect,
"initial_odo_phi", 0));
208 #if !MRPT_HAS_WXWIDGETS 209 SHOW_PROGRESS_3D_REAL_TIME =
false;
216 actOdom2D_params.
modelSelection = CActionRobotMovement2D::mmGaussian;
218 cfg.read_double(
"DummyOdometryParams",
"minStdXY", 0.04);
220 DEG2RAD(cfg.read_double(
"DummyOdometryParams",
"minStdPHI", 2.0));
224 cfg.read_double(
"DummyOdometryParams",
"additional_std_XYZ", 0.01);
225 actOdom3D_params.mm6DOFModel.additional_std_angle =
DEG2RAD(
226 cfg.read_double(
"DummyOdometryParams",
"additional_std_angle", 0.1));
245 <<
"MAP_FILE : " << MAP_FILE << endl
246 <<
"GT_FILE : " << GT_FILE << endl
247 <<
"OUT_DIR_PREFIX : " << OUT_DIR_PREFIX << endl
248 <<
"particles_count :" << particles_count << endl);
262 std::stringstream ss;
263 pfOptions.dumpToTextStream(ss);
282 if (!mapExt.compare(
"simplemap"))
292 "Map loaded ok, with " << simpleMap.
size() <<
" frames.");
298 MRPT_LOG_INFO(
"Building metric map(s) from '.simplemap'...");
302 else if (!mapExt.compare(
"gridmap"))
318 "Map file has unknown extension: '%s'", mapExt.c_str());
337 cfg.read_double(
sect,
"init_PDF_min_x", 0),
338 cfg.read_double(
sect,
"init_PDF_min_y", 0),
339 cfg.read_double(
sect,
"init_PDF_min_z", 0),
345 cfg.read_double(
sect,
"init_PDF_max_x", 0),
346 cfg.read_double(
sect,
"init_PDF_max_y", 0),
347 cfg.read_double(
sect,
"init_PDF_max_z", 0),
353 "Initial PDF limits:\n Min=" << init_min.asString()
354 <<
"\n Max=" << init_max.asString());
360 grid->computeEntropy(gridInfo);
362 "The gridmap has %.04fm2 observed area, %u observed cells.",
363 gridInfo.effectiveMappedArea,
364 (
unsigned)gridInfo.effectiveMappedCells);
368 gridInfo.effectiveMappedArea =
369 (init_max.x - init_min.x) * (init_max.y - init_min.y);
372 for (
int PARTICLE_COUNT : particles_count)
375 "Initial PDF: %f particles/m2",
376 PARTICLE_COUNT / gridInfo.effectiveMappedArea);
379 int nConvergenceTests = 0, nConvergenceOK = 0;
381 std::mutex convergenceErrors_mtx;
388 std::vector<unsigned int> rep_indices(NUM_REPS);
389 std::iota(rep_indices.begin(), rep_indices.end(), 0);
397 auto run_localization_code = [&](
const size_t repetition) {
398 CVectorDouble indivConvergenceErrors, executionTimes, odoError;
400 "====== RUNNING FOR " << PARTICLE_COUNT
401 <<
" INITIAL PARTICLES - Repetition " 402 << 1 + repetition <<
" / " << NUM_REPS);
406 if (SHOW_PROGRESS_3D_REAL_TIME)
408 win3D = std::make_shared<CDisplayWindow3D>(
409 "pf-localization - The MRPT project", 1000, 600);
410 win3D->setCameraAzimuthDeg(-45);
416 if (SCENE3D_FREQ > 0 || SHOW_PROGRESS_3D_REAL_TIME)
421 pts->boundingBox(bbox_min, bbox_max);
425 bbox_min.
x, bbox_max.x, bbox_min.
y, bbox_max.y, 0, 5));
428 win3D->setCameraZoom(
431 bbox_max.x - bbox_min.
x, bbox_max.y - bbox_min.
y));
439 string sOUT_DIR_PARTS, sOUT_DIR_3D;
440 const auto sOUT_DIR =
format(
441 "%s_%03u_%07i", OUT_DIR_PREFIX.c_str(), repetition,
448 if (!SAVE_STATS_ONLY)
450 sOUT_DIR_PARTS =
format(
"%s/particles", sOUT_DIR.c_str());
451 sOUT_DIR_3D =
format(
"%s/3D", sOUT_DIR.c_str());
454 "Creating directory: %s", sOUT_DIR_PARTS.c_str());
460 "Creating directory: %s", sOUT_DIR_3D.c_str());
469 int M = PARTICLE_COUNT;
474 pdf.options = pdfPredictionOptions;
483 size_t rawlogEntry = 0;
489 sect,
"init_PDF_mode",
false,
494 pdf, metricMap, PARTICLE_COUNT, init_min, init_max);
500 pdf, PARTICLE_COUNT, init_min, init_max);
504 "PDF of %u particles initialized in %.03fms", M,
505 1000 * tictac.
Tac());
508 format(
"%s/particles_0_initial.txt", sOUT_DIR_PARTS.c_str()));
513 CPose2D odometryEstimation = initial_odo;
515 using PDF_MEAN_TYPE =
typename MONTECARLO_TYPE::type_value;
517 PDF_MEAN_TYPE pdfEstimation;
524 if (!SAVE_STATS_ONLY)
526 f_cov_est.
open(sOUT_DIR.c_str() + string(
"/cov_est.txt"));
527 f_pf_stats.
open(sOUT_DIR.c_str() + string(
"/PF_stats.txt"));
528 f_odo_est.
open(sOUT_DIR.c_str() + string(
"/odo_est.txt"));
532 CPose2D last_used_abs_odo(0, 0, 0),
533 pending_most_recent_odo(0, 0, 0);
538 if (allow_quit_on_esc_key &&
os::kbhit())
551 if (!impl_get_next_observations(action, observations, obs))
576 pending_most_recent_odo = obs_odo->odometry;
577 static bool is_1st_odo =
true;
581 last_used_abs_odo = pending_most_recent_odo;
589 observations = std::make_shared<CSensoryFrame>();
590 observations->insert(obs);
595 action = std::make_shared<CActionCollection>();
602 pending_most_recent_odo - last_used_abs_odo);
603 last_used_abs_odo = pending_most_recent_odo;
606 odo_incr, actOdom3D_params);
607 action->insert(actOdom3D);
614 pending_most_recent_odo - last_used_abs_odo;
615 last_used_abs_odo = pending_most_recent_odo;
618 odo_incr, actOdom2D_params);
619 action->insert(actOdom2D);
630 if (observations->size() > 0)
632 observations->getObservationByIndex(0)->timestamp;
634 cur_obs_timestamp = obs->timestamp;
636 if (step >= rawlog_offset)
640 if (step > rawlog_offset)
643 if (SHOW_PROGRESS_3D_REAL_TIME)
645 const auto [
cov, meanPose] =
646 pdf.getCovarianceAndMean();
648 if (rawlogEntry >= 2)
650 expectedPose, rawlogEntry - 2, GT,
661 auto el = CEllipsoid3D::Create();
667 el->enableDrawSolid3D(
false);
671 auto el = CEllipsoid2D::Create();
677 el->enableDrawSolid3D(
false);
679 ellip->setName(
"parts_cov");
680 ellip->setColor(1, 0, 0, 0.6);
690 cov.template blockCopy<3, 3>());
697 cov.template blockCopy<2, 2>());
704 meanPose.x(), meanPose.y(), ellipse_z);
708 win3D->get3DSceneAndLock();
710 win3D->setCameraPointingToPoint(
711 meanPose.x(), meanPose.y(), 0);
713 win3D->addTextMessage(
722 win3D->addTextMessage(
726 static_cast<unsigned int>(pdf.size())),
729 win3D->addTextMessage(
732 "mean pose (x y phi_deg)= %s",
733 meanPose.asString().c_str()),
736 *ptrSceneWin = scene;
737 win3D->unlockAccess3DScene();
740 win3D->forceRepaint();
742 std::this_thread::sleep_for(
743 std::chrono::milliseconds(
744 SHOW_PROGRESS_3D_REAL_TIME_DELAY_MS));
751 if (!SAVE_STATS_ONLY)
755 << step <<
". Executing ParticleFilter on " 756 << pdf.particlesCount() <<
" particles...");
766 double run_time = tictac.
Tac();
768 if (!SAVE_STATS_ONLY)
771 "Done in %.03fms, ESS=%f", 1e3 * run_time,
779 action->getBestMovementEstimation();
784 best_mov_estim->poseChange->getMeanVal();
787 pdf.getMean(pdfEstimation);
791 fill_out_estimated_path)
793 out_estimated_path.insert(
799 expectedPose, rawlogEntry, GT, cur_obs_timestamp);
801 if (expectedPose.
x() != 0 || expectedPose.
y() != 0 ||
802 expectedPose.
phi() != 0)
806 for (
size_t k = 0; k < pdf.size(); k++)
807 sumW += exp(pdf.getW(k));
808 for (
size_t k = 0; k < pdf.size(); k++)
810 const auto pk = pdf.getParticlePose(k);
812 expectedPose.
x() - pk.x,
813 expectedPose.
y() - pk.y) *
814 exp(pdf.getW(k)) / sumW;
816 convergenceErrors_mtx.lock();
818 convergenceErrors_mtx.unlock();
820 indivConvergenceErrors.
push_back(locErr);
825 const auto [C, M] = pdf.getCovarianceAndMean();
826 const auto current_pdf_gaussian =
831 if (!SAVE_STATS_ONLY)
834 "Odometry estimation: " << odometryEstimation);
837 << pdfEstimation <<
", ESS (B.R.)= " 839 << std::sqrt(current_pdf_gaussian.cov.trace()));
843 "Ground truth: " << expectedPose);
848 double obs_reliability_estim = .0;
849 if (DO_RELIABILITY_ESTIMATE)
854 obs_scan = observations->getObservationByClass<
861 if (obs_scan && gridmap)
869 COccupancyGridMap2D::sumUnscented;
876 ssu_params.
aperture = obs_scan->aperture;
878 ssu_params.
nRays = obs_scan->getScanSize();
881 ssu_params.
maxRange = obs_scan->maxRange;
883 gridmap->laserScanSimulatorWithUncertainty(
884 ssu_params, ssu_out);
891 obs_reliability_estim =
893 *obs_scan, evalParams);
895 if (DO_SCAN_LIKELIHOOD_DEBUG)
899 std::vector<float> ranges_mean, ranges_obs;
900 for (
size_t i = 0; i < obs_scan->getScanSize();
903 ranges_mean.push_back(
906 ranges_obs.push_back(
907 obs_scan->getScanRange(i));
910 win.plot(ranges_mean,
"3k-",
"mean");
911 win.plot(ranges_obs,
"r-",
"obs");
913 Eigen::VectorXd ci1 =
922 Eigen::VectorXd ci2 =
931 win.plot(ci1,
"k-",
"CI+");
932 win.plot(ci2,
"k-",
"CI-");
935 "obs_reliability_estim: %f",
936 obs_reliability_estim));
941 "Reliability measure [0-1]: " 942 << obs_reliability_estim);
945 if (!SAVE_STATS_ONLY)
949 "%u %e %e %f %f\n", (
unsigned int)pdf.size(),
952 obs_reliability_estim,
953 sqrt(current_pdf_gaussian.cov.det()));
955 "%f %f %f\n", odometryEstimation.
x(),
956 odometryEstimation.
y(), odometryEstimation.
phi());
959 const auto [
cov, meanPose] = pdf.getCovarianceAndMean();
961 if ((!SAVE_STATS_ONLY && SCENE3D_FREQ > 0) ||
962 SHOW_PROGRESS_3D_REAL_TIME)
973 GTpt = std::make_shared<CDisk>();
974 GTpt = std::make_shared<CDisk>();
976 GTpt->setColor(0, 0, 0, 0.9);
979 ->setDiskRadius(0.04f);
983 GTpt->setPose(expectedPose);
992 auto p = pdf.template getAs3DObject<
994 p->setName(
"particles");
1004 scanPts = std::make_shared<CPointCloud>();
1005 scanPts->setName(
"scan");
1006 scanPts->setColor(1, 0, 0, 0.9);
1008 ->enableColorFromZ(
false);
1016 CPose3D robotPose3D(meanPose);
1019 observations->insertObservationsInto(&map);
1022 ->loadFromPointsMap(&map);
1033 CCamera& cam = view1->getCamera();
1042 if (!SAVE_STATS_ONLY && SCENE3D_FREQ != -1 &&
1043 ((step + 1) % SCENE3D_FREQ) == 0)
1047 "%s/progress_%05u.3Dscene", sOUT_DIR_3D.c_str(),
1053 pdf.saveToTextFile(
format(
1054 "%s/particles_%05u.txt", sOUT_DIR_PARTS.c_str(),
1063 if (step == testConvergenceAt)
1065 nConvergenceTests++;
1070 if (pdfEstimation.distanceTo(expectedPose) < 2)
1077 indivConvergenceErrors.
saveToTextFile(sOUT_DIR +
"/GT_error.txt");
1087 const auto max_num_threads = std::thread::hardware_concurrency();
1088 size_t runs_per_thread = NUM_REPS;
1089 if (max_num_threads > 1)
1090 runs_per_thread =
static_cast<size_t>(
1091 std::ceil((NUM_REPS) / static_cast<double>(max_num_threads)));
1094 "Running " << NUM_REPS <<
" repetitions, on max " << max_num_threads
1095 <<
" parallel threads: " << runs_per_thread
1096 <<
" runs/thread.");
1098 std::vector<std::thread> running_tasks;
1099 for (
size_t r = 0; r < NUM_REPS; r += runs_per_thread)
1101 auto runner = [&](
size_t i_start,
size_t i_end) {
1102 if (i_end > NUM_REPS) i_end = NUM_REPS;
1103 for (
size_t i = i_start; i < i_end; i++)
1104 run_localization_code(i);
1107 running_tasks.emplace_back(runner, r, r + runs_per_thread);
1108 std::this_thread::sleep_for(std::chrono::milliseconds(100));
1112 for (
auto& t : running_tasks)
1113 if (t.joinable()) t.join();
1115 double repetitionTime = tictacGlobal.
Tac();
1118 double covergenceErrorMean = 0, convergenceErrorsMin = 0,
1119 convergenceErrorsMax = 0;
1120 if (!convergenceErrors.
empty())
1122 convergenceErrors, covergenceErrorMean, convergenceErrorsMin,
1123 convergenceErrorsMax, STATS_CONF_INTERVAL);
1128 format(
"%s_SUMMARY.txt", OUT_DIR_PREFIX.c_str()),
1132 "%% Ratio_covergence_success #particles " 1133 "average_time_per_execution convergence_mean_error " 1134 "convergence_error_conf_int_inf " 1135 "convergence_error_conf_int_sup " 1137 if (!nConvergenceTests) nConvergenceTests = 1;
1139 "%f %u %f %f %f %f\n",
1140 ((
double)nConvergenceOK) / nConvergenceTests, PARTICLE_COUNT,
1141 repetitionTime / NUM_REPS, covergenceErrorMean,
1142 convergenceErrorsMin, convergenceErrorsMax);
1159 if (GT.
cols() == 4 || GT.
cols() == 7)
1161 bool GT_index_is_time;
1168 floor(GT(0, 0)) != GT(0, 0) && floor(GT(1, 0)) != GT(1, 0);
1172 GT_index_is_time =
false;
1175 if (GT_index_is_time)
1178 using namespace std::chrono_literals;
1180 bool interp_ok =
false;
1181 GT_path.interpolate(cur_time, expectedPose, interp_ok);
1194 size_t k, N = GT.
rows();
1195 for (k = 0; k < N; k++)
1197 if (GT(k, 0) == rawlogEntry)
break;
1202 expectedPose.
x(GT(k, 1));
1203 expectedPose.
y(GT(k, 2));
1204 expectedPose.
phi(GT(k, 3));
1208 else if (GT.
cols() == 3)
1210 if ((
int)rawlogEntry < GT.
rows())
1212 expectedPose.
x(GT(rawlogEntry, 0));
1213 expectedPose.
y(GT(rawlogEntry, 1));
1214 expectedPose.
phi(GT(rawlogEntry, 2));
1217 else if (GT.
cols() > 0)
1227 if (GT.
cols() == 4 || GT.
cols() == 7)
1229 const bool GT_is_3D = (GT.
cols() == 7);
1230 bool GT_index_is_time =
false;
1237 floor(GT(0, 0)) != GT(0, 0) && floor(GT(1, 0)) != GT(1, 0);
1240 if (GT_index_is_time)
1243 using namespace std::chrono_literals;
1244 GT_path.setMaxTimeInterpolation(200ms);
1246 for (
int i = 0; i < GT.
rows(); i++)
1250 TPose2D(GT(i, 1), GT(i, 2), GT(i, GT_is_3D ? 4 : 3)));
1261 const bool is_3D =
params.read_bool(
sect,
"use_3D_poses",
false);
1266 do_pf_localization<CMonteCarloLocalization3D>();
1271 do_pf_localization<CMonteCarloLocalization2D>();
1282 setLoggerName(
"MonteCarloLocalization_Rawlog");
1290 m_rawlogFileName = std::string(
argv[2]);
1292 m_rawlogFileName =
params.read_string(
1293 sect,
"rawlog_file", std::string(
"log.rawlog"),
true);
1295 m_rawlog_offset =
params.read_int(
sect,
"rawlog_offset", 0);
mrpt::poses::CPosePDFGaussian robotPose
The robot pose Gaussian, in map coordinates.
void clear()
Erase all the contents of the map.
A namespace of pseudo-random numbers generators of diferent distributions.
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 2D area [x_min,x_max]x[y_min,y_max] (in meters) and for orientations [phi_min, phi_max] (in radians).
void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr &outObj) const override
Returns a 3D object representing the map.
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
double Tac() noexcept
Stops the stopwatch.
double minStdPHI
Additional uncertainty: [degrees].
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 createDirectory(const std::string &dirName)
Creates a directory.
static time_point fromDouble(const double t) noexcept
Create a timestamp from its double representation.
The struct for passing extra simulation parameters to the prediction stage when running a particle fi...
void prepareGT(const mrpt::math::CMatrixDouble >)
mrpt::config::CConfigFileMemory params
Populated in initialize().
void run()
Runs with the current parameter set.
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...
void setOrthogonal(bool v=true)
Enable/Disable orthogonal mode (vs.
std::chrono::time_point< Clock > time_point
void loadFromProbabilisticPosesAndObservations(const mrpt::maps::CSimpleMap &Map)
Load the map contents from a CSimpleMap object, erasing all previous content of the map...
mrpt::obs::CObservation2DRangeScanWithUncertainty scanWithUncert
The scan + its uncertainty.
#define THROW_EXCEPTION(msg)
Create a GUI window and display plots with MATLAB-like interfaces and commands.
int getch() noexcept
An OS-independent version of getch, which waits until a key is pushed.
std::string std::string format(std::string_view fmt, ARGS &&... args)
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
mrpt::poses::CPose3D sensorPose
(Default: at origin) The 6D pose of the sensor on the robot at the moment of starting the scan...
The namespace for Bayesian filtering algorithm: different particle filters and Kalman filter algorith...
Output params for laserScanSimulatorWithUncertainty()
float rangeNoiseStd
(Default: 0) The standard deviation of measurement noise.
void randomize(const uint32_t seed)
Initialize the PRNG from the given random seed.
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
A high-performance stopwatch, with typical resolution of nanoseconds.
static void resetUniform(CMonteCarloLocalization3D &pdf, size_t PARTICLE_COUNT, const mrpt::math::TPose3D &init_min, const mrpt::math::TPose3D &init_max)
static void resetOnFreeSpace(CMonteCarloLocalization3D &pdf, mrpt::maps::CMultiMetricMap &metricMap, size_t PARTICLE_COUNT, const mrpt::math::TPose3D &init_min, const mrpt::math::TPose3D &init_max)
double minStdXY
Additional uncertainty: [meters].
mrpt::vision::TStereoCalibParams params
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans. ...
void computeFromOdometry(const mrpt::poses::CPose2D &odometryIncrement, const TMotionModelOptions &options)
Computes the PDF of the pose increment from an odometry reading and according to the given motion mod...
static void resetOnFreeSpace(CMonteCarloLocalization2D &pdf, mrpt::maps::CMultiMetricMap &metricMap, size_t PARTICLE_COUNT, const mrpt::math::TPose3D &init_min, const mrpt::math::TPose3D &init_max)
std::string MRPT_getCompilationDate()
Returns the MRPT source code timestamp, according to the Reproducible-Builds specifications: https://...
CObservation2DRangeScan rangeScan
The observation with the mean ranges in the scan field.
The parameter to be passed to "computeFromOdometry".
T::Ptr mapByClass(size_t ith=0) const
Returns the i'th map of a given class (or of a derived class), or empty smart pointer if there is no ...
float additional_std_XYZ
An additional noise added to the 6DOF model (std.
double yaw
Yaw coordinate (rotation angle over Z axis).
bool rightToLeft
(Default: true) The scanning direction: true=counterclockwise; false=clockwise
Statistics for being returned from the "execute" method.
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 saveToTextFile(const std::string &file, mrpt::math::TMatrixTextFileFormat fileFormat=mrpt::math::MATRIX_FORMAT_ENG, bool appendMRPTHeader=false, const std::string &userHeader=std::string()) const
Saves the vector/matrix to a file compatible with MATLAB/Octave text format.
double weightsVariance_beforeResample
virtual std::string impl_get_usage() const =0
void push_back(const T &val)
void setZoomDistance(float z)
double distanceTo(const CPoseOrPoint< OTHERCLASS, DIM2 > &b) const
Returns the Euclidean distance to another pose/point:
void computeFromOdometry(const mrpt::poses::CPose3D &odometryIncrement, const TMotionModelOptions &options)
Computes the PDF of the pose increment from an odometry reading and according to the given motion mod...
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream, std::istream, std::ostream, std::stringstream.
void setAzimuthDegrees(float ang)
The parameter to be passed to "computeFromOdometry".
#define ASSERT_(f)
Defines an assertion mechanism.
Represents a probabilistic 3D (6D) movement.
Represents a probabilistic 2D movement of the robot mobile base.
double ESS_beforeResample
mrpt::math::CVectorDouble rangesMean
The same ranges than in rangeScan.getScanRange(), for convenience as a math vector container...
This base provides a set of functions for maths stuff.
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
void confidenceIntervals(const CONTAINER &data, T &out_mean, T &out_lower_conf_interval, T &out_upper_conf_interval, const double confidenceInterval=0.1, const size_t histogramNumBins=1000)
Return the mean and the 10%-90% confidence points (or with any other confidence value) of a set of sa...
std::string lowerCase(const std::string &str)
Returns an lower-case version of a string.
static void resetUniform(CMonteCarloLocalization2D &pdf, size_t PARTICLE_COUNT, const mrpt::math::TPose3D &init_min, const mrpt::math::TPose3D &init_max)
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...
double phi() const
Get the phi angle of the 2D pose (in radians)
constexpr double DEG2RAD(const double x)
Degrees to radians.
void enableFollowCamera(bool enabled)
If disabled (default), the SceneViewer application will ignore the camera of the "main" viewport and ...
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.
void initialize(int argc, const char **argv)
Initializes the application from CLI parameters.
float aperture
(Default: M_PI) The "aperture" or field-of-view of the range finder, in radians (typically M_PI = 180...
void setLoggerName(const std::string &name)
Set the name of the COutputLogger instance.
This namespace contains representation of robot actions and observations.
Scalar det() const
Determinant of matrix.
void dumpToTextStream(std::ostream &out) const override
This method dumps the options of the multi-metric map AND those of every internal map...
#define IS_CLASS(obj, class_name)
True if the given reference to object (derived from mrpt::rtti::CObject) is of the given class...
double evaluateScanLikelihood(const CObservation2DRangeScan &otherScan, const TEvalParams ¶ms) const
Returns a measure of the likelihood of a given scan, compared to this scan variances.
std::string extractFileExtension(const std::string &filePath, bool ignore_gz=false)
Extract the extension of a filename.
double x() const
Common members of all points & poses classes.
T hypot_fast(const T x, const T y)
Faster version of std::hypot(), to use when overflow is not an issue and we prefer fast code...
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...
CMatrixDouble cov(const MATRIX &v)
Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample...
This CStream derived class allow using a file as a write-only, binary stream.
mrpt::gui::CDisplayWindow3D::Ptr win
size_type rows() const
Number of rows in the matrix.
size_type cols() const
Number of columns in the matrix.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
TDrawSampleMotionModel modelSelection
The model to be used.
Declares a class that represents a Probability Density Function (PDF) over a 2D pose (x...
void pause(const std::string &msg=std::string("Press any key to continue...")) noexcept
Shows the message "Press any key to continue" (or other custom message) to the current standard outpu...
bool open(const std::string &fileName, bool append=false)
Open the given file for write.
Declares a class that represents a Probability Density Function (PDF) over a 3D pose (x...
#define MRPT_LOAD_CONFIG_VAR( variableName, variableType, configFileObject, sectionNameStr)
An useful macro for loading variables stored in a INI-like file under a key with the same name that t...
#define MRPT_LOG_INFO_STREAM(__CONTENTS)
A class for storing an occupancy grid map.
void do_pf_localization()
const_iterator end() const
#define ASSERT_DIRECTORY_EXISTS_(DIR)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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.
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
void setElevationDegrees(float ang)
COpenGLViewport::Ptr getViewport(const std::string &viewportName=std::string("main")) const
Returns the viewport with the given name, or nullptr if it does not exist; note that the default view...
TOptions_GaussianModel gaussianModel
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
const mrpt::maps::CSimplePointsMap * getAsSimplePointsMap() const override
If the map is a simple points map or it's a multi-metric map that contains EXACTLY one simple points ...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Input params for laserScanSimulatorWithUncertainty()
CRenderizable::Ptr getByName(const std::string &str, const std::string &viewportName=std::string("main"))
Returns the first object with a given name, or nullptr (an empty smart pointer) if not found...
void setContent(const std::vector< std::string > &stringList)
Changes the contents of the virtual "config file".
MonteCarloLocalization_Rawlog()
The configuration of a particle filter.
const float & getScanRange(const size_t i) const
The range values of the scan, in meters.
mrpt::math::CMatrixDouble rangesCovar
The covariance matrix for all the ranges in rangeScan.getScanRange()
TLaserSimulUncertaintyMethod method
(Default: sumMonteCarlo) Select the method to do the uncertainty propagation
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
The namespace for 3D scene representation and rendering.
bool kbhit() noexcept
An OS-independent version of kbhit, which returns true if a key has been pushed.
std::string file_get_contents(const std::string &fileName)
Loads an entire text file and return its contents as a single std::string.
MonteCarloLocalization_Base()
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives...
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
static CAST_TO::Ptr from(const CAST_FROM_PTR &ptr)
bool deleteFilesInDirectory(const std::string &s, bool deleteDirectoryAsWell=false)
Delete all the files in a given directory (nothing done if directory does not exists, or path is a file).
void resetUniform(const mrpt::math::TPose3D &corner_min, const mrpt::math::TPose3D &corner_max, const int particlesCount=-1)
Reset the PDF to an uniformly distributed one, inside of the defined "cube".
Classes for creating GUI windows for 2D and 3D visualization.
TOptions_6DOFModel mm6DOFModel
float maxRange
(Default: 80) The maximum range allowed by the device, in meters (e.g.
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object.
std::string MRPT_getVersion()
Returns a string describing the MRPT version.
An observation of the current (cumulative) odometry for a wheeled robot.
Saves data to a file and transparently compress the data using the given compression level...
void Tic() noexcept
Starts the stopwatch.
This class stores any customizable set of metric maps.
std::string dateTimeLocalToString(const mrpt::system::TTimeStamp t)
Convert a timestamp into this textual form (in local time): YEAR/MONTH/DAY,HH:MM:SS.MMM.
#define ASSERT_FILE_EXISTS_(FIL)
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
void impl_initialize(int argc, const char **argv) override
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
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.
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object.
void insert(const CRenderizable::Ptr &newObject, const std::string &viewportName=std::string("main"))
Insert a new object into the scene, in the given viewport (by default, into the "main" viewport)...
Used for returning entropy related information.
static Ptr Create(Args &&... args)
#define MRPT_LOG_INFO_FMT(_FMT_STRING,...)
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
void removeObject(const CRenderizable::Ptr &obj, const std::string &viewportName=std::string("main"))
Removes the given object from the scene (it also deletes the object to free its memory).
void saveMetricMapRepresentationToFile(const std::string &filNamePrefix) const override
This virtual method saves the map to a file "filNamePrefix"+< some_file_extension >...
TKLDParams KLD_params
Parameters for dynamic sample size, KLD method.
void setListOfMaps(const mrpt::maps::TSetOfMetricMapInitializers &init)
Sets the list of internal map according to the passed list of map initializers (current maps will be ...
virtual void impl_initialize(int argc, const char **argv)=0
#define MRPT_LOG_INFO(_STRING)
void setPointingAt(float x, float y, float z)
void loadFromTextFile(std::istream &f)
Loads a vector/matrix from a text file, compatible with MATLAB text format.
void getGroundTruth(mrpt::poses::CPose2D &expectedPose, size_t rawlogEntry, const mrpt::math::CMatrixDouble >, const Clock::time_point &cur_time)