Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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 href="group__mrpt__pbmap__grp.html" >mrpt-pbmap</a>
13  */
14 
15 #ifndef __PBMAPMAKER_H
16 #define __PBMAPMAKER_H
17 
18 #include <mrpt/config.h>
19 
20 #if MRPT_HAS_PCL
21 
22 #include <boost/thread/mutex.hpp>
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>
32 #include <set>
33 
34 typedef pcl::PointXYZRGBA PointT;
35 
36 namespace mrpt {
37 namespace pbmap {
38 
39  /*!frameRGBDandPose stores a dupla containing a pointCloud (built from a RGBD 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, which pose must be also provided.
49  * The range images and their poses are communicated with the object frameQueue.
50  * PbMapMaker run its own thread, which is created at initialization.
51  *
52  * \ingroup mrpt_pbmap_grp
53  */
55  {
56  public:
57 
58  /*!PbMapMaker's constructor sets some threshold for plane segmentation and 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.*/
64 
65  /*!Get the PbMap.*/
66  PbMap getPbMap(){return mPbMap;};
67 
68  /*!Serialize the PbMap.*/
69  void serializePbMap(std::string path);
70 
71  /*!frameQueue is a vector containing the frameRGBDandPose (range image + 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 
82  /*!Find planar patches in the input organised point cloud "pointCloudPtr_arg", and update the PbMap with them (it update previous planes and
83  initialize new ones when they are first observed), the input pose "poseInv" is used to place the current observations into a common frame of
84  reference. Different thresholds are used to control the plane segmentation:
85  - "distThreshold" defines the maximum distance of an inlier to the plane
86  - "angleThreshold" defines the maximum angle between an inlier's normal and the plane's normal
87  - "minInliersF" defines the minimum number of inliers as a fraction of the total number of points in the input cloud
88  */
89  void detectPlanesCloud( pcl::PointCloud<PointT>::Ptr &pointCloudPtr_arg, Eigen::Matrix4f &poseKF, double distThreshold, double angleThreshold, double minInliersF);
90 
91  /*!Returns true when the closest distance between the patches "plane1" and "plane2" is under distThreshold.*/
92  bool arePlanesNearby(Plane &plane1, Plane &plane2, const float distThreshold);
93 
94  /*!Check for new graph connections of the input plane. These connections are stablished when the minimum distance between two patches is under
95  the input threshold "proximity"*/
96  void checkProximity(Plane &plane, float proximity);
97 
98  /*! Returns true if the two input planes represent the same physical surface for some given angle and distance thresholds.
99  * If the planes are the same they are merged in this and the function returns true. Otherwise it returns false.*/
100  bool areSamePlane(Plane &plane1, Plane &plane2, const float &cosAngleThreshold, const float &distThreshold, const float &proxThreshold);
101 
102  /*! Merge the two input patches into "updatePlane".
103  * Recalculate center, normal vector, area, inlier points (filtered), convex hull, etc.
104  */
105  void mergePlanes(Plane &updatePlane, Plane &discardPlane);
106 
107  /*!File containing some paramteres and heuristic thresholds"*/
109 
110  /*!Object to detect previous places.*/
112 
113  /*!Object to cluster set of planes according to their co-visibility.*/
115 
116  boost::mutex mtx_pbmap_busy;
117 
118  protected:
119 
120  /*!The current PbMap.*/
122 
123  /*!List of planes observed in that last frame introduced.*/
124  std::set<unsigned> observedPlanes;
125 
126  /*!Object to infer some knowledge in the map planes.*/
128 
129  /*!PCL visualizer callback*/
130  void viz_cb (pcl::visualization::PCLVisualizer& viz);
131 
132  /*!This executes the PbMapMaker's thread*/
133  void run();
134 
135  /*!PbMapMaker's thread handle*/
137 
138  /*!PbMapMaker's exit thread*/
140 
141  /*!PbMapMaker's stop controller*/
143 
144  /*!PbMapMaker's stop var*/
146 
147  // Color paper
148  void watchProperties(std::set<unsigned> &observedPlanes, Plane &observedPlane);
150  // Unary
151  float rejectAreaF, acceptAreaF, rejectAreaT, acceptAreaT;
152  float rejectElongF, acceptElongF, rejectElongT, acceptElongT;
153  float rejectC1C2C3_F, acceptC1C2C3_F, rejectC1C2C3_T, acceptC1C2C3_T;
154  float rejectNrgb_F, acceptNrgb_F, rejectNrgb_T, acceptNrgb_T;
155  float rejectIntensity_F, acceptIntensity_F, rejectIntensity_T, acceptIntensity_T;
156  float rejectColor_F, acceptColor_F, rejectColor_T, acceptColor_T;
157  float rejectHistH_F, acceptHistH_F, rejectHistH_T, acceptHistH_T;
158  };
159 
160 } } // End of namespaces
161 
162 #endif
163 
164 #endif
pcl::PointXYZRGBA PointT
Definition: PbMapMaker.h:34
A class used to store a Plane-based Map (PbMap).
Definition: pbmap/PbMap.h:46
void checkProximity(Plane &plane, float proximity)
pcl::visualization::CloudViewer cloudViewer
Definition: PbMapMaker.h:78
PbMapLocaliser * mpPbMapLocaliser
Definition: PbMapMaker.h:111
mrpt::system::TThreadHandle pbmaker_hd
Definition: PbMapMaker.h:136
void serializePbMap(std::string path)
std::set< unsigned > observedPlanes
Definition: PbMapMaker.h:124
PbMapMaker(const std::string &config_file)
bool areSamePlane(Plane &plane1, Plane &plane2, const float &cosAngleThreshold, const float &distThreshold, const float &proxThreshold)
void mergePlanes(Plane &updatePlane, Plane &discardPlane)
boost::mutex mtx_pbmap_busy
Definition: PbMapMaker.h:116
std::set< unsigned > sQueueObservedPlanes
Definition: PbMapMaker.h:75
bool arePlanesNearby(Plane &plane1, Plane &plane2, const float distThreshold)
SemanticClustering * clusterize
Definition: PbMapMaker.h:114
void detectPlanesCloud(pcl::PointCloud< PointT >::Ptr &pointCloudPtr_arg, Eigen::Matrix4f &poseKF, double distThreshold, double angleThreshold, double minInliersF)
PlaneInferredInfo * mpPlaneInferInfo
Definition: PbMapMaker.h:127
void watchProperties(std::set< unsigned > &observedPlanes, Plane &observedPlane)
std::vector< frameRGBDandPose > frameQueue
Definition: PbMapMaker.h:72
void viz_cb(pcl::visualization::PCLVisualizer &viz)
A class used to store a planar feature (Plane for short).
Definition: Plane.h:49
A class used to infer some semantic meaning to the planes of a PbMap.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
pcl::PointCloud< PointT >::Ptr cloudPtr
Definition: PbMapMaker.h:44
This structure contains the information needed to interface the threads API on each platform:
Definition: threads.h:26



Page generated by Doxygen 1.9.1 for MRPT 1.4.0 SVN: at Fri Sep 3 01:11:30 UTC 2021