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
mrpt::maps::COctoMap::getOccupancyThres
double getOccupancyThres() const override
Definition: COctoMap.cpp:394
mrpt::maps::COctoMap::internal_insertObservation
bool internal_insertObservation(const mrpt::obs::CObservation *obs, const mrpt::poses::CPose3D *robotPose) override
Internal method called by insertObservation()
Definition: COctoMap.cpp:138
mrpt::maps::COctoMap::getClampingThresMaxLog
float getClampingThresMaxLog() const override
Definition: COctoMap.cpp:430
mrpt::maps::COctoMap::getProbMiss
double getProbMiss() const override
Definition: COctoMap.cpp:410
mrpt::maps::COctoMap::isPointWithinOctoMap
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
mrpt::maps::COctoMap::setClampingThresMax
void setClampingThresMax(double thresProb) override
Definition: COctoMap.cpp:390
mrpt::maps::COctoMap::internal_clear
void internal_clear() override
Internal method called by clear()
Definition: COctoMap.cpp:434
mrpt::maps::COctoMap::setOccupancyThres
void setOccupancyThres(double prob) override
Definition: COctoMap.cpp:374
mrpt::maps::COctoMap::volume
double volume()
Definition: COctoMap.cpp:341
mrpt::maps::COctoMap::insertRay
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
mrpt::maps::COctoMap::getProbHit
double getProbHit() const override
Definition: COctoMap.cpp:402
mrpt::maps::COctoMap::~COctoMap
virtual ~COctoMap()
Destructor.
Definition: COctoMap.cpp:85
mrpt::maps::COctoMap::getMetricMax
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
mrpt::maps::COctoMap::setProbMiss
void setProbMiss(double prob) override
Definition: COctoMap.cpp:382
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::maps::COctoMap::getProbMissLog
float getProbMissLog() const override
Definition: COctoMap.cpp:414
COctoMapBase.h
mrpt::maps::COctoMap::getMetricSize
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
mrpt::maps::COctoMap::getTreeDepth
unsigned int getTreeDepth() const
Definition: COctoMap.cpp:321
CMetricMap.h
mrpt::maps::COctoMapBase
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
Definition: COctoMapBase.h:48
mrpt::maps::COctoMap::COctoMap
COctoMap(const double resolution=0.10)
Default constructor.
Definition: COctoMap.cpp:80
mrpt::maps::COctoMap::setProbHit
void setProbHit(double prob) override
Definition: COctoMap.cpp:378
mrpt::maps::COctoMap::memoryFullGrid
size_t memoryFullGrid() const
Definition: COctoMap.cpp:337
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::maps::COctoMap::getOccupancyThresLog
float getOccupancyThresLog() const override
Definition: COctoMap.cpp:398
obs_frwds.h
mrpt::maps::COctoMap::isEmpty
virtual bool isEmpty() const override
Returns true if the map is empty/no observation has been inserted.
Definition: COctoMap.h:57
mrpt::maps::COctoMap::memoryUsageNode
size_t memoryUsageNode() const
Definition: COctoMap.cpp:333
mrpt::maps::COctoMap::getClampingThresMin
double getClampingThresMin() const override
Definition: COctoMap.cpp:418
mrpt::maps::COctoMap::getProbHitLog
float getProbHitLog() const override
Definition: COctoMap.cpp:406
mrpt::maps::COctoMap::getClampingThresMax
double getClampingThresMax() const override
Definition: COctoMap.cpp:426
mrpt::maps::COctoMap::getMetricMin
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
mrpt::opengl::COctoMapVoxels
A flexible renderer of voxels, typically from a 3D octo map (see mrpt::maps::COctoMap).
Definition: COctoMapVoxels.h:69
mrpt::maps::COctoMap::size
size_t size() const
Definition: COctoMap.cpp:325
mrpt::maps::COctoMap
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
Definition: COctoMap.h:35
MAP_DEFINITION_START
#define MAP_DEFINITION_START(_CLASS_NAME_)
Add a MAP_DEFINITION_START() ...
Definition: TMetricMapTypesRegistry.h:57
mrpt::maps::COctoMap::getAsOctoMapVoxels
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
safe_pointers.h
mrpt::maps::COctoMap::getClampingThresMinLog
float getClampingThresMinLog() const override
Definition: COctoMap.cpp:422
CLoadableOptions.h
MAP_DEFINITION_END
#define MAP_DEFINITION_END(_CLASS_NAME_)
Definition: TMetricMapTypesRegistry.h:67
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::maps::COctoMap::getNumLeafNodes
size_t getNumLeafNodes() const
Traverses the tree to calculate the total number of leaf nodes.
Definition: COctoMap.cpp:370
mrpt::maps::COctoMap::getResolution
double getResolution() const
Definition: COctoMap.cpp:317
mrpt::obs::CObservation
Declares a class that represents any robot's observation.
Definition: CObservation.h:43
mrpt::maps::COctoMap::setClampingThresMin
void setClampingThresMin(double thresProb) override
Definition: COctoMap.cpp:386
z
GLdouble GLdouble z
Definition: glext.h:3872
octomap
Definition: CColouredOctoMap.h:16
mrpt::maps::COctoMap::memoryUsage
size_t memoryUsage() const
Definition: COctoMap.cpp:329
mrpt::maps::COctoMap::calcNumNodes
size_t calcNumNodes() const
Traverses the tree to calculate the total number of nodes.
Definition: COctoMap.cpp:366
mrpt::maps::COctoMap::updateVoxel
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
y
GLenum GLint GLint y
Definition: glext.h:3538
x
GLenum GLint x
Definition: glext.h:3538



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST