Main MRPT website > C++ reference for MRPT 1.5.6
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-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 #include <mrpt/maps/link_pragmas.h>
18 
19 namespace mrpt
20 {
21  namespace maps
22  {
23  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CSimplePointsMap , CPointsMap, MAPS_IMPEXP )
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  */
107  virtual void internal_clear() MRPT_OVERRIDE;
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 
155  /** Set XYZ coordinates of i'th point */
156  inline void setInvalidPoint(const size_t idx)
157  {
158  THROW_EXCEPTION("mrpt::maps::CSimplePointsMap needs to be dense");
159  }
160  }; // end of PointCloudAdapter<mrpt::maps::CPointsMap>
161 
162  }
163 
164 } // End of namespace
165 
166 #endif
float coords_t
The type of each point XYZ coordinates.
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...
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...
#define MAP_DEFINITION_END(_CLASS_NAME_, _LINKAGE_)
GLdouble GLdouble z
Definition: glext.h:3734
virtual const mrpt::maps::CSimplePointsMap * getAsSimplePointsMap() const MRPT_OVERRIDE
If the map is a simple points map or it&#39;s a multi-metric map that contains EXACTLY one simple points ...
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
A helper base class for those PointCloudAdapter<> which do not handle RGB data; it declares needed in...
Definition: adapters.h:48
#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.
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 ...
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans. ...
STL namespace.
GLsizei GLsizei GLuint * obj
Definition: glext.h:3902
With this struct options are provided to the observation insertion process.
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors...
#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 MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
GLuint index
Definition: glext.h:3891
EIGEN_STRONG_INLINE void setSize(size_t row, size_t col)
Changes the size of matrix, maintaining its previous content as possible and padding with zeros where...
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...
void getPointXYZ(const size_t idx, T &x, T &y, T &z) const
Get XYZ coordinates of i&#39;th point.
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:72
Options used when evaluating "computeObservationLikelihood" in the derived classes.
void setInvalidPoint(const size_t idx)
Set XYZ coordinates of i&#39;th point.
GLenum GLint GLint y
Definition: glext.h:3516
virtual mrpt::maps::CSimplePointsMap * getAsSimplePointsMap() MRPT_OVERRIDE
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(), this method does not check for index out of bounds.
An adapter to different kinds of point cloud object.
Definition: adapters.h:38
GLenum GLint x
Definition: glext.h:3516
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
size_t size() const
Returns the number of stored points in the map.
#define MAP_DEFINITION_START(_CLASS_NAME_, _LINKAGE_)
Add a MAP_DEFINITION_START() ...
void resize(const size_t N)
Set number of points (to uninitialized values)



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019