Main MRPT website > C++ reference for MRPT 1.5.6
maps/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-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_CColouredOctoMap_H
11 #define MRPT_CColouredOctoMap_H
12 
13 #include <mrpt/maps/COctoMapBase.h>
14 #include <mrpt/obs/obs_frwds.h>
15 
16 #include <mrpt/maps/link_pragmas.h>
17 
18 PIMPL_FORWARD_DECLARATION(namespace octomap { class ColorOcTree; })
19 PIMPL_FORWARD_DECLARATION(namespace octomap { class ColorOcTreeNode; })
20 
21 namespace mrpt
22 {
23  namespace maps
24  {
25  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CColouredOctoMap , CMetricMap, MAPS_IMPEXP )
26 
27  /** A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ library.
28  * This version stores both, occupancy information and RGB colour data at each octree node. See the base class mrpt::maps::COctoMapBase.
29  *
30  * \sa CMetricMap, the example in "MRPT/samples/octomap_simple"
31  * \ingroup mrpt_maps_grp
32  */
33  class MAPS_IMPEXP CColouredOctoMap : public COctoMapBase<octomap::ColorOcTree,octomap::ColorOcTreeNode>
34  {
35  // This must be added to any CSerializable derived class:
37 
38  public:
39  CColouredOctoMap(const double resolution=0.10); //!< Default constructor
40  virtual ~CColouredOctoMap(); //!< Destructor
41 
42  /** This allows the user to select the desired method to update voxels 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 its previous colour and the new observed one.
45  INTEGRATE = Calculate the new colour of the voxel at (x,y,z) using this formula: prev_color*node_prob + new_color*(0.99-node_prob)
46  If there isn't any previous color, any method is equivalent to SET.
47  INTEGRATE is the default option*/
49  {
50  INTEGRATE = 0,
51  SET,
52  AVERAGE
53  };
54 
55  /** Get the RGB colour of a point
56  * \return false if the point is not mapped, in which case the returned colour is undefined. */
57  bool getPointColour(const float x, const float y, const float z, uint8_t& r, uint8_t& g, uint8_t& b) const;
58 
59  /** Manually update the colour of the voxel at (x,y,z) */
60  void updateVoxelColour(const double x, const double y, const double z, const uint8_t r, const uint8_t g, const uint8_t b);
61 
62  ///Set the method used to update voxels colour
63  void setVoxelColourMethod(TColourUpdate new_method) {m_colour_method = new_method;}
64 
65  ///Get the method used to update voxels colour
66  TColourUpdate getVoxelColourMethod() {return m_colour_method;}
67 
68  virtual void getAsOctoMapVoxels(mrpt::opengl::COctoMapVoxels &gl_obj) const MRPT_OVERRIDE;
69 
71  double resolution; //!< The finest resolution of the octomap (default: 0.10 meters)
72  mrpt::maps::CColouredOctoMap::TInsertionOptions insertionOpts; //!< Observations insertion options
73  mrpt::maps::CColouredOctoMap::TLikelihoodOptions likelihoodOpts; //!< Probabilistic observation likelihood options
75 
76  /** Returns true if the map is empty/no observation has been inserted */
77  virtual bool isEmpty() const MRPT_OVERRIDE { return size() == 1; }
78 
79  /** @name Direct access to octomap library methods
80  @{ */
81 
82  /** Just like insertPointCloud but with a single ray. */
83  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);
84  /** 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 */
85  void updateVoxel(const double x, const double y, const double z, bool occupied);
86  /** Check whether the given point lies within the volume covered by the octomap (that is, whether it is "mapped") */
87  bool isPointWithinOctoMap(const float x, const float y, const float z) const;
88  double getResolution() const;
89  unsigned int getTreeDepth() const;
90  /// \return The number of nodes in the tree
91  size_t size() const;
92  /// \return Memory usage of the complete octree in bytes (may vary between architectures)
93  size_t memoryUsage() const;
94  /// \return Memory usage of the a single octree node
95  size_t memoryUsageNode() const;
96  /// \return Memory usage of a full grid of the same size as the OcTree in bytes (for comparison)
97  size_t memoryFullGrid() const;
98  double volume();
99  /// Size of OcTree (all known space) in meters for x, y and z dimension
100  void getMetricSize(double& x, double& y, double& z);
101  /// Size of OcTree (all known space) in meters for x, y and z dimension
102  void getMetricSize(double& x, double& y, double& z) const;
103  /// minimum value of the bounding box of all known space in x, y, z
104  void getMetricMin(double& x, double& y, double& z);
105  /// minimum value of the bounding box of all known space in x, y, z
106  void getMetricMin(double& x, double& y, double& z) const;
107  /// maximum value of the bounding box of all known space in x, y, z
108  void getMetricMax(double& x, double& y, double& z);
109  /// maximum value of the bounding box of all known space in x, y, z
110  void getMetricMax(double& x, double& y, double& z) const;
111  /// Traverses the tree to calculate the total number of nodes
112  size_t calcNumNodes() const;
113  /// Traverses the tree to calculate the total number of leaf nodes
114  size_t getNumLeafNodes() const;
115 
116  void setOccupancyThres(double prob) MRPT_OVERRIDE;
117  void setProbHit(double prob) MRPT_OVERRIDE;
118  void setProbMiss(double prob) MRPT_OVERRIDE;
119  void setClampingThresMin(double thresProb) MRPT_OVERRIDE;
120  void setClampingThresMax(double thresProb) MRPT_OVERRIDE;
121  double getOccupancyThres() const MRPT_OVERRIDE;
122  float getOccupancyThresLog() const MRPT_OVERRIDE;
123  double getProbHit() const MRPT_OVERRIDE;
124  float getProbHitLog() const MRPT_OVERRIDE;
125  double getProbMiss() const MRPT_OVERRIDE;
126  float getProbMissLog() const MRPT_OVERRIDE;
127  double getClampingThresMin() const MRPT_OVERRIDE;
128  float getClampingThresMinLog() const MRPT_OVERRIDE;
129  double getClampingThresMax() const MRPT_OVERRIDE;
130  float getClampingThresMaxLog() const MRPT_OVERRIDE;
131  /** @} */
132 
133  protected:
134  virtual void internal_clear() MRPT_OVERRIDE;
135 
136  bool internal_insertObservation(const mrpt::obs::CObservation *obs,const mrpt::poses::CPose3D *robotPose) MRPT_OVERRIDE;
137 
138  TColourUpdate m_colour_method; //!Method used to updated voxels colour.
139 
140  }; // End of class def.
142 
143  } // End of namespace
144 
145 } // End of namespace
146 
147 #endif
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1166
#define MAP_DEFINITION_END(_CLASS_NAME_, _LINKAGE_)
GLboolean GLboolean g
Definition: glew.h:5406
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
unsigned char uint8_t
Definition: rptypes.h:43
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...
void setVoxelColourMethod(TColourUpdate new_method)
Set the method used to update voxels colour.
GLint GLint GLint GLint GLint x
Definition: glew.h:1166
TColourUpdate
This allows the user to select the desired method to update voxels colour.
GLsizeiptr size
Definition: glew.h:1586
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
GLdouble GLdouble z
Definition: glew.h:1464
TColourUpdate getVoxelColourMethod()
Get the method used to update voxels colour.
Declares a virtual base class for all metric maps storage classes.
GLdouble GLdouble GLdouble r
Definition: glew.h:1311
#define PIMPL_FORWARD_DECLARATION(_TYPE)
Definition: pimpl.h:47
GLdouble GLdouble GLdouble b
Definition: glew.h:5092
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
#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.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018