35 initializationOptions.PF_options,
36 &initializationOptions.mapsInitializers,
37 &initializationOptions.predictionOptions ),
38 m_PF_options( initializationOptions.PF_options ),
39 insertionLinDistance(initializationOptions.insertionLinDistance),
40 insertionAngDistance(initializationOptions.insertionAngDistance),
41 localizeLinDistance(initializationOptions.localizeLinDistance),
42 localizeAngDistance(initializationOptions.localizeAngDistance),
43 odoIncrementSinceLastLocalization(),
44 odoIncrementSinceLastMapUpdate()
46 setLoggerName(
"CMetricMapBuilderRBPF");
54 this->setLoggerName(
"CMetricMapBuilderRBPF");
119 MRPT_LOG_DEBUG(
"processActionObservation(): Input action is CActionRobotMovement3D");
125 MRPT_LOG_DEBUG(
"processActionObservation(): Input action is CActionRobotMovement2D");
139 bool do_localization = (
145 bool do_map_update = (
154 if ((*it)->GetRuntimeClass()==*itCl)
156 do_map_update =
true;
157 do_localization =
true;
163 do_localization =
true;
165 MRPT_LOG_DEBUG(
mrpt::format(
"do_map_update=%s do_localization=%s",do_map_update ?
"YES":
"NO", do_localization ?
"YES":
"NO" ));
190 newAct.timestamp = act2D->timestamp;
202 pf.setVerbosityLevel( this->getMinLoggingLevel() );
206 if (isLoggingLevelVisible(LVL_INFO))
212 poseEstimation.
getMean(meanPose);
246 it->d->mapTillNow.auxParticleFilterCleanUp();
268 else if (!initialMap.
empty())
271 curPose = initialMap.
rbegin()->first->getMeanVal();
286 CPose3DPDFParticlesPtr posePDF = CPose3DPDFParticles::Create();
290 for (
auto &
p : posePDF->m_particles)
349 std::deque<TPose3D> path;
350 unsigned int imgHeight=0;
356 ASSERT_( currentMetricMapEstimation->m_gridMaps.size()>0 );
360 unsigned int bestPath = 0;
361 double bestPathLik = -1;
375 bool alreadyCopiedImage =
false;
380 currentMetricMapEstimation->m_gridMaps[0]->getSizeX(),
381 currentMetricMapEstimation->m_gridMaps[0]->getSizeY(),
385 if (!alreadyCopiedImage)
391 currentMetricMapEstimation->m_gridMaps[0]->getAsImage( imgGrid );
397 int x1=0,x2=0,y1=0,y2=0;
398 float x_min = currentMetricMapEstimation->m_gridMaps[0]->getXMin();
399 float y_min = currentMetricMapEstimation->m_gridMaps[0]->getYMin();
400 float resolution = currentMetricMapEstimation->m_gridMaps[0]->getResolution();
407 if (i!=bestPath || i==M)
411 size_t nPoses = path.size();
414 x2 =
round( ( path[0].
x - x_min) / resolution);
415 y2 =
round( ( path[0].
y - y_min) / resolution );
418 for (
size_t j=0;j<nPoses;j++)
425 x2 =
round( ( path[j].
x - x_min) / resolution );
426 y2 =
round( ( path[j].
y - y_min) / resolution );
430 x1,
round( (imgHeight-1)-y1 ),
431 x2,
round( (imgHeight-1)-y2 ),
460 img.saveToFile(file);
486 insertionLinDistance ( 1.0f ),
487 insertionAngDistance (
DEG2RAD(30) ),
488 localizeLinDistance ( 0.4f ),
489 localizeAngDistance (
DEG2RAD(10) ),
493 verbosity_level(
mrpt::utils::LVL_INFO)
502 out.
printf(
"\n----------- [CMetricMapBuilderRBPF::TConstructionOptions] ------------ \n\n");
510 PF_options.dumpToTextStream(out);
512 out.
printf(
" Now showing 'mapsInitializers' and 'predictionOptions':\n");
515 mapsInitializers.dumpToTextStream(out);
516 predictionOptions.dumpToTextStream(out);
529 PF_options.loadFromConfigFile(iniFile,section);
536 verbosity_level = iniFile.
read_enum<mrpt::utils::VerbosityLevel>(section,
"verbosity_level", verbosity_level );
538 mapsInitializers.loadFromConfigFile(iniFile,section);
539 predictionOptions.loadFromConfigFile(iniFile,section);
void clear(const mrpt::poses::CPose2D &initialPose)
Clear all elements of the maps, and restore all paths to a single starting pose.
unsigned int getCurrentlyBuiltMapSize()
Returns just how many sensory-frames are stored in the currently build map.
mrpt::poses::CPose3DPDFGaussian poseChange
The 3D pose change probabilistic estimation.
A class acquiring a CCriticalSection at its constructor, and releasing it at destructor.
size_t particlesCount() const MRPT_OVERRIDE
Get the m_particles count.
bool empty() const
Returns size()!=0.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
CPose3D mean
The mean value.
void getMean(CPose3D &mean_pose) const MRPT_OVERRIDE
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF), computed as a weighted average over all m_particles.
void dumpToTextStream(mrpt::utils::CStream &out) const MRPT_OVERRIDE
This method should clearly display all the contents of the structure in textual form, sending it to a CStream.
bool observationsInserted
Whether the SF has been inserted in the metric maps.
CMetricMapBuilderRBPF & operator=(const CMetricMapBuilderRBPF &src)
Copy Operator.
const CMultiMetricMap * getCurrentMostLikelyMetricMap() const
Returns a pointer to the current most likely map (associated to the most likely particle) ...
mrpt::poses::CPose3D odoIncrementSinceLastMapUpdate
Traveled distance since last map update.
double ESS() const MRPT_OVERRIDE
Returns the normalized ESS (Estimated Sample Size), in the range [0,1].
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
float insertionLinDistance
Distances (linear and angular) for inserting a new observation into the map.
A class for storing images as grayscale or RGB bitmaps.
The namespace for Bayesian filtering algorithm: different particle filters and Kalman filter algorith...
void resize(unsigned int width, unsigned int height, TImageChannels nChannels, bool originTopLeft)
Changes the size of the image, erasing previous contents (does NOT scale its current content...
float localizeLinDistance
Distances (linear and angular) for updating the robot pose estimate (and particles weighs...
mrpt::utils::VerbosityLevel verbosity_level
TDATA getMeanVal() const
Returns the mean, or mathematical expectation of the probability density distribution (PDF)...
void saveCurrentPathEstimationToTextFile(const std::string &fil)
A logging utility: saves the current path estimation for each particle in a text file (a row per part...
void getCurrentlyBuiltMap(mrpt::maps::CSimpleMap &out_map) const
Fills "out_map" with the set of "poses"-"sensory-frames", thus the so far built map.
double yaw() const
Get the YAW angle (in radians)
const_reverse_iterator rbegin() const
double getCurrentJointEntropy()
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...
mrpt::poses::CPose3DPDFPtr getCurrentPoseEstimation() const
Returns a copy of the current best pose estimation as a pose PDF.
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string §ion) MRPT_OVERRIDE
This method load the options from a ".ini"-like file or memory-stored string list.
GLsizei GLsizei GLuint * obj
TSet::const_iterator const_iterator
Declares a class for storing a collection of robot actions.
void getEstimatedPosePDF(mrpt::poses::CPose3DPDFParticles &out_estimation) const
Returns the current estimate of the robot pose, as a particles PDF.
GLubyte GLubyte GLubyte GLubyte w
void clear()
Clear all elements of the maps.
This class allows loading and storing values and vectors of different types from a configuration text...
const mrpt::maps::CMultiMetricMap * getCurrentlyBuiltMetricMap() const
Returns the map built so far.
mrpt::synch::CCriticalSection critZoneChangingMap
Critical zones.
TEstimationMethod estimationMethod
This fields indicates the way this estimation was obtained.
const_iterator begin() const
Returns a constant iterator to the first observation: this is an example of usage: ...
void saveCurrentPathEstimationToTextFile(const std::string &fil)
A logging utility: saves the current path estimation for each particle in a text file (a row per part...
Represents a probabilistic 3D (6D) movement.
Represents a probabilistic 2D movement of the robot mobile base.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
CParticleList m_particles
The array of particles.
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
void executeOn(CParticleFilterCapable &obj, const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, TParticleFilterStats *stats=NULL)
Executes a complete prediction + update step of the selected particle filtering algorithm.
void saveCurrentEstimationToImage(const std::string &file, bool formatEMF_BMP=true)
A useful method for debugging: the current map (and/or poses) estimation is dumped to an image file...
mrpt::maps::CMultiMetricMapPDF mapPDF
The map PDF: It includes a path and associated map for each particle.
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...
double norm() const
Returns the euclidean norm of vector: .
#define MRPT_LOG_WARN(_STRING)
A helper class that can convert an enum value into its textual representation, and viceversa...
std::deque< CObservationPtr >::iterator iterator
You can use CSensoryFrame::begin to get a iterator to the first element.
#define MRPT_LOG_INFO(_STRING)
mrpt::utils::CListOfClasses alwaysInsertByClass
A list of observation classes (derived from mrpt::obs::CObservation) which will be always inserted in...
CMetricMapBuilderRBPF()
This second constructor is created for the situation where a class member needs to be of type CMetric...
This namespace contains representation of robot actions and observations.
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
float insertionAngDistance
#define MRPT_LOG_WARN_STREAM(__CONTENTS)
#define MRPT_LOG_DEBUG(_STRING)
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...
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void getCovarianceAndMean(mrpt::math::CMatrixDouble66 &cov, CPose3D &mean_point) const MRPT_OVERRIDE
Returns an estimate of the pose covariance matrix (6x6 cov matrix) and the mean, both at once...
ENUMTYPE read_enum(const std::string §ion, const std::string &name, const ENUMTYPE &defaultValue, bool failIfNotFound=false) const
Reads an "enum" value, where the value in the config file can be either a numerical value or the symb...
virtual ~CMetricMapBuilderRBPF()
Destructor.
float localizeAngDistance
mrpt::math::CMatrixDouble66 cov
The 6x6 covariance matrix.
void updateSensoryFrameSequence()
Update the poses estimation of the member "SFs" according to the current path belief.
#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...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::maps::CSimpleMap SFs
The SFs and their corresponding pose estimations.
#define MRPT_LOG_INFO_STREAM(__CONTENTS)
TStats m_statsLastIteration
This structure will hold stats after each execution of processActionObservation.
TConstructionOptions()
Constructor.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
This class implements a Rao-Blackwelized Particle Filter (RBPF) approach to map building (SLAM)...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
double getCurrentJointEntropy()
Returns the joint entropy estimation over paths and maps, acording to "Information Gain-based Explora...
void setFromValues(const double x0, const double y0, const double z0, const double yaw=0, const double pitch=0, const double roll=0)
Set the pose from a 3D position (meters) and yaw/pitch/roll angles (radians) - This method recomputes...
void getCurrentMostLikelyPath(std::deque< mrpt::math::TPose3D > &outPath) const
Returns the current most-likely path estimation (the path associated to the most likely particle)...
void initialize(const mrpt::maps::CSimpleMap &initialMap=mrpt::maps::CSimpleMap(), mrpt::poses::CPosePDF *x0=NULL)
Initialize the method, starting with a known location PDF "x0" (or set to NULL to use the last keyfra...
bool debugForceInsertion
Always insert into map. Default is false: detect if necesary.
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
int round(const T value)
Returns the closer integer (int) to x.
#define MRPT_LOAD_HERE_CONFIG_VAR_DEGREES_NO_DEFAULT(variableName, variableType, targetVariable, configFileObject, sectionNameStr)
This virtual class defines the interface of any object accepting drawing primitives on it...
mrpt::poses::CPose3DPDFGaussian odoIncrementSinceLastLocalization
Traveled distance since last localization update.
void processActionObservation(mrpt::obs::CActionCollection &action, mrpt::obs::CSensoryFrame &observations)
Appends a new action and observations to update this map: See the description of the class at the top...
T::Ptr getActionByClass(const size_t &ith=0) const
Access to the i'th action of a given class, or a NULL smart pointer if there is no action of that cla...
bool insertObservation(mrpt::obs::CSensoryFrame &sf)
Insert an observation to the map, at each particle's pose and to each particle's metric map...
void drawCurrentEstimationToImage(utils::CCanvas *img)
A useful method for debugging: draws the current map and path hypotheses to a CCanvas.
const_iterator end() const
Returns a constant iterator to the end of the list of observations: this is an example of usage: ...
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...
#define MRPT_LOG_DEBUG_STREAM(__CONTENTS)
size_t size() const
Returns the number of observations in the list.
Options for building a CMetricMapBuilderRBPF object, passed to the constructor.
virtual void drawImage(int x, int y, const utils::CImage &img)
Draws an image as a bitmap at a given position.
bayes::CParticleFilter::TParticleFilterOptions m_PF_options
The configuration of the particle filter.
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
mrpt::system::TTimeStamp timestamp
The associated time-stamp.
Declares a class that represents a Probability Density function (PDF) of a 3D pose.
size_t getHeight() const MRPT_OVERRIDE
Returns the height of the image in pixels.
double getW(size_t i) const MRPT_OVERRIDE
Access to i'th particle (logarithm) weight, where first one is index 0.
void getPath(size_t i, std::deque< math::TPose3D > &out_path) const
Return the path (in absolute coordinate poses) for the i'th particle.
void insert(CAction &action)
Add a new object to the list.