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
unsigned int getTreeDepth() const
GLdouble GLdouble z
Definition: glext.h:3872
void setClampingThresMax(double thresProb) override
double getProbMiss() const override
virtual ~CColouredOctoMap()
Destructor.
#define MAP_DEFINITION_START(_CLASS_NAME_)
Add a MAP_DEFINITION_START() ...
float getClampingThresMinLog() const override
double getProbHit() const override
double getClampingThresMin() const override
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...
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)...
virtual void internal_clear() override
Internal method called by clear()
void setClampingThresMin(double thresProb) override
unsigned char uint8_t
Definition: rptypes.h:41
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).
void setVoxelColourMethod(TColourUpdate new_method)
Set the method used to update voxels colour.
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)
virtual bool isEmpty() const override
Returns true if the map is empty/no observation has been inserted.
double getOccupancyThres() const override
GLubyte g
Definition: glext.h:6279
GLubyte GLubyte b
Definition: glext.h:6279
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.
TColourUpdate
This allows the user to select the desired method to update voxels colour.
void setProbMiss(double prob) override
void setProbHit(double prob) override
float getClampingThresMaxLog() const override
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void getMetricSize(double &x, double &y, double &z)
Size of OcTree (all known space) in meters for x, y and z dimension.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
TColourUpdate getVoxelColourMethod()
Get the method used to update voxels colour.
GLdouble GLdouble GLdouble r
Definition: glext.h:3705
bool internal_insertObservation(const mrpt::obs::CObservation *obs, const mrpt::poses::CPose3D *robotPose) override
Internal method called by insertObservation()
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
float getProbMissLog() const override
size_t calcNumNodes() const
Traverses the tree to calculate the total number of nodes.
GLenum GLint GLint y
Definition: glext.h:3538
float getOccupancyThresLog() const override
void getMetricMax(double &x, double &y, double &z)
maximum value of the bounding box of all known space in x, y, z
void setOccupancyThres(double prob) override
GLenum GLint x
Definition: glext.h:3538
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
virtual void getAsOctoMapVoxels(mrpt::opengl::COctoMapVoxels &gl_obj) const override
Builds a renderizable representation of the octomap as a mrpt::opengl::COctoMapVoxels object...
size_t getNumLeafNodes() const
Traverses the tree to calculate the total number of leaf nodes.
#define MAP_DEFINITION_END(_CLASS_NAME_)
void getMetricMin(double &x, double &y, double &z)
minimum value of the bounding box of all known space in x, y, z
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.
float getProbHitLog() const override
double getClampingThresMax() const override
CColouredOctoMap(const double resolution=0.10)
Default constructor.



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