class mrpt::maps::CReflectivityGridMap2D

Overview

A 2D grid map representing the reflectivity of the environment (for example, measured with an IR proximity sensor).

Important implemented features are:

  • Insertion of mrpt::obs::CObservationReflectivity observations.

  • Probability estimation of observations. See base class.

  • Rendering as 3D object: a 2D textured plane.

  • Automatic resizing of the map limits when inserting observations close to the border.

Each cell contains the up-to-date average height from measured falling in that cell. Algorithms that can be used:

  • mrSimpleAverage: Each cell only stores the current average value.

#include <mrpt/maps/CReflectivityGridMap2D.h>

class CReflectivityGridMap2D:
    public mrpt::maps::CMetricMap,
    public mrpt::containers::CDynamicGrid,
    public mrpt::maps::CLogOddsGridMap2D,
    public mrpt::config::OptionsCapable
{
public:
    // typedefs

    typedef std::shared_ptr<mrpt::maps ::CReflectivityGridMap2D> Ptr;
    typedef std::shared_ptr<const mrpt::maps ::CReflectivityGridMap2D> ConstPtr;
    typedef std::unique_ptr<mrpt::maps ::CReflectivityGridMap2D> UniquePtr;
    typedef std::unique_ptr<const mrpt::maps ::CReflectivityGridMap2D> ConstUniquePtr;
    typedef detail::logoddscell_traits<int8_t> traits_t;

    // structs

    struct TInsertionOptions;
    struct TMapDefinition;
    struct TMapDefinitionBase;

    // fields

    static constexpr const char* className = "mrpt::maps" "::" "CReflectivityGridMap2D";
    static const size_t m_private_map_register_id =   mrpt::maps::internal::TMetricMapTypesRegistry::Instance().doRegister("mrpt::maps::CReflectivityGridMap2D,reflectivityMap" ,& mrpt::maps::CReflectivityGridMap2D ::MapDefinition,& mrpt::maps::CReflectivityGridMap2D ::internal_CreateFromMapDefinition);
    mrpt::maps::CReflectivityGridMap2D::TInsertionOptions insertionOptions;

    // construction

    CReflectivityGridMap2D(
        double x_min = -2,
        double x_max = 2,
        double y_min = -2,
        double y_max = 2,
        double resolution = 0.1
        );

    // 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;
    static std::shared_ptr<mrpt::maps::TMetricMapInitializer> MapDefinition();
    static std::shared_ptr<CReflectivityGridMap2D> CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer& def);
    static std::shared_ptr<mrpt::maps::CMetricMap> internal_CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer& def);
    void clear();
    virtual float cell2float(const int8_t&) const;
    virtual bool isEmpty() const;
    virtual std::map<std::string, mrpt::config::CLoadableOptions*> optionsByName();
    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 getVisualizationInto(mrpt::viz::CSetOfObjects& o) const;
    void getAsImage(mrpt::img::CImage& img, bool verticalFlip = false, bool forceRGB = false) const;
    virtual std::string asString() const;
};

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<CSerializable> Ptr;
    typedef std::shared_ptr<const CSerializable> ConstPtr;
    typedef TCELL cell_t;

    // methods

    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    Visualizable& operator = (const Visualizable&);
    Visualizable& operator = (Visualizable&&);
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual bool isEmpty() const = 0;
    virtual void saveMetricMapRepresentationToFile(const std::string& filNamePrefix) const = 0;
    virtual std::string asString() const = 0;
    virtual void getVisualizationInto(mrpt::viz::CSetOfObjects& o) const = 0;

    void updateCell_fast_occupied(
        const unsigned x,
        const unsigned y,
        const cell_t logodd_obs,
        const cell_t thres,
        cell_t* mapArray,
        const unsigned _size_x
        );

    void updateCell_fast_occupied(cell_t* theCell, const cell_t logodd_obs, const cell_t thres);

    static void updateCell_fast_free(
        const unsigned x,
        const unsigned y,
        const cell_t logodd_obs,
        const cell_t thres,
        cell_t* mapArray,
        const unsigned _size_x
        );

    static void updateCell_fast_free(cell_t* theCell, const cell_t logodd_obs, const cell_t thres);
    OptionsCapable& operator = (const OptionsCapable&);
    OptionsCapable& operator = (OptionsCapable&&);
    virtual std::map<std::string, mrpt::config::CLoadableOptions*> optionsByName() = 0;

Typedefs

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

A type for the associated smart pointer.

Fields

static const size_t m_private_map_register_id =   mrpt::maps::internal::TMetricMapTypesRegistry::Instance().doRegister("mrpt::maps::CReflectivityGridMap2D,reflectivityMap" ,& mrpt::maps::CReflectivityGridMap2D ::MapDefinition,& mrpt::maps::CReflectivityGridMap2D ::internal_CreateFromMapDefinition)

ID used to initialize class registration (just ignore it)

Construction

CReflectivityGridMap2D(
    double x_min = -2,
    double x_max = 2,
    double y_min = -2,
    double y_max = 2,
    double resolution = 0.1
    )

Constructor

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.

static std::shared_ptr<mrpt::maps::TMetricMapInitializer> MapDefinition()

Returns default map definition initializer.

See * mrpt::maps::TMetricMapInitializer

static std::shared_ptr<CReflectivityGridMap2D> CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer& def)

Constructor from a map definition structure: initializes the map and * its parameters accordingly.

void clear()

Calls the base CMetricMap::clear Declared here to avoid ambiguity between the two clear() in both base classes.

virtual float cell2float(const int8_t&) const

The user must implement this in order to provide “saveToTextFile” a way to convert each cell into a numeric value.

virtual bool isEmpty() const

Returns true if the map is empty/no observation has been inserted.

virtual std::map<std::string, mrpt::config::CLoadableOptions*> optionsByName()

Maps an options-group name (e.g.

“insertionOptions”) to a pointer to the corresponding, live CLoadableOptions member. Pointers remain valid as long as this is alive, and point directly to the actual option members (no copies), so writes through them (e.g. via loadFromConfigFile()) take effect immediately.

Implementations should list every CLoadableOptions member they define, INCLUDING “creationOptions” if present (so it can be discovered/exported generically); however, callers must use trySetCreationOptions(), not a direct write through this pointer, to safely modify creation options.

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

See docs in base class: in this class this always returns 0.

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

void getAsImage(mrpt::img::CImage& img, bool verticalFlip = false, bool forceRGB = false) const

Returns the grid as a 8-bit graylevel image, where each pixel is a cell (output image is RGB only if forceRGB is true)

virtual std::string asString() const

Returns a short description of the map.