Main MRPT website > C++ reference for MRPT 1.4.0
maps/CSimplePointsMap.h
Go to the documentation of this file.
1/* +---------------------------------------------------------------------------+
2 | Mobile Robot Programming Toolkit (MRPT) |
3 | http://www.mrpt.org/ |
4 | |
5 | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6 | See: http://www.mrpt.org/Authors - All rights reserved. |
7 | Released under BSD License. See details in http://www.mrpt.org/License |
8 +---------------------------------------------------------------------------+ */
9#ifndef CSimplePointsMap_H
10#define CSimplePointsMap_H
11
14#include <mrpt/math/CMatrix.h>
15#include <mrpt/obs/obs_frwds.h>
16
18
19namespace mrpt
20{
21 namespace maps
22 {
24
25 /** A cloud of points in 2D or 3D, which can be built from a sequence of laser scans.
26 * This class only stores the coordinates (x,y,z) of each point.
27 *
28 * See mrpt::maps::CPointsMap and derived classes for other point cloud classes.
29 *
30 * \sa CMetricMap, CWeightedPointsMap, CPoint, mrpt::utils::CSerializable
31 * \ingroup mrpt_maps_grp
32 */
34 {
35 // This must be added to any CSerializable derived class:
37
38 public:
39 CSimplePointsMap(); //!< Default constructor
40 virtual ~CSimplePointsMap(); //!< Destructor
41
42 // --------------------------------------------
43 /** @name Pure virtual interfaces to be implemented by any class derived from CPointsMap
44 @{ */
45 virtual void reserve(size_t newLength) MRPT_OVERRIDE; // See base class docs
46 virtual void resize(size_t newLength) MRPT_OVERRIDE; // See base class docs
47 virtual void setSize(size_t newLength) MRPT_OVERRIDE; // See base class docs
48 /** Changes the coordinates of the given point (0-based index), *without* checking for out-of-bounds and *without* calling mark_as_modified() \sa setPoint */
49 virtual void setPointFast(size_t index,float x, float y, float z) MRPT_OVERRIDE;
50 /** The virtual method for \a insertPoint() *without* calling mark_as_modified() */
51 virtual void insertPointFast( float x, float y, float z = 0 ) MRPT_OVERRIDE;
52 /** Virtual assignment operator, to be implemented in derived classes */
53 virtual void copyFrom(const CPointsMap &obj) MRPT_OVERRIDE;
54 /** Get all the data fields for one point as a vector: [X Y Z]
55 * Unlike getPointAllFields(), this method does not check for index out of bounds
56 * \sa getPointAllFields, setPointAllFields, setPointAllFieldsFast
57 */
58 virtual void getPointAllFieldsFast( const size_t index, std::vector<float> & point_data ) const MRPT_OVERRIDE {
59 point_data.resize(3);
60 point_data[0] = x[index];
61 point_data[1] = y[index];
62 point_data[2] = z[index];
63 }
64 /** Set all the data fields for one point as a vector: [X Y Z]
65 * Unlike setPointAllFields(), this method does not check for index out of bounds
66 * \sa setPointAllFields, getPointAllFields, getPointAllFieldsFast
67 */
68 virtual void setPointAllFieldsFast( const size_t index, const std::vector<float> & point_data ) MRPT_OVERRIDE {
69 ASSERTDEB_(point_data.size()==3)
70 x[index] = point_data[0];
71 y[index] = point_data[1];
72 z[index] = point_data[2];
73 }
74
75 // See CPointsMap::loadFromRangeScan()
76 virtual void loadFromRangeScan(const mrpt::obs::CObservation2DRangeScan &rangeScan,const mrpt::poses::CPose3D *robotPose = NULL) MRPT_OVERRIDE;
77 // See CPointsMap::loadFromRangeScan()
78 virtual void loadFromRangeScan(const mrpt::obs::CObservation3DRangeScan &rangeScan,const mrpt::poses::CPose3D *robotPose = NULL ) MRPT_OVERRIDE;
79
80 protected:
81 /** Auxiliary method called from within \a addFrom() automatically, to finish the copying of class-specific data */
82 virtual void addFrom_classSpecific(const CPointsMap &anotherMap, const size_t nPreviousPoints) MRPT_OVERRIDE {
83 MRPT_UNUSED_PARAM(anotherMap); MRPT_UNUSED_PARAM(nPreviousPoints);
84 // No extra data.
85 }
86
87 // Friend methods:
88 template <class Derived> friend struct detail::loadFromRangeImpl;
89 template <class Derived> friend struct detail::pointmap_traits;
90
91 public:
92
93
94 /** @} */
95 // --------------------------------------------
96
97
98 /** If the map is a simple points map or it's a multi-metric map that contains EXACTLY one simple points map, return it.
99 * Otherwise, return NULL
100 */
101 virtual const mrpt::maps::CSimplePointsMap * getAsSimplePointsMap() const MRPT_OVERRIDE { return this; }
103
104 protected:
105 /** Clear the map, erasing all the points.
106 */
108
109 /** @name PLY Import virtual methods to implement in base classes
110 @{ */
111 /** In a base class, reserve memory to prepare subsequent calls to PLY_import_set_vertex */
112 virtual void PLY_import_set_vertex_count(const size_t N) MRPT_OVERRIDE;
113 /** @} */
114
116 mrpt::maps::CPointsMap::TInsertionOptions insertionOpts; //!< Observations insertion options
117 mrpt::maps::CPointsMap::TLikelihoodOptions likelihoodOpts; //!< Probabilistic observation likelihood options
119
120 }; // End of class def.
122 } // End of namespace
123
124 namespace utils
125 {
126 /** Specialization mrpt::utils::PointCloudAdapter<mrpt::maps::CSimplePointsMap> \ingroup mrpt_adapters_grp*/
127 template <>
128 class PointCloudAdapter<mrpt::maps::CSimplePointsMap> : public detail::PointCloudAdapterHelperNoRGB<mrpt::maps::CSimplePointsMap,float>
129 {
130 private:
132 public:
133 typedef float coords_t; //!< The type of each point XYZ coordinates
134 static const int HAS_RGB = 0; //!< Has any color RGB info?
135 static const int HAS_RGBf = 0; //!< Has native RGB info (as floats)?
136 static const int HAS_RGBu8 = 0; //!< Has native RGB info (as uint8_t)?
137
138 /** Constructor (accept a const ref for convenience) */
139 inline PointCloudAdapter(const mrpt::maps::CSimplePointsMap &obj) : m_obj(*const_cast<mrpt::maps::CSimplePointsMap*>(&obj)) { }
140 /** Get number of points */
141 inline size_t size() const { return m_obj.size(); }
142 /** Set number of points (to uninitialized values) */
143 inline void resize(const size_t N) { m_obj.resize(N); }
144
145 /** Get XYZ coordinates of i'th point */
146 template <typename T>
147 inline void getPointXYZ(const size_t idx, T &x,T &y, T &z) const {
148 m_obj.getPointFast(idx,x,y,z);
149 }
150 /** Set XYZ coordinates of i'th point */
151 inline void setPointXYZ(const size_t idx, const coords_t x,const coords_t y, const coords_t z) {
152 m_obj.setPointFast(idx,x,y,z);
153 }
154 }; // end of PointCloudAdapter<mrpt::maps::CPointsMap>
155
156 }
157
158} // End of namespace
159
160#endif
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
#define MAP_DEFINITION_END(_CLASS_NAME_, _LINKAGE_)
#define MAP_DEFINITION_START(_CLASS_NAME_, _LINKAGE_)
Add a MAP_DEFINITION_START() ... MAP_DEFINITION_END() block inside the declaration of each metric map...
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors.
void getPointFast(size_t index, float &x, float &y, float &z) const
Just like getPoint() but without checking out-of-bound index and without returning the point weight,...
size_t size() const
Returns the number of stored points in the map.
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans.
virtual void setPointAllFieldsFast(const size_t index, const std::vector< float > &point_data) MRPT_OVERRIDE
Set all the data fields for one point as a vector: [X Y Z] Unlike setPointAllFields(),...
virtual mrpt::maps::CSimplePointsMap * getAsSimplePointsMap() MRPT_OVERRIDE
virtual void setSize(size_t newLength) MRPT_OVERRIDE
Resizes all point buffers so they can hold the given number of points, erasing all previous contents ...
virtual void setPointFast(size_t index, float x, float y, float z) MRPT_OVERRIDE
Changes the coordinates of the given point (0-based index), without checking for out-of-bounds and wi...
virtual void loadFromRangeScan(const mrpt::obs::CObservation2DRangeScan &rangeScan, const mrpt::poses::CPose3D *robotPose=NULL) MRPT_OVERRIDE
Transform the range scan into a set of cartessian coordinated points.
virtual void reserve(size_t newLength) MRPT_OVERRIDE
Reserves memory for a given number of points: the size of the map does not change,...
virtual void insertPointFast(float x, float y, float z=0) MRPT_OVERRIDE
The virtual method for insertPoint() without calling mark_as_modified()
virtual void loadFromRangeScan(const mrpt::obs::CObservation3DRangeScan &rangeScan, const mrpt::poses::CPose3D *robotPose=NULL) MRPT_OVERRIDE
Overload of loadFromRangeScan() for 3D range scans (for example, Kinect observations).
virtual void addFrom_classSpecific(const CPointsMap &anotherMap, const size_t nPreviousPoints) MRPT_OVERRIDE
Auxiliary method called from within addFrom() automatically, to finish the copying of class-specific ...
virtual void resize(size_t newLength) MRPT_OVERRIDE
Resizes all point buffers so they can hold the given number of points: newly created points are set t...
CSimplePointsMap()
Default constructor.
virtual void internal_clear() MRPT_OVERRIDE
Clear the map, erasing all the points.
virtual const mrpt::maps::CSimplePointsMap * getAsSimplePointsMap() const MRPT_OVERRIDE
If the map is a simple points map or it's a multi-metric map that contains EXACTLY one simple points ...
virtual ~CSimplePointsMap()
Destructor.
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement,...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:73
void getPointXYZ(const size_t idx, T &x, T &y, T &z) const
Get XYZ coordinates of i'th point.
void setPointXYZ(const size_t idx, const coords_t x, const coords_t y, const coords_t z)
Set XYZ coordinates of i'th point.
void resize(const size_t N)
Set number of points (to uninitialized values)
PointCloudAdapter(const mrpt::maps::CSimplePointsMap &obj)
Constructor (accept a const ref for convenience)
An adapter to different kinds of point cloud object.
Definition: adapters.h:38
A helper base class for those PointCloudAdapter<> which do not handle RGB data; it declares needed in...
Definition: adapters.h:49
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.
Definition: mrpt_macros.h:283
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
Definition: mrpt_macros.h:290
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
STL namespace.
With this struct options are provided to the observation insertion process.
Options used when evaluating "computeObservationLikelihood" in the derived classes.



Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Fri Jan 20 02:28:26 UTC 2023