class mrpt::maps::CMultiMetricMap

Python API: mrpt.maps.CMultiMetricMap

Overview

This class stores any customizable set of metric maps.

The internal metric maps can be accessed directly by the user as smart pointers with CMultiMetricMap::mapByIndex() or via iterator s. The utility of this container is to operate on several maps simultaneously: update them by inserting observations, evaluate the likelihood of one observation by fusing (multiplying) the likelihoods over the different maps, etc.

These kinds of metric maps can be kept inside (list may be incomplete, refer to classes derived from mrpt::maps::CMetricMap):

mrpt::maps::CVoxelMap or mrpt::maps::CVoxelMapRGB : 3D sparse voxel maps.

See CMultiMetricMap::setListOfMaps() for the method for initializing this class programmatically. See also TSetOfMetricMapInitializers::loadFromConfigFile for a template of “.ini”-like configuration file that can be used to define which maps to create and all their parameters. Alternatively, the list of maps is public so it can be directly manipulated/accessed in CMultiMetricMap::maps

#include <mrpt/maps/CMultiMetricMap.h>

class CMultiMetricMap: public mrpt::maps::CMetricMap
{
public:
    // typedefs

    typedef std::shared_ptr<mrpt::maps ::CMultiMetricMap> Ptr;
    typedef std::shared_ptr<const mrpt::maps ::CMultiMetricMap> ConstPtr;
    typedef std::unique_ptr<mrpt::maps ::CMultiMetricMap> UniquePtr;
    typedef std::unique_ptr<const mrpt::maps ::CMultiMetricMap> ConstUniquePtr;
    typedef std::deque<mrpt::maps::CMetricMap::Ptr> TListMaps;
    typedef TListMaps::iterator iterator;
    typedef mrpt::containers::deep_const_iterator<TListMaps::const_iterator> const_iterator;

    // fields

    static constexpr const char* className = "mrpt::maps" "::" "CMultiMetricMap";

    // construction

    CMultiMetricMap();
    CMultiMetricMap(const TSetOfMetricMapInitializers& initializers);
    CMultiMetricMap(const CMultiMetricMap& o);
    CMultiMetricMap(CMultiMetricMap&&);

    // methods

    static constexpr auto getClassName();
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    static std::shared_ptr<CObject> CreateObject();

    template <typename... Args>
    static Ptr Create(Args&&... args);

    template <typename Alloc, typename... Args>
    static Ptr CreateAlloc(
        const Alloc& alloc,
        Args&&... args
        );

    template <typename... Args>
    static UniquePtr CreateUnique(Args&&... args);

    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual mrpt::rtti::CObject* clone() const;
    iterator begin();
    const_iterator begin() const;
    iterator end();
    const_iterator end() const;
    size_t size() const;
    bool empty() const;
    void push_back(const mrpt::maps::CMetricMap::Ptr& m);
    void clearMaps();
    TListMaps& mapsList();
    mrpt::maps::CMetricMap::ConstPtr mapByIndex(size_t idx) const;
    mrpt::maps::CMetricMap::Ptr mapByIndex(size_t idx);

    template <typename T>
    T::ConstPtr mapByClass(size_t ith = 0) const;

    template <typename T>
    T::Ptr mapByClass(size_t ith = 0);

    template <typename T>
    std::size_t countMapsByClass() const;

    CMultiMetricMap& operator = (const CMultiMetricMap& o);
    CMultiMetricMap& operator = (CMultiMetricMap&&);
    void setListOfMaps(const mrpt::maps::TSetOfMetricMapInitializers& init);
    virtual bool isEmpty() const;

    virtual void determineMatching2D(
        const mrpt::maps::CMetricMap* otherMap,
        const mrpt::poses::CPose2D& otherMapPose,
        mrpt::tfest::TMatchingPairList& correspondences,
        const mrpt::maps::TMatchingParams& params,
        mrpt::maps::TMatchingExtraResults& extraResults
        ) const;

