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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020