Main MRPT website > C++ reference
MRPT logo
CReflectivityGridMap2D.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-2014, 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 
10 #ifndef CReflectivityGridMap2D_H
11 #define CReflectivityGridMap2D_H
12 
13 #include <mrpt/utils/CImage.h>
17 #include <mrpt/slam/CMetricMap.h>
19 
20 #include <mrpt/maps/link_pragmas.h>
21 
22 namespace mrpt
23 {
24  namespace slam
25  {
26  using namespace mrpt;
27  using namespace mrpt::utils;
28 
29  class CObservation;
30 
31  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CReflectivityGridMap2D, CMetricMap, MAPS_IMPEXP )
32 
33  /** A 2D grid map representing the reflectivity of the environment (for example, measured with an IR proximity sensor).
34  *
35  * Important implemented features are:
36  * - Insertion of mrpt::slam::CObservationReflectivity observations.
37  * - Probability estimation of observations. See base class.
38  * - Rendering as 3D object: a 2D textured plane.
39  * - Automatic resizing of the map limits when inserting observations close to the border.
40  *
41  * Each cell contains the up-to-date average height from measured falling in that cell. Algorithms that can be used:
42  * - mrSimpleAverage: Each cell only stores the current average value.
43  * \ingroup mrpt_maps_grp
44  */
46  public CMetricMap,
47  public utils::CDynamicGrid<int8_t>,
48  public CLogOddsGridMap2D<int8_t>
49  {
50  // This must be added to any CSerializable derived class:
52 
53  protected:
54  static CLogOddsGridMapLUT<cell_t> m_logodd_lut; //!< Lookup tables for log-odds
55 
56  public:
57 
58  /** Calls the base CMetricMap::clear
59  * Declared here to avoid ambiguity between the two clear() in both base classes.
60  */
61  inline void clear() { CMetricMap::clear(); }
62 
63  float cell2float(const int8_t& c) const
64  {
65  return m_logodd_lut.l2p(c);
66  }
67 
68  /** Constructor
69  */
71  float x_min = -2,
72  float x_max = 2,
73  float y_min = -2,
74  float y_max = 2,
75  float resolution = 0.1
76  );
77 
78  /** Returns true if the map is empty/no observation has been inserted.
79  */
80  bool isEmpty() const;
81 
82  // See docs in base class
83  double computeObservationLikelihood( const CObservation *obs, const CPose3D &takenFrom );
84 
85  /** Parameters related with inserting observations into the map.
86  */
88  {
89  /** Default values loader:
90  */
92 
93  /** See utils::CLoadableOptions
94  */
95  void loadFromConfigFile(
96  const mrpt::utils::CConfigFileBase &source,
97  const std::string &section);
98 
99  /** See utils::CLoadableOptions
100  */
101  void dumpToTextStream(CStream &out) const;
102 
103  } insertionOptions;
104 
105  /** See docs in base class: in this class this always returns 0 */
106  float compute3DMatchingRatio(
107  const CMetricMap *otherMap,
108  const CPose3D &otherMapPose,
109  float maxDistForCorr = 0.10f,
110  float maxMahaDistForCorr = 2.0f
111  ) const;
112 
113  /** The implementation in this class just calls all the corresponding method of the contained metric maps.
114  */
115  void saveMetricMapRepresentationToFile(
116  const std::string &filNamePrefix
117  ) const;
118 
119  /** Returns a 3D object representing the map: by default, it will be a mrpt::opengl::CMesh object, unless
120  * it is specified otherwise in mrpt::
121  */
122  void getAs3DObject ( mrpt::opengl::CSetOfObjectsPtr &outObj ) const;
123 
124  /** Returns the grid as a 8-bit graylevel image, where each pixel is a cell (output image is RGB only if forceRGB is true)
125  */
126  void getAsImage( utils::CImage &img, bool verticalFlip = false, bool forceRGB=false) const;
127 
128  protected:
129 
130  /** Erase all the contents of the map
131  */
132  virtual void internal_clear();
133 
134  /** Insert the observation information into this map. This method must be implemented
135  * in derived classes.
136  * \param obs The observation
137  * \param robotPose The 3D pose of the robot mobile base in the map reference system, or NULL (default) if you want to use CPose2D(0,0,deg)
138  *
139  * \sa CObservation::insertObservationInto
140  */
141  virtual bool internal_insertObservation( const CObservation *obs, const CPose3D *robotPose = NULL );
142 
143  };
145 
146 
147  } // End of namespace
148 
149 
150 } // End of namespace
151 
152 #endif
void clear()
Erase all the contents of the map.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:97
float cell2float(const int8_t &c) const
The user must implement this in order to provide "saveToTextFile" a way to convert each cell into a n...
This class allows loading and storing values and vectors of different types from a configuration text...
Declares a virtual base class for all metric maps storage classes.
Definition: CMetricMap.h:83
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
A 2D grid of dynamic size which stores any kind of data at each cell.
Definition: CDynamicGrid.h:39
#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...
Declares a class that represents any robot's observation.
Definition: CObservation.h:52
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...
Parameters related with inserting observations into the map.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:69
A 2D grid map representing the reflectivity of the environment (for example, measured with an IR prox...
One static instance of this struct should exist in any class implementing CLogOddsGridMap2D to hold t...
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
A generic provider of log-odds grid-map maintainance functions.



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014