Main MRPT website > C++ reference for MRPT 1.9.9
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-2018, 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 namespace octomap { class OcTree; }
21 namespace octomap { class OcTreeNode; }
22 
23 namespace mrpt
24 {
25 namespace maps
26 {
27 /** A three-dimensional probabilistic occupancy grid, implemented as an
28  * octo-tree with the "octomap" C++ library.
29  * This version only stores occupancy information at each octree node. See the
30  * base class mrpt::maps::COctoMapBase.
31  *
32  * \sa CMetricMap, the example in "MRPT/samples/octomap_simple"
33  * \ingroup mrpt_maps_grp
34  */
35 class COctoMap : public COctoMapBase<octomap::OcTree, octomap::OcTreeNode>
36 {
37  // This must be added to any CSerializable derived class:
39 
40  public:
41  COctoMap(const double resolution = 0.10); //!< Default constructor
42  virtual ~COctoMap(); //!< Destructor
43 
44  virtual void getAsOctoMapVoxels(
45  mrpt::opengl::COctoMapVoxels& gl_obj) const override;
46 
48  double resolution; //!< The finest resolution of the octomap (default: 0.10
49  //! meters)
50  mrpt::maps::COctoMap::TInsertionOptions
51  insertionOpts; //!< Observations insertion options
52  mrpt::maps::COctoMap::TLikelihoodOptions
53  likelihoodOpts; //!< Probabilistic observation likelihood options
55 
56  /** Returns true if the map is empty/no observation has been inserted */
57  virtual bool isEmpty() const override { return size() == 1; }
58  /** @name Direct access to octomap library methods
59  @{ */
60 
61  /** Just like insertPointCloud but with a single ray. */
62  void insertRay(
63  const float end_x, const float end_y, const float end_z,
64  const float sensor_x, const float sensor_y, const float sensor_z);
65  /** Manually updates the occupancy of the voxel at (x,y,z) as being occupied
66  * (true) or free (false), using the log-odds parameters in \a
67  * insertionOptions */
68  void updateVoxel(
69  const double x, const double y, const double z, bool occupied);
70  /** Check whether the given point lies within the volume covered by the
71  * octomap (that is, whether it is "mapped") */
73  const float x, const float y, const float z) const;
74  double getResolution() const;
75  unsigned int getTreeDepth() const;
76  /// \return The number of nodes in the tree
77  size_t size() const;
78  /// \return Memory usage of the complete octree in bytes (may vary between
79  /// architectures)
80  size_t memoryUsage() const;
81  /// \return Memory usage of the a single octree node
82  size_t memoryUsageNode() const;
83  /// \return Memory usage of a full grid of the same size as the OcTree in
84  /// bytes (for comparison)
85  size_t memoryFullGrid() const;
86  double volume();
87  /// Size of OcTree (all known space) in meters for x, y and z dimension
88  void getMetricSize(double& x, double& y, double& z);
89  /// Size of OcTree (all known space) in meters for x, y and z dimension
90  void getMetricSize(double& x, double& y, double& z) const;
91  /// minimum value of the bounding box of all known space in x, y, z
92  void getMetricMin(double& x, double& y, double& z);
93  /// minimum value of the bounding box of all known space in x, y, z
94  void getMetricMin(double& x, double& y, double& z) const;
95  /// maximum value of the bounding box of all known space in x, y, z
96  void getMetricMax(double& x, double& y, double& z);
97  /// maximum value of the bounding box of all known space in x, y, z
98  void getMetricMax(double& x, double& y, double& z) const;
99  /// Traverses the tree to calculate the total number of nodes
100  size_t calcNumNodes() const;
101  /// Traverses the tree to calculate the total number of leaf nodes
102  size_t getNumLeafNodes() const;
103 
104  void setOccupancyThres(double prob) override;
105  void setProbHit(double prob) override;
106  void setProbMiss(double prob) override;
107  void setClampingThresMin(double thresProb) override;
108  void setClampingThresMax(double thresProb) override;
109  double getOccupancyThres() const override;
110  float getOccupancyThresLog() const override;
111  double getProbHit() const override;
112  float getProbHitLog() const override;
113  double getProbMiss() const override;
114  float getProbMissLog() const override;
115  double getClampingThresMin() const override;
116  float getClampingThresMinLog() const override;
117  double getClampingThresMax() const override;
118  float getClampingThresMaxLog() const override;
119  /** @} */
120 
121  protected:
122  void internal_clear() override;
124  const mrpt::obs::CObservation* obs,
125  const mrpt::poses::CPose3D* robotPose) override;
126 }; // End of class def.
127 } // End of namespace
128 } // End of namespace
129 
130 #endif
void setClampingThresMax(double thresProb) override
Definition: COctoMap.cpp:390
GLdouble GLdouble z
Definition: glext.h:3872
double getOccupancyThres() const override
Definition: COctoMap.cpp:394
void getMetricSize(double &x, double &y, double &z)
Size of OcTree (all known space) in meters for x, y and z dimension.
Definition: COctoMap.cpp:342
bool internal_insertObservation(const mrpt::obs::CObservation *obs, const mrpt::poses::CPose3D *robotPose) override
Internal method called by insertObservation()
Definition: COctoMap.cpp:138
float getClampingThresMaxLog() const override
Definition: COctoMap.cpp:430
size_t memoryUsageNode() const
Definition: COctoMap.cpp:333
double getClampingThresMin() const override
Definition: COctoMap.cpp:418
double getProbHit() const override
Definition: COctoMap.cpp:402
void setProbHit(double prob) override
Definition: COctoMap.cpp:378
#define MAP_DEFINITION_START(_CLASS_NAME_)
Add a MAP_DEFINITION_START() ...
size_t memoryFullGrid() const
Definition: COctoMap.cpp:337
float getClampingThresMinLog() const override
Definition: COctoMap.cpp:422
float getOccupancyThresLog() const override
Definition: COctoMap.cpp:398
void setClampingThresMin(double thresProb) override
Definition: COctoMap.cpp:386
void getMetricMax(double &x, double &y, double &z)
maximum value of the bounding box of all known space in x, y, z
Definition: COctoMap.cpp:358
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
Definition: COctoMapBase.h:48
A flexible renderer of voxels, typically from a 3D octo map (see mrpt::maps::COctoMap).
double getClampingThresMax() const override
Definition: COctoMap.cpp:426
float getProbMissLog() const override
Definition: COctoMap.cpp:414
virtual void getAsOctoMapVoxels(mrpt::opengl::COctoMapVoxels &gl_obj) const override
Builds a renderizable representation of the octomap as a mrpt::opengl::COctoMapVoxels object...
Definition: COctoMap.cpp:156
void updateVoxel(const double x, const double y, const double z, bool occupied)
Manually updates the occupancy of the voxel at (x,y,z) as being occupied (true) or free (false)...
Definition: COctoMap.cpp:304
void getMetricMin(double &x, double &y, double &z)
minimum value of the bounding box of all known space in x, y, z
Definition: COctoMap.cpp:350
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)
Just like insertPointCloud but with a single ray.
Definition: COctoMap.cpp:294
void internal_clear() override
Internal method called by clear()
Definition: COctoMap.cpp:434
void setOccupancyThres(double prob) override
Definition: COctoMap.cpp:374
size_t getNumLeafNodes() const
Traverses the tree to calculate the total number of leaf nodes.
Definition: COctoMap.cpp:370
virtual ~COctoMap()
Destructor.
Definition: COctoMap.cpp:85
double getResolution() const
Definition: COctoMap.cpp:317
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
Definition: COctoMap.h:35
double getProbMiss() const override
Definition: COctoMap.cpp:410
bool isPointWithinOctoMap(const float x, const float y, const float z) const
Check whether the given point lies within the volume covered by the octomap (that is...
Definition: COctoMap.cpp:309
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...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
size_t size() const
Definition: COctoMap.cpp:325
void setProbMiss(double prob) override
Definition: COctoMap.cpp:382
GLenum GLint GLint y
Definition: glext.h:3538
size_t memoryUsage() const
Definition: COctoMap.cpp:329
size_t calcNumNodes() const
Traverses the tree to calculate the total number of nodes.
Definition: COctoMap.cpp:366
GLenum GLint x
Definition: glext.h:3538
virtual bool isEmpty() const override
Returns true if the map is empty/no observation has been inserted.
Definition: COctoMap.h:57
unsigned int getTreeDepth() const
Definition: COctoMap.cpp:321
#define MAP_DEFINITION_END(_CLASS_NAME_)
float getProbHitLog() const override
Definition: COctoMap.cpp:406
COctoMap(const double resolution=0.10)
Default constructor.
Definition: COctoMap.cpp:80



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019