Main MRPT website > C++ reference for MRPT 1.9.9
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-2018, 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 
12 #include <mrpt/maps/CPointsMap.h>
14 #include <mrpt/math/CMatrix.h>
15 #include <mrpt/obs/obs_frwds.h>
16 
17 namespace mrpt
18 {
19 namespace maps
20 {
21 /** A cloud of points in 2D or 3D, which can be built from a sequence of laser
22  * scans.
23  * This class only stores the coordinates (x,y,z) of each point.
24  *
25  * See mrpt::maps::CPointsMap and derived classes for other point cloud
26  * classes.
27  *
28  * \sa CMetricMap, CWeightedPointsMap, CPoint,
29  * mrpt::serialization::CSerializable \ingroup mrpt_maps_grp
30  */
32 {
34 
35  public:
36  /** Default constructor */
38 
39  // --------------------------------------------
40  /** @name Pure virtual interfaces to be implemented by any class derived
41  from CPointsMap
42  @{ */
43  virtual void reserve(size_t newLength) override; // See base class docs
44  virtual void resize(size_t newLength) override; // See base class docs
45  virtual void setSize(size_t newLength) override; // See base class docs
46  /** Changes the coordinates of the given point (0-based index), *without*
47  * checking for out-of-bounds and *without* calling mark_as_modified() \sa
48  * setPoint */
49  virtual void setPointFast(size_t index, float x, float y, float z) override;
50  /** The virtual method for \a insertPoint() *without* calling
51  * mark_as_modified() */
52  virtual void insertPointFast(float x, float y, float z = 0) override;
53  /** Virtual assignment operator, to be implemented in derived classes */
54  virtual void copyFrom(const CPointsMap& obj) override;
55  /** Get all the data fields for one point as a vector: [X Y Z]
56  * Unlike getPointAllFields(), this method does not check for index out of
57  * bounds
58  * \sa getPointAllFields, setPointAllFields, setPointAllFieldsFast
59  */
60  virtual void getPointAllFieldsFast(
61  const size_t index, std::vector<float>& point_data) const override
62  {
63  point_data.resize(3);
64  point_data[0] = m_x[index];
65  point_data[1] = m_y[index];
66  point_data[2] = m_z[index];
67  }
68  /** Set all the data fields for one point as a vector: [X Y Z]
69  * Unlike setPointAllFields(), this method does not check for index out of
70  * bounds
71  * \sa setPointAllFields, getPointAllFields, getPointAllFieldsFast
72  */
73  virtual void setPointAllFieldsFast(
74  const size_t index, const std::vector<float>& point_data) override
75  {
76  ASSERTDEB_(point_data.size() == 3);
77  m_x[index] = point_data[0];
78  m_y[index] = point_data[1];
79  m_z[index] = point_data[2];
80  }
81 
82  // See CPointsMap::loadFromRangeScan()
83  virtual void loadFromRangeScan(
84  const mrpt::obs::CObservation2DRangeScan& rangeScan,
85  const mrpt::poses::CPose3D* robotPose = nullptr) override;
86  // See CPointsMap::loadFromRangeScan()
87  virtual void loadFromRangeScan(
88  const mrpt::obs::CObservation3DRangeScan& rangeScan,
89  const mrpt::poses::CPose3D* robotPose = nullptr) override;
90 
91  protected:
92  /** Auxiliary method called from within \a addFrom() automatically, to
93  * finish the copying of class-specific data */
94  virtual void addFrom_classSpecific(
95  const CPointsMap& anotherMap, const size_t nPreviousPoints) override
96  {
97  MRPT_UNUSED_PARAM(anotherMap);
98  MRPT_UNUSED_PARAM(nPreviousPoints);
99  // No extra data.
100  }
101 
102  // Friend methods:
103  template <class Derived>
105  template <class Derived>
106  friend struct detail::pointmap_traits;
107 
108  public:
109  /** @} */
110  // --------------------------------------------
111 
112  /** If the map is a simple points map or it's a multi-metric map that
113  * contains EXACTLY one simple points map, return it.
114  * Otherwise, return NULL
115  */
117  const override
118  {
119  return this;
120  }
122  {
123  return this;
124  }
125 
126  protected:
127  /** Clear the map, erasing all the points.
128  */
129  virtual void internal_clear() override;
130 
131  /** @name PLY Import virtual methods to implement in base classes
132  @{ */
133  /** In a base class, reserve memory to prepare subsequent calls to
134  * PLY_import_set_vertex */
135  virtual void PLY_import_set_vertex_count(const size_t N) override;
136  /** @} */
137 
139  /** Observations insertion options */
140  mrpt::maps::CPointsMap::TInsertionOptions insertionOpts;
141  /** Probabilistic observation likelihood options */
142  mrpt::maps::CPointsMap::TLikelihoodOptions likelihoodOpts;
143  /** Rendering as 3D object options */
144  mrpt::maps::CPointsMap::TRenderOptions renderOpts;
146 }; // End of class def.
147 } // namespace maps
148 
149 namespace opengl
150 {
151 /** Specialization mrpt::opengl::PointCloudAdapter<mrpt::maps::CSimplePointsMap>
152  * \ingroup mrpt_adapters_grp*/
153 template <>
155  : public detail::PointCloudAdapterHelperNoRGB<mrpt::maps::CSimplePointsMap,
156  float>
157 {
158  private:
160 
161  public:
162  /** The type of each point XYZ coordinates */
163  using coords_t = float;
164  /** Has any color RGB info? */
165  static const int HAS_RGB = 0;
166  /** Has native RGB info (as floats)? */
167  static const int HAS_RGBf = 0;
168  /** Has native RGB info (as uint8_t)? */
169  static const int HAS_RGBu8 = 0;
170 
171  /** Constructor (accept a const ref for convenience) */
173  : m_obj(*const_cast<mrpt::maps::CSimplePointsMap*>(&obj))
174  {
175  }
176  /** Get number of points */
177  inline size_t size() const { return m_obj.size(); }
178  /** Set number of points (to uninitialized values) */
179  inline void resize(const size_t N) { m_obj.resize(N); }
180  /** Get XYZ coordinates of i'th point */
181  template <typename T>
182  inline void getPointXYZ(const size_t idx, T& x, T& y, T& z) const
183  {
184  m_obj.getPointFast(idx, x, y, z);
185  }
186  /** Set XYZ coordinates of i'th point */
187  inline void setPointXYZ(
188  const size_t idx, const coords_t x, const coords_t y, const coords_t z)
189  {
190  m_obj.setPointFast(idx, x, y, z);
191  }
192 
193  /** Set XYZ coordinates of i'th point */
194  inline void setInvalidPoint(const size_t idx)
195  {
196  THROW_EXCEPTION("mrpt::maps::CSimplePointsMap needs to be dense");
197  }
198 }; // end of PointCloudAdapter<mrpt::maps::CPointsMap>
199 } // namespace opengl
200 
201 } // namespace mrpt
202 
203 #endif
mrpt::maps::CSimplePointsMap::getPointAllFieldsFast
virtual void getPointAllFieldsFast(const size_t index, std::vector< float > &point_data) const override
Get all the data fields for one point as a vector: [X Y Z] Unlike getPointAllFields(),...
Definition: CSimplePointsMap.h:60
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::size
size_t size() const
Get number of points.
Definition: CSimplePointsMap.h:177
mrpt::opengl::PointCloudAdapter
An adapter to different kinds of point cloud object.
Definition: pointcloud_adapters.h:39
mrpt::maps::CPointsMap::size
size_t size() const
Returns the number of stored points in the map.
Definition: CPointsMap.h:408
mrpt::maps::CPointsMap::TLikelihoodOptions
Options used when evaluating "computeObservationLikelihood" in the derived classes.
Definition: CPointsMap.h:263
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::setPointXYZ
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.
Definition: CSimplePointsMap.h:187
mrpt::maps::CPointsMap::getPointFast
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,...
Definition: CPointsMap.h:450
CPointsMap.h
mrpt::maps::CSimplePointsMap::insertPointFast
virtual void insertPointFast(float x, float y, float z=0) override
The virtual method for insertPoint() without calling mark_as_modified()
Definition: CSimplePointsMap.cpp:278
mrpt::obs::CObservation2DRangeScan
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
Definition: CObservation2DRangeScan.h:56
mrpt::maps::CSimplePointsMap::internal_clear
virtual void internal_clear() override
Clear the map, erasing all the points.
Definition: CSimplePointsMap.cpp:261
mrpt::maps::CPointsMap::TInsertionOptions
With this struct options are provided to the observation insertion process.
Definition: CPointsMap.h:205
mrpt::maps::CSimplePointsMap::setPointFast
virtual void setPointFast(size_t index, float x, float y, float z) override
Changes the coordinates of the given point (0-based index), without checking for out-of-bounds and wi...
Definition: CSimplePointsMap.cpp:271
obj
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
CMatrix.h
MRPT_UNUSED_PARAM
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186
mrpt::maps::CPointsMap
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors.
Definition: CPointsMap.h:64
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::m_obj
mrpt::maps::CSimplePointsMap & m_obj
Definition: CSimplePointsMap.h:159
mrpt::maps::CSimplePointsMap::setSize
virtual void setSize(size_t newLength) override
Resizes all point buffers so they can hold the given number of points, erasing all previous contents ...
Definition: CSimplePointsMap.cpp:85
mrpt::maps::CSimplePointsMap::setPointAllFieldsFast
virtual void setPointAllFieldsFast(const size_t index, const std::vector< float > &point_data) override
Set all the data fields for one point as a vector: [X Y Z] Unlike setPointAllFields(),...
Definition: CSimplePointsMap.h:73
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
THROW_EXCEPTION
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
mrpt::maps::CPointsMap::TRenderOptions
Rendering options, used in getAs3DObject()
Definition: CPointsMap.h:297
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::PointCloudAdapter
PointCloudAdapter(const mrpt::maps::CSimplePointsMap &obj)
Constructor (accept a const ref for convenience)
Definition: CSimplePointsMap.h:172
mrpt::obs::CObservation3DRangeScan
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement,...
Definition: CObservation3DRangeScan.h:224
mrpt::maps::CSimplePointsMap::CSimplePointsMap
CSimplePointsMap()
Default constructor.
Definition: CSimplePointsMap.cpp:62
mrpt::maps::CSimplePointsMap::loadFromRangeScan
virtual void loadFromRangeScan(const mrpt::obs::CObservation2DRangeScan &rangeScan, const mrpt::poses::CPose3D *robotPose=nullptr) override
See CPointsMap::loadFromRangeScan()
Definition: CSimplePointsMap.cpp:379
mrpt::maps::CSimplePointsMap::reserve
virtual void reserve(size_t newLength) override
Reserves memory for a given number of points: the size of the map does not change,...
Definition: CSimplePointsMap.cpp:63
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
index
GLuint index
Definition: glext.h:4054
mrpt::maps::CPointsMap::m_z
mrpt::aligned_std_vector< float > m_z
Definition: CPointsMap.h:1094
mrpt::maps::CSimplePointsMap
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans.
Definition: CSimplePointsMap.h:31
obs_frwds.h
mrpt::maps::CPointsMap::m_y
mrpt::aligned_std_vector< float > m_y
Definition: CPointsMap.h:1094
mrpt::maps::CSimplePointsMap::copyFrom
virtual void copyFrom(const CPointsMap &obj) override
Virtual assignment operator, to be implemented in derived classes
Definition: CSimplePointsMap.cpp:94
mrpt::maps::detail::pointmap_traits
Definition: CPointsMap.h:39
mrpt::maps::CSimplePointsMap::addFrom_classSpecific
virtual void addFrom_classSpecific(const CPointsMap &anotherMap, const size_t nPreviousPoints) override
Auxiliary method called from within addFrom() automatically, to finish the copying of class-specific ...
Definition: CSimplePointsMap.h:94
MAP_DEFINITION_START
#define MAP_DEFINITION_START(_CLASS_NAME_)
Add a MAP_DEFINITION_START() ...
Definition: TMetricMapTypesRegistry.h:57
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::resize
void resize(const size_t N)
Set number of points (to uninitialized values)
Definition: CSimplePointsMap.h:179
MAP_DEFINITION_END
#define MAP_DEFINITION_END(_CLASS_NAME_)
Definition: TMetricMapTypesRegistry.h:67
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::coords_t
float coords_t
The type of each point XYZ coordinates.
Definition: CSimplePointsMap.h:163
mrpt::opengl::detail::PointCloudAdapterHelperNoRGB
A helper base class for those PointCloudAdapter<> which do not handle RGB data; it declares needed in...
Definition: pointcloud_adapters.h:49
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::getPointXYZ
void getPointXYZ(const size_t idx, T &x, T &y, T &z) const
Get XYZ coordinates of i'th point.
Definition: CSimplePointsMap.h:182
mrpt::maps::CSimplePointsMap::getAsSimplePointsMap
virtual const mrpt::maps::CSimplePointsMap * getAsSimplePointsMap() const override
If the map is a simple points map or it's a multi-metric map that contains EXACTLY one simple points ...
Definition: CSimplePointsMap.h:116
mrpt::maps::CPointsMap::m_x
mrpt::aligned_std_vector< float > m_x
The point coordinates.
Definition: CPointsMap.h:1094
z
GLdouble GLdouble z
Definition: glext.h:3872
ASSERTDEB_
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.
Definition: exceptions.h:205
mrpt::maps::CSimplePointsMap::PLY_import_set_vertex_count
virtual void PLY_import_set_vertex_count(const size_t N) override
In a base class, reserve memory to prepare subsequent calls to PLY_import_set_vertex.
Definition: CSimplePointsMap.cpp:399
mrpt::maps::detail::loadFromRangeImpl
Definition: CPointsMap.h:37
mrpt::maps::CSimplePointsMap::resize
virtual void resize(size_t newLength) override
Resizes all point buffers so they can hold the given number of points: newly created points are set t...
Definition: CSimplePointsMap.cpp:73
CSerializable.h
mrpt::maps::CSimplePointsMap::getAsSimplePointsMap
virtual mrpt::maps::CSimplePointsMap * getAsSimplePointsMap() override
Definition: CSimplePointsMap.h:121
y
GLenum GLint GLint y
Definition: glext.h:3538
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::setInvalidPoint
void setInvalidPoint(const size_t idx)
Set XYZ coordinates of i'th point.
Definition: CSimplePointsMap.h:194
x
GLenum GLint x
Definition: glext.h:3538



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST