Go to the documentation of this file.00001
00006 #ifndef LOOP_CLOSING_H
00007 #define LOOP_CLOSING_H
00008
00009 #include <ros/ros.h>
00010
00011 #include <boost/thread.hpp>
00012 #include <boost/filesystem.hpp>
00013 #include <boost/lexical_cast.hpp>
00014
00015 #include <libhaloc/lc.h>
00016
00017 #include "constants.h"
00018 #include "cluster.h"
00019 #include "graph.h"
00020
00021 using namespace std;
00022 using namespace boost;
00023 namespace fs = filesystem;
00024
00025 namespace slam
00026 {
00027
00028 class Graph;
00029
00030 class LoopClosing
00031 {
00032
00033 public:
00034
00037 LoopClosing();
00038
00042 inline void setGraph(Graph *graph){graph_ = graph;}
00043
00046 void run();
00047
00051 void addClusterToQueue(Cluster cluster);
00052
00055 void finalize();
00056
00057 protected:
00058
00062 bool checkNewClusterInQueue();
00063
00066 void processNewCluster();
00067
00070 void searchByProximity();
00071
00074 void searchByHash();
00075
00080 bool closeLoopWithCluster(Cluster candidate);
00081
00086 void getCandidates(int cluster_id, vector< pair<int,float> >& candidates);
00087
00092 Cluster readCluster(int id);
00093
00103 void drawLoopClosure(vector<int> cand_kfs,
00104 vector<int> cand_matchings,
00105 vector<int> inliers,
00106 vector<int> definitive_inliers_per_pair,
00107 vector< vector<int> > definitive_cluster_pairs,
00108 vector<cv::Point2f> matched_query_kp_l,
00109 vector<cv::Point2f> matched_cand_kp_l);
00110
00111 private:
00112
00113 Cluster c_cluster_;
00114
00115 list<Cluster> cluster_queue_;
00116
00117 mutex mutex_cluster_queue_;
00118
00119 haloc::Hash hash_;
00120
00121 vector< pair<int, vector<float> > > hash_table_;
00122
00123 vector< pair<int, int > > cluster_lc_found_;
00124
00125 int num_loop_closures_;
00126
00127 string execution_dir_;
00128
00129 string loop_closures_dir_;
00130
00131 Graph* graph_;
00132
00133 ros::Publisher pub_num_keyframes_;
00134
00135 ros::Publisher pub_num_lc_;
00136
00137 ros::Publisher pub_queue_;
00138
00139 ros::Publisher pub_lc_matchings_;
00140
00141 image_geometry::PinholeCameraModel camera_model_;
00142
00143 };
00144
00145 }
00146
00147 #endif // LOOP_CLOSING_H