class mrpt::maps::CPointsMap

A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors.

This is a virtual class, thus only a derived class can be instantiated by the user. The user most usually wants to use CSimplePointsMap.

This class implements generic version of mrpt::maps::CMetric::insertObservation() accepting these types of sensory data:

Loading and saving in the standard LAS LiDAR point cloud format is supported by installing libLAS and including the header <mrpt/maps/CPointsMaps_liblas.h> in your program. Since MRPT 1.5.0 there is no need to build MRPT against libLAS to use this feature. See LAS functions in libLAS interface for CPointsMap (in.

See also:

CMetricMap, CPoint, CSerializable

#include <mrpt/maps/CPointsMap.h>

class CPointsMap:
    public mrpt::maps::CMetricMap,
    public mrpt::math::KDTreeCapable,
    public mrpt::opengl::PLY_Importer,
    public mrpt::opengl::PLY_Exporter
{
public:
    // structs

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

    // construction

    CPointsMap();
    CPointsMap(const CPointsMap& o);

    //
methods

    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(const size_t index, std::vector<float>& point_data) const = 0;
    virtual void setPointAllFieldsFast(const 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 mrpt::poses::CPose3D* robotPose = nullptr) = 0;
    virtual void loadFromRangeScan(const mrpt::obs::CObservation3DRangeScan& rangeScan, const mrpt::poses::CPose3D* robotPose = nullptr) = 0;
    virtual void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr& outObj) const;
};

// direct descendants

class CColouredPointsMap;
class CPointsMapXYZI;
class CSimplePointsMap;
class CWeightedPointsMap;

Inherited Members

public:
    // typedefs

    typedef KDTreeCapable<Derived, num_t, metric_t> self_t;

    // structs

    template <int _DIM = -1>
    struct TKDTreeDataHolder;

    struct TKDTreeSearchParams;

    //
methods

    virtual bool isEmpty() const = 0;
    virtual void saveMetricMapRepresentationToFile(const std::string& filNamePrefix) const = 0;
    virtual void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr& outObj) const = 0;
    virtual std::string asString() 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;

    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;

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

    void kdTreeEnsureIndexBuilt3D();
    void kdTreeEnsureIndexBuilt2D();
    KDTreeCapable& operator = (const KDTreeCapable&);

Construction

CPointsMap()

Ctor.

CPointsMap(const CPointsMap& o)

Don’t define this one as we cannot call the virtual method impl_copyFrom() during copy ctors.

Redefine in derived classes as needed instead.

Methods

virtual void reserve(size_t newLength) = 0

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) = 0

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) = 0

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

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

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

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

Get all the data fields for one point as a vector: depending on the implementation class this can be [X Y Z] or [X Y Z R G B], etc…

Unlike getPointAllFields(), this method does not check for index out of bounds

See also:

getPointAllFields, setPointAllFields, setPointAllFieldsFast

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

Set all the data fields for one point as a vector: depending on the implementation class this can be [X Y Z] or [X Y Z R G B], etc…

Unlike setPointAllFields(), this method does not check for index out of bounds

See also:

setPointAllFields, getPointAllFields, getPointAllFieldsFast

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

Access to a given point from map, and its colors, if the map defines them (othersise, R=G=B=1.0).

First index is 0.

Parameters:

Throws

std::exception on index out of bound.

Returns:

The return value is the weight of the point (the times it has been fused)

virtual bool hasColorPoints() const

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

virtual void loadFromRangeScan(const mrpt::obs::CObservation2DRangeScan& rangeScan, const mrpt::poses::CPose3D* robotPose = nullptr) = 0

Transform the range scan into a set of cartessian coordinated points.

The options in “insertionOptions” are considered in this method. Only ranges marked as “valid=true” in the observation will be inserted

Each derived class may enrich points in different ways (color, weight, etc..), so please refer to the description of the specific implementation of mrpt::maps::CPointsMap you are using.

The actual generic implementation of this file lives in <src>/CPointsMap_crtp_common.h, but specific instantiations are generated at each derived class.

Parameters:

rangeScan

The scan to be inserted into this map

robotPose

Default to (0,0,0|0deg,0deg,0deg). Changes the frame of reference for the point cloud (i.e. the vehicle/robot pose in world coordinates).

See also:

CObservation2DRangeScan, CObservation3DRangeScan

virtual void loadFromRangeScan(const mrpt::obs::CObservation3DRangeScan& rangeScan, const mrpt::poses::CPose3D* robotPose = nullptr) = 0

Overload of loadFromRangeScan() for 3D range scans (for example, Kinect observations).

Each derived class may enrich points in different ways (color, weight, etc..), so please refer to the description of the specific implementation of mrpt::maps::CPointsMap you are using.

The actual generic implementation of this file lives in <src>/CPointsMap_crtp_common.h, but specific instantiations are generated at each derived class.

Parameters:

rangeScan

The scan to be inserted into this map

robotPose

Default to (0,0,0|0deg,0deg,0deg). Changes the frame of reference for the point cloud (i.e. the vehicle/robot pose in world coordinates).

See also:

loadFromVelodyneScan

virtual void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr& outObj) const

Returns a 3D object representing the map.

The color of the points is controlled by renderOptions