MRPT  2.0.3
CSimplePointsMap.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/maps/CPointsMap.h>
12 #include <mrpt/math/CMatrixF.h>
13 #include <mrpt/obs/obs_frwds.h>
15 
16 namespace mrpt
17 {
18 namespace maps
19 {
20 /** A cloud of points in 2D or 3D, which can be built from a sequence of laser
21  * scans.
22  * This class only stores the coordinates (x,y,z) of each point.
23  *
24  * See mrpt::maps::CPointsMap and derived classes for other point cloud
25  * classes.
26  *
27  * \sa CMetricMap, CWeightedPointsMap, CPoint,
28  * mrpt::serialization::CSerializable \ingroup mrpt_maps_grp
29  */
31 {
33 
34  public:
35  /** Default constructor */
36  CSimplePointsMap() = default;
39  {
41  }
43  {
45  return *this;
46  }
48  {
49  impl_copyFrom(o);
50  return *this;
51  }
52 
53  // --------------------------------------------
54  /** @name Pure virtual interfaces to be implemented by any class derived
55  from CPointsMap
56  @{ */
57  void reserve(size_t newLength) override; // See base class docs
58  void resize(size_t newLength) override; // See base class docs
59  void setSize(size_t newLength) override; // See base class docs
60  /** The virtual method for \a insertPoint() *without* calling
61  * mark_as_modified() */
62  void insertPointFast(float x, float y, float z = 0) override;
63  /** Get all the data fields for one point as a vector: [X Y Z]
64  * Unlike getPointAllFields(), this method does not check for index out of
65  * bounds
66  * \sa getPointAllFields, setPointAllFields, setPointAllFieldsFast
67  */
69  const size_t index, std::vector<float>& point_data) const override
70  {
71  point_data.resize(3);
72  point_data[0] = m_x[index];
73  point_data[1] = m_y[index];
74  point_data[2] = m_z[index];
75  }
76  /** Set all the data fields for one point as a vector: [X Y Z]
77  * Unlike setPointAllFields(), this method does not check for index out of
78  * bounds
79  * \sa setPointAllFields, getPointAllFields, getPointAllFieldsFast
80  */
82  const size_t index, const std::vector<float>& point_data) override
83  {
84  ASSERTDEB_(point_data.size() == 3);
85  m_x[index] = point_data[0];
86  m_y[index] = point_data[1];
87  m_z[index] = point_data[2];
88  }
89 
90  // See CPointsMap::loadFromRangeScan()
91  void loadFromRangeScan(
92  const mrpt::obs::CObservation2DRangeScan& rangeScan,
93  const mrpt::poses::CPose3D* robotPose = nullptr) override;
94  // See CPointsMap::loadFromRangeScan()
95  void loadFromRangeScan(
96  const mrpt::obs::CObservation3DRangeScan& rangeScan,
97  const mrpt::poses::CPose3D* robotPose = nullptr) override;
98 
99  protected:
100  void impl_copyFrom(const CPointsMap& obj) override;
102  [[maybe_unused]] const CPointsMap& anotherMap,
103  [[maybe_unused]] const size_t nPreviousPoints) override
104  {
105  // No extra data.
106  }
107 
108  // Friend methods:
109  template <class Derived>
111  template <class Derived>
112  friend struct detail::pointmap_traits;
113 
114  public:
115  /** @} */
116 
117  // See base docs
119  {
120  return this;
121  }
122 
123  protected:
124  /** Clear the map, erasing all the points.
125  */
126  void internal_clear() override;
127 
128  /** @name PLY Import virtual methods to implement in base classes
129  @{ */
130  /** In a base class, reserve memory to prepare subsequent calls to
131  * PLY_import_set_vertex */
132  void PLY_import_set_vertex_count(const size_t N) override;
133  /** @} */
134 
136  /** Observations insertion options */
137  mrpt::maps::CPointsMap::TInsertionOptions insertionOpts;
138  /** Probabilistic observation likelihood options */
139  mrpt::maps::CPointsMap::TLikelihoodOptions likelihoodOpts;
140  /** Rendering as 3D object options */
141  mrpt::maps::CPointsMap::TRenderOptions renderOpts;
143 }; // End of class def.
144 } // namespace maps
145 
146 namespace opengl
147 {
148 /** Specialization mrpt::opengl::PointCloudAdapter<mrpt::maps::CSimplePointsMap>
149  * \ingroup mrpt_adapters_grp*/
150 template <>
152 {
153  private:
155 
156  public:
157  /** The type of each point XYZ coordinates */
158  using coords_t = float;
159  /** Has any color RGB info? */
160  static constexpr bool HAS_RGB = false;
161  /** Has native RGB info (as floats)? */
162  static constexpr bool HAS_RGBf = false;
163  /** Has native RGB info (as uint8_t)? */
164  static constexpr bool HAS_RGBu8 = false;
165 
166  /** Constructor (accept a const ref for convenience) */
168  : m_obj(*const_cast<mrpt::maps::CSimplePointsMap*>(&obj))
169  {
170  }
171  /** Get number of points */
172  inline size_t size() const { return m_obj.size(); }
173  /** Set number of points (to uninitialized values) */
174  inline void resize(const size_t N) { m_obj.resize(N); }
175  /** Does nothing as of now */
176  inline void setDimensions(size_t height, size_t width) {}
177  /** Get XYZ coordinates of i'th point */
178  template <typename T>
179  inline void getPointXYZ(const size_t idx, T& x, T& y, T& z) const
180  {
181  m_obj.getPointFast(idx, x, y, z);
182  }
183  /** Set XYZ coordinates of i'th point */
184  inline void setPointXYZ(
185  const size_t idx, const coords_t x, const coords_t y, const coords_t z)
186  {
187  m_obj.setPointFast(idx, x, y, z);
188  }
189 
190  /** Set XYZ coordinates of i'th point */
191  inline void setInvalidPoint(const size_t idx)
192  {
193  m_obj.setPointFast(idx, 0, 0, 0);
194  }
195 }; // end of PointCloudAdapter<mrpt::maps::CPointsMap>
196 } // namespace opengl
197 
198 } // namespace mrpt
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::setDimensions
void setDimensions(size_t height, size_t width)
Does nothing as of now.
Definition: CSimplePointsMap.h:176
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::size
size_t size() const
Get number of points.
Definition: CSimplePointsMap.h:172
mrpt::opengl::PointCloudAdapter
An adapter to different kinds of point cloud object.
Definition: pointcloud_adapters.h:37
mrpt::maps::CPointsMap::operator=
CPointsMap & operator=(const CPointsMap &o)
Definition: CPointsMap.h:122
mrpt::maps::CPointsMap::size
size_t size() const
Save the point cloud as a PCL PCD file, in either ASCII or binary format.
Definition: CPointsMap.h:459
mrpt::maps::CPointsMap::TLikelihoodOptions
Options used when evaluating "computeObservationLikelihood" in the derived classes.
Definition: CPointsMap.h:280
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:184
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:499
mrpt::maps::CSimplePointsMap::operator=
CSimplePointsMap & operator=(const CPointsMap &o)
Definition: CSimplePointsMap.h:42
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:152
CPointsMap.h
mrpt::maps::CSimplePointsMap::insertPointFast
void insertPointFast(float x, float y, float z=0) override
The virtual method for insertPoint() without calling mark_as_modified()
Definition: CSimplePointsMap.cpp:268
mrpt::maps::CSimplePointsMap::getAsSimplePointsMap
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:118
mrpt::obs::CObservation2DRangeScan
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
Definition: CObservation2DRangeScan.h:54
mrpt::maps::CSimplePointsMap::internal_clear
void internal_clear() override
Clear the map, erasing all the points.
Definition: CSimplePointsMap.cpp:258
mrpt::maps::CPointsMap::TInsertionOptions
With this struct options are provided to the observation insertion process.
Definition: CPointsMap.h:222
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:67
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::m_obj
mrpt::maps::CSimplePointsMap & m_obj
Definition: CSimplePointsMap.h:154
mrpt::maps::CSimplePointsMap::setSize
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:82
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: BaseAppDataSource.h:15
mrpt::maps::CSimplePointsMap::CSimplePointsMap
CSimplePointsMap(const CPointsMap &o)
Definition: CSimplePointsMap.h:37
mrpt::maps::CPointsMap::TRenderOptions
Rendering options, used in getAs3DObject()
Definition: CPointsMap.h:314
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::PointCloudAdapter
PointCloudAdapter(const mrpt::maps::CSimplePointsMap &obj)
Constructor (accept a const ref for convenience)
Definition: CSimplePointsMap.h:167
mrpt::maps::CPointsMap::setPointFast
void setPointFast(size_t index, float x, float y, float z)
Changes the coordinates of the given point (0-based index), without checking for out-of-bounds and wi...
Definition: CPointsMap.h:163
mrpt::maps::CSimplePointsMap::setPointAllFieldsFast
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:81
mrpt::obs::CObservation3DRangeScan
A range or depth 3D scan measurement, as from a time-of-flight range camera or a structured-light dep...
Definition: CObservation3DRangeScan.h:168
mrpt::maps::CSimplePointsMap::loadFromRangeScan
void loadFromRangeScan(const mrpt::obs::CObservation2DRangeScan &rangeScan, const mrpt::poses::CPose3D *robotPose=nullptr) override
See CPointsMap::loadFromRangeScan()
Definition: CSimplePointsMap.cpp:351
mrpt::maps::CSimplePointsMap::reserve
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:60
mrpt::maps::CSimplePointsMap::operator=
CSimplePointsMap & operator=(const CSimplePointsMap &o)
Definition: CSimplePointsMap.h:47
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
mrpt::maps::CPointsMap::m_z
mrpt::aligned_std_vector< float > m_z
Definition: CPointsMap.h:1135
mrpt::maps::CSimplePointsMap
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans.
Definition: CSimplePointsMap.h:30
obs_frwds.h
mrpt::maps::CPointsMap::m_y
mrpt::aligned_std_vector< float > m_y
Definition: CPointsMap.h:1135
mrpt::maps::detail::pointmap_traits
Definition: CPointsMap.h:41
MAP_DEFINITION_START
#define MAP_DEFINITION_START(_CLASS_NAME_)
Add a MAP_DEFINITION_START() ...
Definition: TMetricMapTypesRegistry.h:57
mrpt::maps::CSimplePointsMap::addFrom_classSpecific
void addFrom_classSpecific([[maybe_unused]] const CPointsMap &anotherMap, [[maybe_unused]] const size_t nPreviousPoints) override
Definition: CSimplePointsMap.h:101
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::resize
void resize(const size_t N)
Set number of points (to uninitialized values)
Definition: CSimplePointsMap.h:174
MAP_DEFINITION_END
#define MAP_DEFINITION_END(_CLASS_NAME_)
Definition: TMetricMapTypesRegistry.h:67
mrpt::maps::CSimplePointsMap::CSimplePointsMap
CSimplePointsMap()=default
Default constructor.
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::coords_t
float coords_t
The type of each point XYZ coordinates.
Definition: CSimplePointsMap.h:158
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:179
mrpt::maps::CPointsMap::m_x
mrpt::aligned_std_vector< float > m_x
The point coordinates.
Definition: CPointsMap.h:1135
ASSERTDEB_
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.
Definition: exceptions.h:190
mrpt::maps::CSimplePointsMap::PLY_import_set_vertex_count
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:371
mrpt::maps::detail::loadFromRangeImpl
Definition: CPointsMap.h:39
mrpt::maps::CSimplePointsMap::resize
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:70
mrpt::maps
Definition: CBeacon.h:21
mrpt::maps::CSimplePointsMap::getPointAllFieldsFast
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:68
CMatrixF.h
CSerializable.h
mrpt::maps::CSimplePointsMap::CSimplePointsMap
CSimplePointsMap(const CSimplePointsMap &o)
Definition: CSimplePointsMap.h:38
mrpt::opengl::PointCloudAdapter< mrpt::maps::CSimplePointsMap >::setInvalidPoint
void setInvalidPoint(const size_t idx)
Set XYZ coordinates of i'th point.
Definition: CSimplePointsMap.h:191
mrpt::maps::CSimplePointsMap::impl_copyFrom
void impl_copyFrom(const CPointsMap &obj) override
Virtual assignment operator, copies as much common data (XYZ, color,...) as possible from the source ...
Definition: CSimplePointsMap.cpp:91



Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 29 13:06:46 UTC 2020