class mrpt::maps::CPointsMapXYZIRT

Overview

A map of 3D points with channels: X,Y,Z,I (intensity), R (ring), T (time).

  • ring (uint16_t) holds the “ring number”, or the “row index” for organized point clouds.

  • time (float) uses the convention of time offset in seconds since the first firing of the cloud. So, for example a 10 Hz LIDAR will produce clouds with XYZIRT points with time in the range [0, 0.1] seconds.

All three fields I,R,T are optional. Empty vectors are used to represent that any of these fields is empty, and trying to read them will silently read zeros, but you can check their validity with:

See also:

mrpt::maps::CPointsMap, mrpt::maps::CMetricMap

#include <mrpt/maps/CPointsMapXYZIRT.h>

class CPointsMapXYZIRT: public mrpt::maps::CPointsMap
{
public:
    // construction

    CPointsMapXYZIRT();
    CPointsMapXYZIRT(const CPointsMap& o);
    CPointsMapXYZIRT(const CPointsMapXYZIRT& o);
    CPointsMapXYZIRT(const CPointsMapXYZI& o);

    // methods

    virtual void reserve(size_t newLength);
    virtual void resize(size_t newLength);
    virtual void setSize(size_t newLength);
    void reserve_XYZIRT(size_t n, bool hasIntensity, bool hasRing, bool hasTime);
    void resize_XYZIRT(size_t newLength, bool hasIntensity, bool hasRing, bool hasTime);
    bool hasIntensityField() const;
    bool hasRingField() const;
    bool hasTimeField() const;
    virtual void insertPointFast(float x, float y, float z = 0);
    virtual void getPointAllFieldsFast(size_t index, std::vector<float>& point_data) const;
    virtual void setPointAllFieldsFast(size_t index, const std::vector<float>& point_data);

    virtual void loadFromRangeScan(
        const mrpt::obs::CObservation2DRangeScan& rangeScan,
        const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt
        );

    virtual void loadFromRangeScan(
        const mrpt::obs::CObservation3DRangeScan& rangeScan,
        const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt
        );

    CPointsMapXYZIRT& operator = (const CPointsMap& o);
    CPointsMapXYZIRT& operator = (const CPointsMapXYZIRT& o);
    CPointsMapXYZIRT& operator = (const CPointsMapXYZI& o);
    bool saveXYZIRT_to_text_file(const std::string& file) const;
    bool loadXYZIRT_from_text_file(const std::string& file);

    void setPointRGB(
        size_t index,
        float x,
        float y,
        float z,
        float R_intensity,
        float G_ignored,
        float B_ignored
        );

    void insertPointRGB(
        float x,
        float y,
        float z,
        float R_intensity,
        float G_ignored,
        float B_ignored
        );

    void setPointIntensity(size_t index, float intensity);
    void setPointRing(size_t index, uint16_t ring);
    void setPointTime(size_t index, float time);
    void setPointColor_fast(size_t index, float R, float G, float B);

    virtual void getPointRGB(
        size_t index,
        float& x,
        float& y,
        float& z,
        float& R_intensity,
        float& G_intensity,
        float& B_intensity
        ) const;

    float getPointIntensity(size_t index) const;
    uint16_t getPointRing(size_t index) const;
    float getPointTime(size_t index) const;
    float getPointIntensity_fast(size_t index) const;
    virtual bool hasColorPoints() const;
    virtual void getVisualizationInto(mrpt::opengl::CSetOfObjects& outObj) const;
    virtual auto getPointsBufferRef_intensity() const;
    virtual auto getPointsBufferRef_ring() const;
    virtual auto getPointsBufferRef_timestamp() const;
    virtual auto getPointsBufferRef_intensity();
    virtual auto getPointsBufferRef_ring();
    virtual auto getPointsBufferRef_timestamp();
    void insertPointField_Intensity(float i);
    void insertPointField_Ring(uint16_t r);
    void insertPointField_Timestamp(float t);
    virtual void saveMetricMapRepresentationToFile(const std::string& filNamePrefix) const;
};

Inherited Members

public:
    // typedefs

    typedef KDTreeCapable<Derived, num_t, metric_t> self_t;

    // structs

    template <int _DIM = -1>
    struct TKDTreeDataHolder;

    struct TKDTreeSearchParams;
    struct TInsertionOptions;
    struct TLaserRange2DInsertContext;
    struct TLaserRange3DInsertContext;
    struct TLikelihoodOptions;
    struct TRenderOptions;

    // methods

    virtual bool isEmpty() const = 0;
    virtual void saveMetricMapRepresentationToFile(const std::string& filNamePrefix) const = 0;
    virtual std::string asString() const = 0;
    virtual void getVisualizationInto(mrpt::opengl::CSetOfObjects& o) const = 0;
    float kdTreeClosestPoint2DsqrError(const TPoint2D& p0) const;
    void kdTreeTwoClosestPoint2D(const TPoint2D& p0, TPoint2D& pOut1, TPoint2D& pOut2, float& outDistSqr1, float& outDistSqr2) const;

    std::vector<size_t> kdTreeNClosestPoint2D(
        const TPoint2D& p0,
        size_t N,
        std::vector<TPoint2D>& pOut,
        std::vector<float>& outDistSqr,
        const std::optional<float>& maximumSearchDistanceSqr = std::nullopt
        ) const;

    void kdTreeNClosestPoint2DIdx(
        const TPoint2D& p0,
        size_t N,
        std::vector<size_t>& outIdx,
        std::vector<float>& outDistSqr
        ) const;

    void kdTreeNClosestPoint3D(
        const TPoint3D& p0,
        size_t N,
        std::vector<TPoint3D>& pOut,
        std::vector<float>& outDistSqr,
        const std::optional<float>& maximumSearchDistanceSqr = std::nullopt
        ) const;

    void kdTreeNClosestPoint3DIdx(
        const TPoint3D& p0,
        size_t N,
        std::vector<size_t>& outIdx,
        std::vector<float>& outDistSqr,
        const std::optional<float>& maximumSearchDistanceSqr = std::nullopt
        ) const;

    void kdTreeEnsureIndexBuilt3D();
    void kdTreeEnsureIndexBuilt2D();
    KDTreeCapable& operator = (const KDTreeCapable&);
    virtual bool nn_has_indices_or_ids() const = 0;
    virtual size_t nn_index_count() const = 0;

    virtual bool nn_single_search(
        const mrpt::math::TPoint3Df& query,
        mrpt::math::TPoint3Df& result,
        float& out_dist_sqr,
        uint64_t& resultIndexOrIDOrID
        ) const = 0;

    virtual bool nn_single_search(
        const mrpt::math::TPoint2Df& query,
        mrpt::math::TPoint2Df& result,
        float& out_dist_sqr,
        uint64_t& resultIndexOrIDOrID
        ) const = 0;

    virtual void nn_multiple_search(
        const mrpt::math::TPoint3Df& query,
        const size_t N,
        std::vector<mrpt::math::TPoint3Df>& results,
        std::vector<float>& out_dists_sqr,
        std::vector<uint64_t>& resultIndicesOrIDs
        ) const = 0;

    virtual void nn_multiple_search(
        const mrpt::math::TPoint2Df& query,
        const size_t N,
        std::vector<mrpt::math::TPoint2Df>& results,
        std::vector<float>& out_dists_sqr,
        std::vector<uint64_t>& resultIndicesOrIDs
        ) const = 0;

    virtual void nn_radius_search(
        const mrpt::math::TPoint3Df& query,
        const float search_radius_sqr,
        std::vector<mrpt::math::TPoint3Df>& results,
        std::vector<float>& out_dists_sqr,
        std::vector<uint64_t>& resultIndicesOrIDs,
        size_t maxPoints = 0
        ) const = 0;

    virtual void nn_radius_search(
        const mrpt::math::TPoint2Df& query,
        const float search_radius_sqr,
        std::vector<mrpt::math::TPoint2Df>& results,
        std::vector<float>& out_dists_sqr,
        std::vector<uint64_t>& resultIndicesOrIDs,
        size_t maxPoints = 0
        ) const = 0;

    virtual void reserve(size_t newLength) = 0;
    virtual void resize(size_t newLength) = 0;
    virtual void setSize(size_t newLength) = 0;
    virtual void insertPointFast(float x, float y, float z = 0) = 0;
    virtual void getPointAllFieldsFast(size_t index, std::vector<float>& point_data) const = 0;
    virtual void setPointAllFieldsFast(size_t index, const std::vector<float>& point_data) = 0;
    CPointsMap& operator = (const CPointsMap& o);

    virtual void getPointRGB(
        size_t index,
        float& x,
        float& y,
        float& z,
        float& R,
        float& G,
        float& B
        ) const;

    virtual bool hasColorPoints() const;

    virtual void loadFromRangeScan(
        const mrpt::obs::CObservation2DRangeScan& rangeScan,
        const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt
        ) = 0;

    virtual void loadFromRangeScan(
        const mrpt::obs::CObservation3DRangeScan& rangeScan,
        const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt
        ) = 0;

    virtual void getVisualizationInto(mrpt::opengl::CSetOfObjects& outObj) const;

