Main MRPT website > C++ reference for MRPT 1.9.9
CColouredOctoMap.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_CColouredOctoMap_H
11 #define MRPT_CColouredOctoMap_H
12 
13 #include <mrpt/maps/COctoMapBase.h>
14 #include <mrpt/obs/obs_frwds.h>
15 
16 namespace octomap { class ColorOcTree; }
17 namespace octomap { class ColorOcTreeNode; }
18 
19 namespace mrpt
20 {
21 namespace maps
22 {
23 /** A three-dimensional probabilistic occupancy grid, implemented as an
24  * octo-tree with the "octomap" C++ library.
25  * This version stores both, occupancy information and RGB colour data at
26  * each octree node. See the base class mrpt::maps::COctoMapBase.
27  *
28  * \sa CMetricMap, the example in "MRPT/samples/octomap_simple"
29  * \ingroup mrpt_maps_grp
30  */
32  : public COctoMapBase<octomap::ColorOcTree, octomap::ColorOcTreeNode>
33 {
34  // This must be added to any CSerializable derived class:
36 
37  public:
38  CColouredOctoMap(const double resolution = 0.10); //!< Default constructor
39  virtual ~CColouredOctoMap(); //!< Destructor
40 
41  /** This allows the user to select the desired method to update voxels
42  colour.
43  SET = Set the colour of the voxel at (x,y,z) directly
44  AVERAGE = Set the colour of the voxel at (x,y,z) as the mean of
45  its previous colour and the new observed one.
46  INTEGRATE = Calculate the new colour of the voxel at (x,y,z) using
47  this formula: prev_color*node_prob + new_color*(0.99-node_prob)
48  If there isn't any previous color, any method is equivalent to
49  SET.
50  INTEGRATE is the default option*/
52  {
53  INTEGRATE = 0,
54  SET,
56  };
57 
58  /** Get the RGB colour of a point
59  * \return false if the point is not mapped, in which case the
60  * returned colour is undefined. */
61  bool getPointColour(
62  const float x, const float y, const float z, uint8_t& r, uint8_t& g,
63  uint8_t& b) const;
64 
65  /** Manually update the colour of the voxel at (x,y,z) */
66  void updateVoxelColour(
67  const double x, const double y, const double z, const uint8_t r,
68  const uint8_t g, const uint8_t b);
69 
70  /// Set the method used to update voxels colour
72  {
73  m_colour_method = new_method;
74  }
75 
76  /// Get the method used to update voxels colour
78  virtual void getAsOctoMapVoxels(
79  mrpt::opengl::COctoMapVoxels& gl_obj) const override;
80 
82  double resolution; //!< The finest resolution of the octomap (default: 0.10
83  //! meters)
84  mrpt::maps::CColouredOctoMap::TInsertionOptions
85  insertionOpts; //!< Observations insertion options
86  mrpt::maps::CColouredOctoMap::TLikelihoodOptions
87  likelihoodOpts; //!< Probabilistic observation likelihood options
89 
90  /** Returns true if the map is empty/no observation has been inserted */
91  virtual bool isEmpty() const override { return size() == 1; }
92  /** @name Direct access to octomap library methods
93  @{ */
94 
95  /** Just like insertPointCloud but with a single ray. */
96  void insertRay(
97  const float end_x, const float end_y, const float end_z,
98  const float sensor_x, const float sensor_y, const float sensor_z);
99  /** Manually updates the occupancy of the voxel at (x,y,z) as being occupied
100  * (true) or free (false), using the log-odds parameters in \a
101  * insertionOptions */
102  void updateVoxel(
103  const double x, const double y, const double z, bool occupied);
104  /** Check whether the given point lies within the volume covered by the
105  * octomap (that is, whether it is "mapped") */
107  const float x, const float y, const float z) const;
108  double getResolution() const;
109  unsigned int getTreeDepth() const;
110  /// \return The number of nodes in the tree
111  size_t size() const;
112  /// \return Memory usage of the complete octree in bytes (may vary between
113  /// architectures)
114  size_t memoryUsage() const;
115  /// \return Memory usage of the a single octree node
116  size_t memoryUsageNode() const;
117  /// \return Memory usage of a full grid of the same size as the OcTree in
118  /// bytes (for comparison)
119  size_t memoryFullGrid() const;
120  double volume();
121  /// Size of OcTree (all known space) in meters for x, y and z dimension
122  void getMetricSize(double& x, double& y, double& z);
123  /// Size of OcTree (all known space) in meters for x, y and z dimension
124  void getMetricSize(double& x, double& y, double& z) const;
125  /// minimum value of the bounding box of all known space in x, y, z
126  void getMetricMin(double& x, double& y, double& z);
127  /// minimum value of the bounding box of all known space in x, y, z
128  void getMetricMin(double& x, double& y, double& z) const;
129  /// maximum value of the bounding box of all known space in x, y, z
130  void getMetricMax(double& x, double& y, double& z);
131  /// maximum value of the bounding box of all known space in x, y, z
132  void getMetricMax(double& x, double& y, double& z) const;
133  /// Traverses the tree to calculate the total number of nodes
134  size_t calcNumNodes() const;
135  /// Traverses the tree to calculate the total number of leaf nodes
136  size_t getNumLeafNodes() const;
137 
138  void setOccupancyThres(double prob) override;
139  void setProbHit(double prob) override;
140  void setProbMiss(double prob) override;
141  void setClampingThresMin(double thresProb) override;
142  void setClampingThresMax(double thresProb) override;
143  double getOccupancyThres() const override;
144  float getOccupancyThresLog() const override;
145  double getProbHit() const override;
146  float getProbHitLog() const override;
147  double getProbMiss() const override;
148  float getProbMissLog() const override;
149  double getClampingThresMin() const override;
150  float getClampingThresMinLog() const override;
151  double getClampingThresMax() const override;
152  float getClampingThresMaxLog() const override;
153  /** @} */
154 
155  protected:
156  virtual void internal_clear() override;
157 
159  const mrpt::obs::CObservation* obs,
160  const mrpt::poses::CPose3D* robotPose) override;
161 
162  TColourUpdate m_colour_method; //! Method used to updated voxels colour.
163 
164 }; // End of class def.
165 } // End of namespace
166 } // End of namespace
167 #endif
mrpt::maps::CColouredOctoMap::setProbMiss
void setProbMiss(double prob) override
Definition: CColouredOctoMap.cpp:516
mrpt::maps::CColouredOctoMap::internal_insertObservation
bool internal_insertObservation(const mrpt::obs::CObservation *obs, const mrpt::poses::CPose3D *robotPose) override
Internal method called by insertObservation()
Definition: CColouredOctoMap.cpp:150
mrpt::maps::CColouredOctoMap::getClampingThresMaxLog
float getClampingThresMaxLog() const override
Definition: CColouredOctoMap.cpp:564
mrpt::maps::CColouredOctoMap::getMetricMax
void getMetricMax(double &x, double &y, double &z)
maximum value of the bounding box of all known space in x, y, z
Definition: CColouredOctoMap.cpp:492
mrpt::maps::CColouredOctoMap::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: CColouredOctoMap.cpp:435
mrpt::maps::CColouredOctoMap::volume
double volume()
Definition: CColouredOctoMap.cpp:472
mrpt::maps::CColouredOctoMap::memoryUsage
size_t memoryUsage() const
Definition: CColouredOctoMap.cpp:460
mrpt::maps::CColouredOctoMap::getMetricSize
void getMetricSize(double &x, double &y, double &z)
Size of OcTree (all known space) in meters for x, y and z dimension.
Definition: CColouredOctoMap.cpp:476
mrpt::maps::CColouredOctoMap::memoryUsageNode
size_t memoryUsageNode() const
Definition: CColouredOctoMap.cpp:464
mrpt::maps::CColouredOctoMap::getOccupancyThres
double getOccupancyThres() const override
Definition: CColouredOctoMap.cpp:528
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
g
GLubyte g
Definition: glext.h:6279
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
mrpt::maps::CColouredOctoMap::getOccupancyThresLog
float getOccupancyThresLog() const override
Definition: CColouredOctoMap.cpp:532
mrpt::maps::CColouredOctoMap::getClampingThresMax
double getClampingThresMax() const override
Definition: CColouredOctoMap.cpp:560
mrpt::maps::CColouredOctoMap::calcNumNodes
size_t calcNumNodes() const
Traverses the tree to calculate the total number of nodes.
Definition: CColouredOctoMap.cpp:500
COctoMapBase.h
mrpt::maps::CColouredOctoMap::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: CColouredOctoMap.cpp:425
mrpt::maps::CColouredOctoMap::SET
@ SET
Definition: CColouredOctoMap.h:54
mrpt::maps::CColouredOctoMap::getNumLeafNodes
size_t getNumLeafNodes() const
Traverses the tree to calculate the total number of leaf nodes.
Definition: CColouredOctoMap.cpp:504
mrpt::maps::COctoMapBase
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
Definition: COctoMapBase.h:48
r
GLdouble GLdouble GLdouble r
Definition: glext.h:3705
mrpt::maps::CColouredOctoMap::getProbHitLog
float getProbHitLog() const override
Definition: CColouredOctoMap.cpp:540
mrpt::maps::CColouredOctoMap::setClampingThresMax
void setClampingThresMax(double thresProb) override
Definition: CColouredOctoMap.cpp:524
mrpt::maps::CColouredOctoMap::getMetricMin
void getMetricMin(double &x, double &y, double &z)
minimum value of the bounding box of all known space in x, y, z
Definition: CColouredOctoMap.cpp:484
mrpt::maps::CColouredOctoMap::getResolution
double getResolution() const
Definition: CColouredOctoMap.cpp:448
mrpt::maps::CColouredOctoMap::getTreeDepth
unsigned int getTreeDepth() const
Definition: CColouredOctoMap.cpp:452
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
b
GLubyte GLubyte b
Definition: glext.h:6279
mrpt::maps::CColouredOctoMap::CColouredOctoMap
CColouredOctoMap(const double resolution=0.10)
Default constructor.
Definition: CColouredOctoMap.cpp:87
mrpt::maps::CColouredOctoMap::getVoxelColourMethod
TColourUpdate getVoxelColourMethod()
Get the method used to update voxels colour.
Definition: CColouredOctoMap.h:77
mrpt::maps::CColouredOctoMap::updateVoxelColour
void updateVoxelColour(const double x, const double y, const double z, const uint8_t r, const uint8_t g, const uint8_t b)
Manually update the colour of the voxel at (x,y,z)
Definition: CColouredOctoMap.cpp:312
obs_frwds.h
mrpt::maps::CColouredOctoMap::getProbHit
double getProbHit() const override
Definition: CColouredOctoMap.cpp:536
mrpt::maps::CColouredOctoMap::getClampingThresMinLog
float getClampingThresMinLog() const override
Definition: CColouredOctoMap.cpp:556
mrpt::maps::CColouredOctoMap::~CColouredOctoMap
virtual ~CColouredOctoMap()
Destructor.
Definition: CColouredOctoMap.cpp:93
mrpt::maps::CColouredOctoMap
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
Definition: CColouredOctoMap.h:31
mrpt::maps::CColouredOctoMap::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: CColouredOctoMap.cpp:337
mrpt::maps::CColouredOctoMap::m_colour_method
TColourUpdate m_colour_method
Definition: CColouredOctoMap.h:162
mrpt::opengl::COctoMapVoxels
A flexible renderer of voxels, typically from a 3D octo map (see mrpt::maps::COctoMap).
Definition: COctoMapVoxels.h:69
MAP_DEFINITION_START
#define MAP_DEFINITION_START(_CLASS_NAME_)
Add a MAP_DEFINITION_START() ...
Definition: TMetricMapTypesRegistry.h:57
mrpt::maps::CColouredOctoMap::isEmpty
virtual bool isEmpty() const override
Returns true if the map is empty/no observation has been inserted.
Definition: CColouredOctoMap.h:91
mrpt::maps::CColouredOctoMap::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: CColouredOctoMap.cpp:440
mrpt::maps::CColouredOctoMap::setOccupancyThres
void setOccupancyThres(double prob) override
Definition: CColouredOctoMap.cpp:508
MAP_DEFINITION_END
#define MAP_DEFINITION_END(_CLASS_NAME_)
Definition: TMetricMapTypesRegistry.h:67
mrpt::maps::CColouredOctoMap::setProbHit
void setProbHit(double prob) override
Definition: CColouredOctoMap.cpp:512
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::CColouredOctoMap::size
size_t size() const
Definition: CColouredOctoMap.cpp:456
mrpt::maps::CColouredOctoMap::memoryFullGrid
size_t memoryFullGrid() const
Definition: CColouredOctoMap.cpp:468
mrpt::obs::CObservation
Declares a class that represents any robot's observation.
Definition: CObservation.h:43
z
GLdouble GLdouble z
Definition: glext.h:3872
octomap
Definition: CColouredOctoMap.h:16
mrpt::maps::CColouredOctoMap::internal_clear
virtual void internal_clear() override
Internal method called by clear()
Definition: CColouredOctoMap.cpp:568
mrpt::maps::CColouredOctoMap::INTEGRATE
@ INTEGRATE
Definition: CColouredOctoMap.h:53
mrpt::maps::CColouredOctoMap::setVoxelColourMethod
void setVoxelColourMethod(TColourUpdate new_method)
Set the method used to update voxels colour.
Definition: CColouredOctoMap.h:71
mrpt::maps::CColouredOctoMap::getPointColour
bool getPointColour(const float x, const float y, const float z, uint8_t &r, uint8_t &g, uint8_t &b) const
Get the RGB colour of a point.
Definition: CColouredOctoMap.cpp:289
y
GLenum GLint GLint y
Definition: glext.h:3538
mrpt::maps::CColouredOctoMap::AVERAGE
@ AVERAGE
Definition: CColouredOctoMap.h:55
mrpt::maps::CColouredOctoMap::setClampingThresMin
void setClampingThresMin(double thresProb) override
Definition: CColouredOctoMap.cpp:520
x
GLenum GLint x
Definition: glext.h:3538
mrpt::maps::CColouredOctoMap::TColourUpdate
TColourUpdate
This allows the user to select the desired method to update voxels colour.
Definition: CColouredOctoMap.h:51
mrpt::maps::CColouredOctoMap::getProbMiss
double getProbMiss() const override
Definition: CColouredOctoMap.cpp:544
mrpt::maps::CColouredOctoMap::getClampingThresMin
double getClampingThresMin() const override
Definition: CColouredOctoMap.cpp:552
mrpt::maps::CColouredOctoMap::getProbMissLog
float getProbMissLog() const override
Definition: CColouredOctoMap.cpp:548



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