    virtual float compute3DMatchingRatio(const mrpt::maps::CMetricMap* otherMap, const mrpt::poses::CPose3D& otherMapPose, const TMatchingRatioParams& params) const;
    virtual void saveMetricMapRepresentationToFile(const std::string& filNamePrefix) const;
    virtual void auxParticleFilterCleanUp();
    virtual void getVisualizationInto(mrpt::viz::CSetOfObjects& o) const;
    virtual std::string asString() const;
};

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<CObject> Ptr;
    typedef std::shared_ptr<const CObject> ConstPtr;
    typedef std::unique_ptr<CObject> UniquePtr;
    typedef std::unique_ptr<const CObject> ConstUniquePtr;
    typedef std::shared_ptr<CSerializable> Ptr;
    typedef std::shared_ptr<const CSerializable> ConstPtr;
    typedef std::shared_ptr<CMetricMap> Ptr;
    typedef std::shared_ptr<const CMetricMap> ConstPtr;

    // fields

    TMapGenericParams genericMapParams;

    // methods

    mrpt::rtti::CObject::Ptr duplicateGetSmartPtr() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual CObject* clone() const = 0;
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual std::string asString() const = 0;
    Visualizable& operator = (const Visualizable&);
    Visualizable& operator = (Visualizable&&);
    virtual void getVisualizationInto(mrpt::viz::CSetOfObjects& o) const = 0;
    std::shared_ptr<mrpt::viz::CSetOfObjects> getVisualization() const;
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    void clear();
    virtual bool isEmpty() const = 0;
    virtual auto boundingBox() const;
    void loadFromSimpleMap(const mrpt::maps::CSimpleMap& Map);
    bool insertObservation(const mrpt::obs::CObservation& obs, const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt);
    bool insertObservationPtr(const mrpt::obs::CObservation::Ptr& obs, const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt);
    double computeObservationLikelihood(const mrpt::obs::CObservation& obs, const mrpt::poses::CPose3D& takenFrom) const;
    virtual bool canComputeObservationLikelihood(const mrpt::obs::CObservation& obs) const;
    double computeObservationsLikelihood(const mrpt::obs::CSensoryFrame& sf, const mrpt::poses::CPose3D& takenFrom);
    bool canComputeObservationsLikelihood(const mrpt::obs::CSensoryFrame& sf) const;

    virtual void determineMatching2D(
        const mrpt::maps::CMetricMap* otherMap,
        const mrpt::poses::CPose2D& otherMapPose,
        mrpt::tfest::TMatchingPairList& correspondences,
        const TMatchingParams& params,
        TMatchingExtraResults& extraResults
        ) const;

    virtual void determineMatching3D(
        const mrpt::maps::CMetricMap* otherMap,
        const mrpt::poses::CPose3D& otherMapPose,
        mrpt::tfest::TMatchingPairList& correspondences,
        const TMatchingParams& params,
        TMatchingExtraResults& extraResults
        ) const;

    virtual float compute3DMatchingRatio(const mrpt::maps::CMetricMap* otherMap, const mrpt::poses::CPose3D& otherMapPose, const TMatchingRatioParams& params) const;
    virtual void saveMetricMapRepresentationToFile(const std::string& filNamePrefix) const = 0;
    virtual void auxParticleFilterCleanUp();
    virtual float squareDistanceToClosestCorrespondence(float x0, float y0) const;

Typedefs

typedef std::shared_ptr<mrpt::maps ::CMultiMetricMap> Ptr

A type for the associated smart pointer.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

typedef mrpt::containers::deep_const_iterator<TListMaps::const_iterator> const_iterator

Dereferencing it yields a CMetricMap::ConstPtr, so that a const multi-map cannot hand out mutable child maps.

Construction

CMultiMetricMap()

Default ctor: empty list of maps.

CMultiMetricMap(const TSetOfMetricMapInitializers& initializers)

Constructor with a list of map initializers.

Parameters:

initializers

One internal map will be created for each entry in this “TSetOfMetricMapInitializers” struct.

CMultiMetricMap(const CMultiMetricMap& o)

Creates a deep copy.

CMultiMetricMap(CMultiMetricMap&&)

Move ctor.

Methods

virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const

Returns information about the class of an object in runtime.

virtual mrpt::rtti::CObject* clone() const

Returns a deep copy (clone) of the object, indepently of its class.

size_t size() const

Number of child maps.

bool empty() const

Returns true if there are no child maps.

void push_back(const mrpt::maps::CMetricMap::Ptr& m)

Appends a new child map to the list.

void clearMaps()

Removes all child maps.

TListMaps& mapsList()

Direct access to the list of child maps, for advanced manipulation.

Use dynamic_cast or smart pointer-based downcast to access maps by their actual type. Helper methods to initialize the list are described in the docs of CMultiMetricMap.

mrpt::maps::CMetricMap::ConstPtr mapByIndex(size_t idx) const

Gets the i-th map.

Parameters:

std::runtime_error

On out-of-bounds

template <typename T>
T::ConstPtr 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 such map.

Example:

 COccupancyGridMap2D::Ptr obs =
multimap.mapByClass<COccupancyGridMap2D>();

By default (ith=0), the first match is returned.

template <typename T>
std::size_t countMapsByClass() const

Count how many maps exist of the given class (or derived class)

CMultiMetricMap& operator = (const CMultiMetricMap& o)

Creates a deep copy.

CMultiMetricMap& operator = (CMultiMetricMap&&)

Move operator.

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 deleted)

virtual bool isEmpty() const

Returns true if all maps returns true in their isEmpty() method.

virtual void determineMatching2D(
    const mrpt::maps::CMetricMap* otherMap,
    const mrpt::poses::CPose2D& otherMapPose,
    mrpt::tfest::TMatchingPairList& correspondences,
    const mrpt::maps::TMatchingParams& params,
    mrpt::maps::TMatchingExtraResults& extraResults
    ) const

Computes the matching between this and another 2D point map, which includes finding:

  • The set of points pairs in each map

  • The mean squared distance between corresponding pairs.

The algorithm is:

  • For each point in “otherMap”:

    • Transform the point according to otherMapPose

    • Search with a KD-TREE the closest correspondences in “this” map.

    • Add to the set of candidate matchings, if it passes all the thresholds in params.

This method is the most time critical one into ICP-like algorithms.

Parameters:

otherMap

[IN] The other map to compute the matching with.

otherMapPose

[IN] The pose of the other map as seen from “this”.

params

[IN] Parameters for the determination of pairings.

correspondences

[OUT] The detected matchings pairs.

extraResults

[OUT] Other results.

See also:

compute3DMatchingRatio

virtual float compute3DMatchingRatio(
    const mrpt::maps::CMetricMap* otherMap,
    const mrpt::poses::CPose3D& otherMapPose,
    const TMatchingRatioParams& params
    ) const

Computes the ratio in [0,1] of correspondences between “this” and the “otherMap” map, whose 6D pose relative to “this” is “otherMapPose” In the case of a multi-metric map, this returns the average between the maps.

This method always return 0 for grid maps.

Parameters:

otherMap

[IN] The other map to compute the matching with.

otherMapPose

[IN] The 6D pose of the other map as seen from “this”.

params

[IN] Matching parameters

Returns:

The matching ratio [0,1]

See also:

determineMatching2D

virtual void saveMetricMapRepresentationToFile(const std::string& filNamePrefix) const

This virtual method saves the map to a file “filNamePrefix”+< some_file_extension >, as an image or in any other applicable way (Notice that other methods to save the map may be implemented in classes implementing this virtual interface).

virtual void auxParticleFilterCleanUp()

This method is called at the end of each “prediction-update-map insertion” cycle within “mrpt::slam::CMetricMapBuilderRBPF::processActionObservation”.

This method should normally do nothing, but in some cases can be used to free auxiliary cached variables.

virtual void getVisualizationInto(mrpt::viz::CSetOfObjects& o) const

Inserts 3D primitives representing this object into the provided container.

Note that the former contents of o are not cleared.

See also:

getVisualization()

virtual std::string asString() const

Returns a short description of the map.