Methods

virtual void reserve(size_t newLength)

Reserves memory for a given number of points: the size of the map does not change, it only reserves the memory.

This is useful for situations where it is approximately known the final size of the map. This method is more efficient than constantly increasing the size of the buffers. Refer to the STL C++ library’s “reserve” methods.

virtual void resize(size_t newLength)

Resizes all point buffers so they can hold the given number of points: newly created points are set to default values, and old contents are not changed.

See also:

reserve, setPoint, setPointFast, setSize

virtual void setSize(size_t newLength)

Resizes all point buffers so they can hold the given number of points, erasing all previous contents and leaving all points to default values.

See also:

reserve, setPoint, setPointFast, setSize

void reserve_XYZIRT(size_t n, bool hasIntensity, bool hasRing, bool hasTime)

Like reserve(), but allows selecting which fields are present or not:

void resize_XYZIRT(
    size_t newLength,
    bool hasIntensity,
    bool hasRing,
    bool hasTime
    )

Like resize(), but allows selecting which fields are present or not:

virtual void insertPointFast(float x, float y, float z = 0)

The virtual method for insertPoint() without calling mark_as_modified()

virtual void getPointAllFieldsFast(size_t index, std::vector<float>& point_data) const

Get all the data fields for one point as a vector: [X Y Z I] Unlike getPointAllFields(), this method does not check for index out of bounds.

See also:

getPointAllFields, setPointAllFields, setPointAllFieldsFast

virtual void setPointAllFieldsFast(
    size_t index,
    const std::vector<float>& point_data
    )

Set all the data fields for one point as a vector: [X Y Z I R T] Unlike setPointAllFields(), this method does not check for index out of bounds.

See also:

setPointAllFields, getPointAllFields, getPointAllFieldsFast

virtual void loadFromRangeScan(
    const mrpt::obs::CObservation2DRangeScan& rangeScan,
    const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt
    )

See CPointsMap::loadFromRangeScan()

virtual void loadFromRangeScan(
    const mrpt::obs::CObservation3DRangeScan& rangeScan,
    const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt
    )

See CPointsMap::loadFromRangeScan()

bool saveXYZIRT_to_text_file(const std::string& file) const

Save to a text file.

In each line contains X Y Z I R T Returns false if any error occurred, true elsewere.

bool loadXYZIRT_from_text_file(const std::string& file)

Loads from a text file, each line having “X Y Z I”, I in [0,1].

Returns false if any error occurred, true elsewere.

void setPointRGB(
    size_t index,
    float x,
    float y,
    float z,
    float R_intensity,
    float G_ignored,
    float B_ignored
    )

Changes a given point from map.

First index is 0.

Parameters:

Throws

std::exception on index out of bound.

void insertPointRGB(
    float x,
    float y,
    float z,
    float R_intensity,
    float G_ignored,
    float B_ignored
    )

Adds a new point given its coordinates and color (colors range is [0,1])

void setPointIntensity(size_t index, float intensity)

Changes the intensity of a given point from the map.

First index is 0.

Parameters:

Throws

std::exception on index out of bound.

void setPointRing(size_t index, uint16_t ring)

Changes the ring of a given point from the map.

Parameters:

Throws

std::exception on index out of bound.

void setPointTime(size_t index, float time)

Changes the time of a given point from the map.

First index is 0.

Parameters:

Throws

std::exception on index out of bound.

void setPointColor_fast(size_t index, float R, float G, float B)

Like setPointColor but without checking for out-of-index errors.

virtual void getPointRGB(
    size_t index,
    float& x,
    float& y,
    float& z,
    float& R_intensity,
    float& G_intensity,
    float& B_intensity
    ) const

Retrieves a point and its color (colors range is [0,1])

float getPointIntensity(size_t index) const

Gets point intensity ([0,1]), or 0 if field is not present.

uint16_t getPointRing(size_t index) const

Gets point ring number, or 0 if field is not present.

float getPointTime(size_t index) const

Gets point time, or 0 if field is not present.

float getPointIntensity_fast(size_t index) const

Like getPointColor but without checking for out-of-index errors.

virtual bool hasColorPoints() const

Returns true if the point map has a color field for each point.

virtual void getVisualizationInto(mrpt::opengl::CSetOfObjects& outObj) const

Override of the default 3D scene builder to account for the individual points’ color.

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

clang-format on