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



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