class mrpt::slam::CMetricMapBuilderRBPF

This class implements a Rao-Blackwelized Particle Filter (RBPF) approach to map building (SLAM).

Internally, the list of particles, each containing a hypothesis for the robot path plus its associated metric map, is stored in an object of class CMultiMetricMapPDF.

This class processes robot actions and observations sequentially (through the method CMetricMapBuilderRBPF::processActionObservation) and exploits the generic design of metric map classes in MRPT to deal with any number and combination of maps simultaneously: the likelihood of observations is the product of the likelihood in the different maps, etc.

A number of particle filter methods are implemented as well, by selecting the appropriate values in TConstructionOptions::PF_options. Not all the PF algorithms are implemented for all kinds of maps.

For an example of usage, check the application “rbpf-slam”, in “apps/RBPF-SLAM”. See also the wiki page.

Since MRPT 0.7.2, the new variables “localizeLinDistance,localizeAngDistance” are introduced to provide a way to update the robot pose at a different rate than the map is updated.

Since MRPT 0.7.1 the semantics of the parameters “insertionLinDistance” and “insertionAngDistance” changes: the entire RBFP is now NOT updated unless odometry increments surpass the threshold (previously, only the map was NOT updated). This is done to gain efficiency.

Since MRPT 0.6.2 this class implements full 6D SLAM. Previous versions worked in 2D + heading only.

See also:

CMetricMap

#include <mrpt/slam/CMetricMapBuilderRBPF.h>

class CMetricMapBuilderRBPF: public mrpt::slam::CMetricMapBuilder
{
public:
    // structs

    struct TConstructionOptions;
    struct TStats;

    //
fields

    mrpt::maps::CMultiMetricMapPDF mapPDF;
    TStats m_statsLastIteration;
    TOptions options;

    // construction

    CMetricMapBuilderRBPF(const TConstructionOptions& initializationOptions);
    CMetricMapBuilderRBPF();

    //
methods

    CMetricMapBuilderRBPF& operator = (const CMetricMapBuilderRBPF& src);
    virtual void initialize(const mrpt::maps::CSimpleMap& initialMap = mrpt::maps::CSimpleMap(), const mrpt::poses::CPosePDF* x0 = nullptr);
    void clear();
    virtual mrpt::poses::CPose3DPDF::Ptr getCurrentPoseEstimation() const;
    void getCurrentMostLikelyPath(std::deque<mrpt::math::TPose3D>& outPath) const;
    virtual void processActionObservation(mrpt::obs::CActionCollection& action, mrpt::obs::CSensoryFrame& observations);
    virtual void getCurrentlyBuiltMap(mrpt::maps::CSimpleMap& out_map) const;
    virtual const mrpt::maps::CMultiMetricMap& getCurrentlyBuiltMetricMap() const;
    virtual unsigned int getCurrentlyBuiltMapSize();
    virtual void saveCurrentEstimationToImage(const std::string& file, bool formatEMF_BMP = true);
    void drawCurrentEstimationToImage(mrpt::img::CCanvas* img);
    void saveCurrentPathEstimationToTextFile(const std::string& fil);
    double getCurrentJointEntropy();
};

Inherited Members

public:
    // structs

    struct TMsg;
    struct TOptions;

    //
methods

    virtual void initialize(const mrpt::maps::CSimpleMap& initialMap = mrpt::maps::CSimpleMap(), const mrpt::poses::CPosePDF* x0 = nullptr) = 0;
    virtual mrpt::poses::CPose3DPDF::Ptr getCurrentPoseEstimation() const = 0;
    virtual void processActionObservation(mrpt::obs::CActionCollection& action, mrpt::obs::CSensoryFrame& observations) = 0;
    virtual void getCurrentlyBuiltMap(mrpt::maps::CSimpleMap& out_map) const = 0;
    virtual unsigned int getCurrentlyBuiltMapSize() = 0;
    virtual const mrpt::maps::CMultiMetricMap& getCurrentlyBuiltMetricMap() const = 0;
    virtual void saveCurrentEstimationToImage(const std::string& file, bool formatEMF_BMP = true) = 0;
    void clear();
    void enableMapUpdating(bool enable);
    void loadCurrentMapFromFile(const std::string& fileName);
    void saveCurrentMapToFile(const std::string& fileName, bool compressGZ = true) const;

Fields

mrpt::maps::CMultiMetricMapPDF mapPDF

The map PDF: It includes a path and associated map for each particle.

TStats m_statsLastIteration

This structure will hold stats after each execution of processActionObservation.

Construction

CMetricMapBuilderRBPF(const TConstructionOptions& initializationOptions)

Constructor.

CMetricMapBuilderRBPF()

This second constructor is created for the situation where a class member needs to be of type CMetricMapBuilderRBPF

Methods

CMetricMapBuilderRBPF& operator = (const CMetricMapBuilderRBPF& src)

Copy Operator.

virtual void initialize(const mrpt::maps::CSimpleMap& initialMap = mrpt::maps::CSimpleMap(), const mrpt::poses::CPosePDF* x0 = nullptr)

Initialize the method, starting with a known location PDF “x0”(if supplied, set to nullptr to left unmodified) and a given fixed, past map.

void clear()

Clear all elements of the maps.

virtual mrpt::poses::CPose3DPDF::Ptr getCurrentPoseEstimation() const

Returns a copy of the current best pose estimation as a pose PDF.

void getCurrentMostLikelyPath(std::deque<mrpt::math::TPose3D>& outPath) const

Returns the current most-likely path estimation (the path associated to the most likely particle).

virtual 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 of this page to see a more complete description.

Parameters:

action

The incremental 2D pose change in the robot pose. This value is deterministic.

observations

The set of observations that robot senses at the new pose. Statistics will be saved to statsLastIteration

virtual void getCurrentlyBuiltMap(mrpt::maps::CSimpleMap& out_map) const

Fills “out_map” with the set of “poses”-“sensory-frames”, thus the so far built map.

virtual const mrpt::maps::CMultiMetricMap& getCurrentlyBuiltMetricMap() const

Returns the map built so far.

NOTE that for efficiency a pointer to the internal object is passed, DO NOT delete nor modify the object in any way, if desired, make a copy of ir with “clone()”.

virtual unsigned int getCurrentlyBuiltMapSize()

Returns just how many sensory-frames are stored in the currently build map.

virtual 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.

Parameters:

file

The output file name

formatEMF_BMP

Output format = true:EMF, false:BMP

void drawCurrentEstimationToImage(mrpt::img::CCanvas* img)

A useful method for debugging: draws the current map and path hypotheses to a CCanvas

void saveCurrentPathEstimationToTextFile(const std::string& fil)

A logging utility: saves the current path estimation for each particle in a text file (a row per particle, each 3-column-entry is a set [x,y,phi], respectively).