class mrpt::maps::CSimplePointsMap
Overview
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans.
This class only stores the coordinates (x,y,z) of each point.
See mrpt::maps::CPointsMap and derived classes for other point cloud classes.
See also:
CMetricMap, CPoint, mrpt::serialization::CSerializable
#include <mrpt/maps/CSimplePointsMap.h> class CSimplePointsMap: public mrpt::maps::CPointsMap { public: // typedefs typedef std::shared_ptr<mrpt::maps ::CSimplePointsMap> Ptr; typedef std::shared_ptr<const mrpt::maps ::CSimplePointsMap> ConstPtr; typedef std::unique_ptr<mrpt::maps ::CSimplePointsMap> UniquePtr; typedef std::unique_ptr<const mrpt::maps ::CSimplePointsMap> ConstUniquePtr; // structs struct TMapDefinition; struct TMapDefinitionBase; // fields static constexpr const char* className = "mrpt::maps" "::" "CSimplePointsMap"; static const size_t m_private_map_register_id = mrpt::maps::internal::TMetricMapTypesRegistry::Instance().doRegister("mrpt::maps::CSimplePointsMap,pointsMap" ,& mrpt::maps::CSimplePointsMap ::MapDefinition,& mrpt::maps::CSimplePointsMap ::internal_CreateFromMapDefinition); static constexpr static const char* POINT_FIELD_INTENSITY = "intensity"; static constexpr static const char* POINT_FIELD_RING_ID = "ring"; static constexpr static const char* POINT_FIELD_TIMESTAMP = "t"; TLikelihoodOptions likelihoodOptions; TRenderOptions renderOptions; // construction CSimplePointsMap(); CSimplePointsMap(const CPointsMap& o); CSimplePointsMap(const CSimplePointsMap& o); // 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<CSimplePointsMap> CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer& def); static std::shared_ptr<mrpt::maps::CMetricMap> internal_CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer& def); virtual void reserve(size_t newLength); virtual void resize(size_t newLength); virtual void setSize(size_t newLength); 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); virtual void loadFromRangeScan(const mrpt::obs::CObservation3DRangeScan& rangeScan, const std::optional<const mrpt::poses::CPose3D>& robotPose); bool load2D_from_text_stream( std::istream& in, mrpt::optional_ref<std::string> outErrorMsg = std::nullopt ); bool load3D_from_text_stream( std::istream& in, mrpt::optional_ref<std::string> outErrorMsg = std::nullopt ); bool load2Dor3D_from_text_stream( std::istream& in, mrpt::optional_ref<std::string> outErrorMsg, bool is_3D ); bool save2D_to_text_stream(std::ostream& out) const; bool save3D_to_text_stream(std::ostream& out) const; virtual void reserveField_float( ] const std::string& fieldName, ] size_t n ); virtual void reserveField_double( ] const std::string& fieldName, ] size_t n ); virtual void reserveField_uint16( ] const std::string& fieldName, ] size_t n ); virtual void reserveField_uint8( ] const std::string& fieldName, ] size_t n ); virtual void reserveField_uint32( ] const std::string& fieldName, ] size_t n ); virtual void resizeField_float( ] const std::string& fieldName, ] size_t n ); virtual void resizeField_double( ] const std::string& fieldName, ] size_t n ); virtual void resizeField_uint16( ] const std::string& fieldName, ] size_t n ); virtual void resizeField_uint8( ] const std::string& fieldName, ] size_t n ); virtual void resizeField_uint32( ] const std::string& fieldName, ] size_t n ); virtual auto getPointsBufferRef_float_field(const std::string& fieldName) const; virtual auto getPointsBufferRef_float_field(const std::string& fieldName); virtual auto getPointsBufferRef_double_field(] const std::string& fieldName) const; virtual auto getPointsBufferRef_double_field(] const std::string& fieldName); virtual auto getPointsBufferRef_uint16_field(] const std::string& fieldName) const; virtual auto getPointsBufferRef_uint16_field(] const std::string& fieldName); virtual auto getPointsBufferRef_uint8_field(] const std::string& fieldName) const; virtual auto getPointsBufferRef_uint8_field(] const std::string& fieldName); virtual auto getPointsBufferRef_uint32_field(] const std::string& fieldName) const; virtual auto getPointsBufferRef_uint32_field(] const std::string& fieldName); template <typename BBOX> bool kdtree_get_bbox(BBOX& bb) const; virtual bool nn_single_search( const mrpt::math::TPoint2Df& query, mrpt::math::TPoint2Df& result, float& out_dist_sqr, uint64_t& resultIndexOrID ) const; virtual void nn_multiple_search( const mrpt::math::TPoint2Df& query, size_t N, std::vector<mrpt::math::TPoint2Df>& results, std::vector<float>& out_dists_sqr, std::vector<uint64_t>& resultIndicesOrIDs ) const; virtual void nn_radius_search( const mrpt::math::TPoint2Df& query, float search_radius_sqr, std::vector<mrpt::math::TPoint2Df>& results, std::vector<float>& out_dists_sqr, std::vector<uint64_t>& resultIndicesOrIDs, size_t maxPoints ) const; CSimplePointsMap& operator = (const CPointsMap& o); CSimplePointsMap& operator = (const CSimplePointsMap& o); virtual const mrpt::maps::CSimplePointsMap* getAsSimplePointsMap() const; float squareDistanceToClosestCorrespondenceT(const mrpt::math::TPoint2D& p0) const; void getPoint( size_t index, mrpt::math::TPoint3Df& p ) const; void getAllPoints( std::vector<mrpt::math::TPoint2D>& ps, size_t decimation = 1 ) const; double internal_computeObservationLikelihoodPointCloud3D( const mrpt::poses::CPose3D& pc_in_map, const float* xs, const float* ys, const float* zs, std::size_t num_pts ) const; };
Inherited Members
public: // typedefs typedef std::shared_ptr<CObject> Ptr; typedef std::shared_ptr<const CObject> ConstPtr; typedef std::shared_ptr<CSerializable> Ptr; typedef std::shared_ptr<const CSerializable> ConstPtr; typedef KDTreeCapable<Derived, num_t, metric_t> self_t; typedef std::shared_ptr<CPointsMap> Ptr; typedef std::shared_ptr<const CPointsMap> ConstPtr; // structs template <int _DIM = -1> struct TKDTreeDataHolder; struct TKDTreeSearchParams; struct InsertCtx; struct TInsertionOptions; struct TLaserRange2DInsertContext; struct TLaserRange3DInsertContext; struct TLikelihoodOptions; struct TRenderOptions; // methods static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); 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; 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, 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, 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, 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, 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; NearestNeighborsCapable& operator = (const NearestNeighborsCapable&); NearestNeighborsCapable& operator = (NearestNeighborsCapable&&); virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const; static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); virtual bool registerField_float(const std::string& fieldName); virtual void reserve(size_t newLength) = 0; virtual void resize(size_t newLength) = 0; virtual void setSize(size_t newLength) = 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; virtual bool hasPointField(const std::string& fieldName) const; virtual std::vector<std::string> getPointFieldNames_float() const; virtual std::vector<std::string> getPointFieldNames_double() const; virtual std::vector<std::string> getPointFieldNames_uint16() const; virtual std::vector<std::string> getPointFieldNames_uint8() const; virtual std::vector<std::string> getPointFieldNames_uint32() const; virtual float getPointField_float(size_t index, const std::string& fieldName) const; virtual void setPointField_float(size_t index, const std::string& fieldName, float value); CPointsMap& operator = (const CPointsMap& o); CPointsMap& operator = (CPointsMap&& o); virtual void loadFromRangeScan(const mrpt::obs::CObservation2DRangeScan& rangeScan, const std::optional<const mrpt::poses::CPose3D>& robotPose) = 0; virtual void loadFromRangeScan(const mrpt::obs::CObservation3DRangeScan& rangeScan, const std::optional<const mrpt::poses::CPose3D>& robotPose) = 0;
Typedefs
typedef std::shared_ptr<mrpt::maps ::CSimplePointsMap> 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::CSimplePointsMap,pointsMap" ,& mrpt::maps::CSimplePointsMap ::MapDefinition,& mrpt::maps::CSimplePointsMap ::internal_CreateFromMapDefinition)
ID used to initialize class registration (just ignore it)
Construction
CSimplePointsMap()
Default 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<CSimplePointsMap> CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer& def)
Constructor from a map definition structure: initializes the map and * its parameters accordingly.
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 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] 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] 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 )
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 std::optional<const mrpt::poses::CPose3D>& robotPose )
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:
virtual const mrpt::maps::CSimplePointsMap* getAsSimplePointsMap() const
If the map is a simple points map or it’s a multi-metric map that contains EXACTLY one simple points map, return it.
Otherwise, return nullptr