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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019