Main MRPT website > C++ reference for MRPT 1.5.7
maps/COctoMap.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 
10 #ifndef MRPT_COctoMap_H
11 #define MRPT_COctoMap_H
12 
13 #include <mrpt/maps/COctoMapBase.h>
14 
15 #include <mrpt/maps/CMetricMap.h>
18 #include <mrpt/obs/obs_frwds.h>
19 
20 #include <mrpt/maps/link_pragmas.h>
21 
22 PIMPL_FORWARD_DECLARATION(namespace octomap { class OcTree; })
23 PIMPL_FORWARD_DECLARATION(namespace octomap { class OcTreeNode; })
24 
25 namespace mrpt
26 {
27  namespace maps
28  {
30 
31  /** A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ library.
32  * This version only stores occupancy information at each octree node. See the base class mrpt::maps::COctoMapBase.
33  *
34  * \sa CMetricMap, the example in "MRPT/samples/octomap_simple"
35  * \ingroup mrpt_maps_grp
36  */
37  class MAPS_IMPEXP COctoMap : public COctoMapBase<octomap::OcTree,octomap::OcTreeNode>
38  {
39  // This must be added to any CSerializable derived class:
41 
42  public:
43  COctoMap(const double resolution=0.10); //!< Default constructor
44  virtual ~COctoMap(); //!< Destructor
45 
46  virtual void getAsOctoMapVoxels(mrpt::opengl::COctoMapVoxels &gl_obj) const MRPT_OVERRIDE;
47 
49  double resolution; //!< The finest resolution of the octomap (default: 0.10 meters)
50  mrpt::maps::COctoMap::TInsertionOptions insertionOpts; //!< Observations insertion options
51  mrpt::maps::COctoMap::TLikelihoodOptions likelihoodOpts; //!< Probabilistic observation likelihood options
53 
54  /** Returns true if the map is empty/no observation has been inserted */
55  virtual bool isEmpty() const MRPT_OVERRIDE { return size() == 1; }
56 
57  /** @name Direct access to octomap library methods
58  @{ */
59 
60  /** Just like insertPointCloud but with a single ray. */
61  void insertRay(const float end_x, const float end_y, const float end_z, const float sensor_x, const float sensor_y, const float sensor_z);
62  /** Manually updates the occupancy of the voxel at (x,y,z) as being occupied (true) or free (false), using the log-odds parameters in \a insertionOptions */
63  void updateVoxel(const double x, const double y, const double z, bool occupied);
64  /** Check whether the given point lies within the volume covered by the octomap (that is, whether it is "mapped") */
65  bool isPointWithinOctoMap(const float x, const float y, const float z) const;
66  double getResolution() const;
67  unsigned int getTreeDepth() const;
68  /// \return The number of nodes in the tree
69  size_t size() const;
70  /// \return Memory usage of the complete octree in bytes (may vary between architectures)
71  size_t memoryUsage() const;
72  /// \return Memory usage of the a single octree node
73  size_t memoryUsageNode() const;
74  /// \return Memory usage of a full grid of the same size as the OcTree in bytes (for comparison)
75  size_t memoryFullGrid() const;
76  double volume();
77  /// Size of OcTree (all known space) in meters for x, y and z dimension
78  void getMetricSize(double& x, double& y, double& z);
79  /// Size of OcTree (all known space) in meters for x, y and z dimension
80  void getMetricSize(double& x, double& y, double& z) const;
81  /// minimum value of the bounding box of all known space in x, y, z
82  void getMetricMin(double& x, double& y, double& z);
83  /// minimum value of the bounding box of all known space in x, y, z
84  void getMetricMin(double& x, double& y, double& z) const;
85  /// maximum value of the bounding box of all known space in x, y, z
86  void getMetricMax(double& x, double& y, double& z);
87  /// maximum value of the bounding box of all known space in x, y, z
88  void getMetricMax(double& x, double& y, double& z) const;
89  /// Traverses the tree to calculate the total number of nodes
90  size_t calcNumNodes() const;
91  /// Traverses the tree to calculate the total number of leaf nodes
92  size_t getNumLeafNodes() const;
93 
94  void setOccupancyThres(double prob) MRPT_OVERRIDE;
95  void setProbHit(double prob) MRPT_OVERRIDE;
96  void setProbMiss(double prob) MRPT_OVERRIDE;
97  void setClampingThresMin(double thresProb) MRPT_OVERRIDE;
98  void setClampingThresMax(double thresProb) MRPT_OVERRIDE;
99  double getOccupancyThres() const MRPT_OVERRIDE;
100  float getOccupancyThresLog() const MRPT_OVERRIDE;
101  double getProbHit() const MRPT_OVERRIDE;
102  float getProbHitLog() const MRPT_OVERRIDE;
103  double getProbMiss() const MRPT_OVERRIDE;
104  float getProbMissLog() const MRPT_OVERRIDE;
105  double getClampingThresMin() const MRPT_OVERRIDE;
106  float getClampingThresMinLog() const MRPT_OVERRIDE;
107  double getClampingThresMax() const MRPT_OVERRIDE;
108  float getClampingThresMaxLog() const MRPT_OVERRIDE;
109  /** @} */
110 
111  protected:
112  void internal_clear() MRPT_OVERRIDE;
113  bool internal_insertObservation(const mrpt::obs::CObservation *obs,const mrpt::poses::CPose3D *robotPose) MRPT_OVERRIDE;
114  }; // End of class def.
116  } // End of namespace
117 
118 } // End of namespace
119 
120 #endif
#define MAP_DEFINITION_END(_CLASS_NAME_, _LINKAGE_)
GLdouble GLdouble z
Definition: glext.h:3734
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
A flexible renderer of voxels, typically from a 3D octo map (see mrpt::maps::COctoMap).
#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...
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
Definition: maps/COctoMap.h:37
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...
Declares a virtual base class for all metric maps storage classes.
#define PIMPL_FORWARD_DECLARATION(_TYPE)
Definition: pimpl.h:47
GLenum GLint GLint y
Definition: glext.h:3516
GLsizeiptr size
Definition: glext.h:3779
GLenum GLint x
Definition: glext.h:3516
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
#define MAP_DEFINITION_START(_CLASS_NAME_, _LINKAGE_)
Add a MAP_DEFINITION_START() ...



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019