Main MRPT website > C++ reference for MRPT 1.9.9
PbMapMaker.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 /* Plane-based Map (PbMap) library
11  * Construction of plane-based maps and localization in it from RGBD Images.
12  * Writen by Eduardo Fernandez-Moral. See docs for <a
13  * href="group__mrpt__pbmap__grp.html" >mrpt-pbmap</a>
14  */
15 
16 #ifndef __PBMAPMAKER_H
17 #define __PBMAPMAKER_H
18 
19 #include <mrpt/config.h>
20 
21 #if MRPT_HAS_PCL
22 
23 #include <mrpt/utils/utils_defs.h>
24 #include <pcl/visualization/cloud_viewer.h>
25 #include <pcl/visualization/pcl_visualizer.h>
26 #include <mrpt/pbmap/Plane.h>
28 #include <mrpt/pbmap/PbMap.h>
31 #include <set>
32 
33 typedef pcl::PointXYZRGBA PointT;
34 
35 namespace mrpt
36 {
37 namespace pbmap
38 {
39 /*!frameRGBDandPose stores a dupla containing a pointCloud (built from a RGBD
40  * frame) and a pose.
41  * \ingroup mrpt_pbmap_grp
42  */
44 {
45  pcl::PointCloud<PointT>::Ptr cloudPtr;
46  Eigen::Matrix4f pose;
47 };
48 
49 /*! This class construct the PbMap extracting planar segments from Range images,
50  * which pose must be also provided.
51  * The range images and their poses are communicated with the object
52  * frameQueue.
53  * PbMapMaker run its own thread, which is created at initialization.
54  *
55  * \ingroup mrpt_pbmap_grp
56  */
58 {
59  public:
60  /*!PbMapMaker's constructor sets some threshold for plane segmentation and
61  map growing from a configuration file (or default).
62  This constructor also starts PbMapMaker's own thread.*/
63  PbMapMaker(const std::string& config_file);
64 
65  /*!PbMapMaker's destructor is used to save some debugging info to file.*/
66  ~PbMapMaker();
67 
68  /*!Get the PbMap.*/
69  PbMap getPbMap() { return mPbMap; };
70  /*!Serialize the PbMap.*/
71  void serializePbMap(std::string path);
72 
73  /*!frameQueue is a vector containing the frameRGBDandPose (range image +
74  * pose) to be processed.*/
75  std::vector<frameRGBDandPose> frameQueue;
76 
77  /*!observedPlanes is a list containing the current observed planes.*/
78  std::set<unsigned> sQueueObservedPlanes;
79 
80  /*!PCL viewer. It runs in a different thread.*/
81  pcl::visualization::CloudViewer cloudViewer;
82 
83  private:
84  /*!Find planar patches in the input organised point cloud
85  "pointCloudPtr_arg", and update the PbMap with them (it update previous
86  planes and
87  initialize new ones when they are first observed), the input pose "poseInv"
88  is used to place the current observations into a common frame of
89  reference. Different thresholds are used to control the plane segmentation:
90  - "distThreshold" defines the maximum distance of an inlier to the plane
91  - "angleThreshold" defines the maximum angle between an inlier's normal and
92  the plane's normal
93  - "minInliersF" defines the minimum number of inliers as a fraction of the
94  total number of points in the input cloud
95  */
96  void detectPlanesCloud(
97  pcl::PointCloud<PointT>::Ptr& pointCloudPtr_arg,
98  Eigen::Matrix4f& poseKF, double distThreshold, double angleThreshold,
99  double minInliersF);
100 
101  /*!Returns true when the closest distance between the patches "plane1" and
102  * "plane2" is under distThreshold.*/
103  bool arePlanesNearby(
104  Plane& plane1, Plane& plane2, const float distThreshold);
105 
106  /*!Check for new graph connections of the input plane. These connections are
107  stablished when the minimum distance between two patches is under
108  the input threshold "proximity"*/
109  void checkProximity(Plane& plane, float proximity);
110 
111  /*! Returns true if the two input planes represent the same physical surface
112  * for some given angle and distance thresholds.
113  * If the planes are the same they are merged in this and the function
114  * returns true. Otherwise it returns false.*/
115  bool areSamePlane(
116  Plane& plane1, Plane& plane2, const float& cosAngleThreshold,
117  const float& distThreshold, const float& proxThreshold);
118 
119  /*! Merge the two input patches into "updatePlane".
120  * Recalculate center, normal vector, area, inlier points (filtered),
121  * convex hull, etc.
122  */
123  void mergePlanes(Plane& updatePlane, Plane& discardPlane);
124 
125  /*!File containing some paramteres and heuristic thresholds"*/
127 
128  /*!Object to detect previous places.*/
130 
131  /*!Object to cluster set of planes according to their co-visibility.*/
133 
134  boost::mutex mtx_pbmap_busy;
135 
136  protected:
137  /*!The current PbMap.*/
139 
140  /*!List of planes observed in that last frame introduced.*/
141  std::set<unsigned> observedPlanes;
142 
143  /*!Object to infer some knowledge in the map planes.*/
145 
146  /*!PCL visualizer callback*/
147  void viz_cb(pcl::visualization::PCLVisualizer& viz);
148 
149  /*!This executes the PbMapMaker's thread*/
150  void run();
151 
152  /*!PbMapMaker's thread handle*/
153  std::thread pbmaker_hd;
154 
155  /*!PbMapMaker's exit thread*/
156  bool stop_pbMapMaker();
157 
158  /*!PbMapMaker's stop controller*/
160 
161  /*!PbMapMaker's stop var*/
163 
164  // Color paper
165  void watchProperties(
166  std::set<unsigned>& observedPlanes, Plane& observedPlane);
167  void saveInfoFiles();
168  // Unary
177 };
178 }
179 } // End of namespaces
180 
181 #endif
182 
183 #endif
PlaneInferredInfo * mpPlaneInferInfo
Definition: PbMapMaker.h:144
std::set< unsigned > observedPlanes
Definition: PbMapMaker.h:141
A class used to store a planar feature (Plane for short).
Definition: Plane.h:48
PbMapLocaliser * mpPbMapLocaliser
Definition: PbMapMaker.h:129
bool areSamePlane(Plane &plane1, Plane &plane2, const float &cosAngleThreshold, const float &distThreshold, const float &proxThreshold)
void checkProximity(Plane &plane, float proximity)
Definition: PbMapMaker.cpp:316
void serializePbMap(std::string path)
boost::mutex mtx_pbmap_busy
Definition: PbMapMaker.h:134
pcl::PointXYZRGBA PointT
Definition: PbMapMaker.h:33
void viz_cb(pcl::visualization::PCLVisualizer &viz)
void watchProperties(std::set< unsigned > &observedPlanes, Plane &observedPlane)
double dist_THRESHOLDFull = 1.2; double dist_THRESHOLDFull_inv = 1/dist_THRESHOLDFull; ...
Definition: PbMapMaker.cpp:355
A class used to infer some semantic meaning to the planes of a PbMap.
void mergePlanes(Plane &updatePlane, Plane &discardPlane)
SemanticClustering * clusterize
Definition: PbMapMaker.h:132
GLsizei const GLchar ** string
Definition: glext.h:4101
std::thread pbmaker_hd
Definition: PbMapMaker.h:153
PbMapMaker(const std::string &config_file)
Definition: PbMapMaker.cpp:181
bool arePlanesNearby(Plane &plane1, Plane &plane2, const float distThreshold)
Definition: PbMapMaker.cpp:213
std::set< unsigned > sQueueObservedPlanes
Definition: PbMapMaker.h:78
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void detectPlanesCloud(pcl::PointCloud< PointT >::Ptr &pointCloudPtr_arg, Eigen::Matrix4f &poseKF, double distThreshold, double angleThreshold, double minInliersF)
Definition: PbMapMaker.cpp:646
pcl::PointCloud< PointT >::Ptr cloudPtr
Definition: PbMapMaker.h:45
std::vector< frameRGBDandPose > frameQueue
Definition: PbMapMaker.h:75
A class used to store a Plane-based Map (PbMap).
Definition: pbmap/PbMap.h:49
pcl::visualization::CloudViewer cloudViewer
Definition: PbMapMaker.h:81



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019