LoopClosing.h
Go to the documentation of this file.
1 
21 #ifndef LOOPCLOSING_H
22 #define LOOPCLOSING_H
23 
24 #include "KeyFrame.h"
25 #include "LocalMapping.h"
26 #include "Map.h"
27 #include "ORBVocabulary.h"
28 #include "Tracking.h"
29 
30 #include "KeyFrameDatabase.h"
31 
32 #include <thread>
33 #include <mutex>
35 
36 namespace ORB_SLAM2
37 {
38 
39 class Tracking;
40 class LocalMapping;
41 class KeyFrameDatabase;
42 
43 
45 {
46 public:
47 
48  typedef pair<set<KeyFrame*>,int> ConsistentGroup;
49  typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
50  Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;
51 
52 public:
53 
54  LoopClosing(Map* pMap, KeyFrameDatabase* pDB, ORBVocabulary* pVoc,const bool bFixScale);
55 
56  void SetTracker(Tracking* pTracker);
57 
58  void SetLocalMapper(LocalMapping* pLocalMapper);
59 
60  // Main function
61  void Run();
62 
63  void InsertKeyFrame(KeyFrame *pKF);
64 
65  void RequestReset();
66 
67  // This function will run in a separate thread
68  void RunGlobalBundleAdjustment(unsigned long nLoopKF);
69 
70  bool isRunningGBA(){
71  unique_lock<std::mutex> lock(mMutexGBA);
72  return mbRunningGBA;
73  }
74  bool isFinishedGBA(){
75  unique_lock<std::mutex> lock(mMutexGBA);
76  return mbFinishedGBA;
77  }
78 
79  void RequestFinish();
80 
81  bool isFinished();
82 
84 
85  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
86 
87 protected:
88 
89  bool CheckNewKeyFrames();
90 
91  bool DetectLoop();
92 
93  bool ComputeSim3();
94 
95  void SearchAndFuse(const KeyFrameAndPose &CorrectedPosesMap);
96 
97  void CorrectLoop();
98 
99  void ResetIfRequested();
101  std::mutex mMutexReset;
102 
103  bool CheckFinish();
104  void SetFinish();
107  std::mutex mMutexFinish;
108 
111 
114 
116 
117  std::list<KeyFrame*> mlpLoopKeyFrameQueue;
118 
119  std::mutex mMutexLoopQueue;
120 
121  // Loop detector parameters
123 
124  // Loop detector variables
127  std::vector<ConsistentGroup> mvConsistentGroups;
128  std::vector<KeyFrame*> mvpEnoughConsistentCandidates;
129  std::vector<KeyFrame*> mvpCurrentConnectedKFs;
130  std::vector<MapPoint*> mvpCurrentMatchedPoints;
131  std::vector<MapPoint*> mvpLoopMapPoints;
132  cv::Mat mScw;
134 
135  long unsigned int mLastLoopKFid;
136 
137  // Variables related to Global Bundle Adjustment
140  bool mbStopGBA;
141  std::mutex mMutexGBA;
142  std::thread* mpThreadGBA;
143 
144  // Fix scale in the stereo/RGB-D case
146 
147 
149 };
150 
151 } //namespace ORB_SLAM
152 
153 #endif // LOOPCLOSING_H
Definition: sim3.h:41
std::vector< KeyFrame * > mvpCurrentConnectedKFs
Definition: LoopClosing.h:129
LoopClosing(Map *pMap, KeyFrameDatabase *pDB, ORBVocabulary *pVoc, const bool bFixScale)
void InsertKeyFrame(KeyFrame *pKF)
ORBVocabulary * mpORBVocabulary
Definition: LoopClosing.h:113
LocalMapping * mpLocalMapper
Definition: LoopClosing.h:115
void SearchAndFuse(const KeyFrameAndPose &CorrectedPosesMap)
void SetLocalMapper(LocalMapping *pLocalMapper)
KeyFrameDatabase * mpKeyFrameDB
Definition: LoopClosing.h:112
long unsigned int mLastLoopKFid
Definition: LoopClosing.h:135
pair< set< KeyFrame * >, int > ConsistentGroup
Definition: LoopClosing.h:48
std::vector< KeyFrame * > mvpEnoughConsistentCandidates
Definition: LoopClosing.h:128
void SetTracker(Tracking *pTracker)
void RunGlobalBundleAdjustment(unsigned long nLoopKF)
std::list< KeyFrame * > mlpLoopKeyFrameQueue
Definition: LoopClosing.h:117
map< KeyFrame *, g2o::Sim3, std::less< KeyFrame * >, Eigen::aligned_allocator< std::pair< const KeyFrame *, g2o::Sim3 > > > KeyFrameAndPose
Definition: LoopClosing.h:50
std::mutex mMutexLoopQueue
Definition: LoopClosing.h:119
std::vector< MapPoint * > mvpLoopMapPoints
Definition: LoopClosing.h:131
std::thread * mpThreadGBA
Definition: LoopClosing.h:142
std::vector< MapPoint * > mvpCurrentMatchedPoints
Definition: LoopClosing.h:130
std::vector< ConsistentGroup > mvConsistentGroups
Definition: LoopClosing.h:127


orb_slam2_with_maps_odom
Author(s): teng zhang
autogenerated on Fri Sep 25 2020 03:24:47