forked from UZ-SLAMLab/ORB_SLAM3
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLocalMapping.h
202 lines (151 loc) · 4.43 KB
/
LocalMapping.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/**
* This file is part of ORB-SLAM3
*
* Copyright (C) 2017-2021 Carlos Campos, Richard Elvira, Juan J. Gómez Rodríguez, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
* Copyright (C) 2014-2016 Raúl Mur-Artal, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
*
* ORB-SLAM3 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ORB-SLAM3 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with ORB-SLAM3.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LOCALMAPPING_H
#define LOCALMAPPING_H
#include "KeyFrame.h"
#include "Atlas.h"
#include "LoopClosing.h"
#include "Tracking.h"
#include "KeyFrameDatabase.h"
#include "Settings.h"
#include <mutex>
namespace ORB_SLAM3
{
class System;
class Tracking;
class LoopClosing;
class Atlas;
class LocalMapping
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
LocalMapping(System* pSys, Atlas* pAtlas, const float bMonocular, bool bInertial, const string &_strSeqName=std::string());
void SetLoopCloser(LoopClosing* pLoopCloser);
void SetTracker(Tracking* pTracker);
// Main function
void Run();
void InsertKeyFrame(KeyFrame* pKF);
void EmptyQueue();
// Thread Synch
void RequestStop();
void RequestReset();
void RequestResetActiveMap(Map* pMap);
bool Stop();
void Release();
bool isStopped();
bool stopRequested();
bool AcceptKeyFrames();
void SetAcceptKeyFrames(bool flag);
bool SetNotStop(bool flag);
void InterruptBA();
void RequestFinish();
bool isFinished();
int KeyframesInQueue(){
unique_lock<std::mutex> lock(mMutexNewKFs);
return mlNewKeyFrames.size();
}
bool IsInitializing();
double GetCurrKFTime();
KeyFrame* GetCurrKF();
std::mutex mMutexImuInit;
Eigen::MatrixXd mcovInertial;
Eigen::Matrix3d mRwg;
Eigen::Vector3d mbg;
Eigen::Vector3d mba;
double mScale;
double mInitTime;
double mCostTime;
unsigned int mInitSect;
unsigned int mIdxInit;
unsigned int mnKFs;
double mFirstTs;
int mnMatchesInliers;
// For debugging (erase in normal mode)
int mInitFr;
int mIdxIteration;
string strSequence;
bool mbNotBA1;
bool mbNotBA2;
bool mbBadImu;
bool mbWriteStats;
// not consider far points (clouds)
bool mbFarPoints;
float mThFarPoints;
#ifdef REGISTER_TIMES
vector<double> vdKFInsert_ms;
vector<double> vdMPCulling_ms;
vector<double> vdMPCreation_ms;
vector<double> vdLBA_ms;
vector<double> vdKFCulling_ms;
vector<double> vdLMTotal_ms;
vector<double> vdLBASync_ms;
vector<double> vdKFCullingSync_ms;
vector<int> vnLBA_edges;
vector<int> vnLBA_KFopt;
vector<int> vnLBA_KFfixed;
vector<int> vnLBA_MPs;
int nLBA_exec;
int nLBA_abort;
#endif
protected:
bool CheckNewKeyFrames();
void ProcessNewKeyFrame();
void CreateNewMapPoints();
void MapPointCulling();
void SearchInNeighbors();
void KeyFrameCulling();
System *mpSystem;
bool mbMonocular;
bool mbInertial;
void ResetIfRequested();
bool mbResetRequested;
bool mbResetRequestedActiveMap;
Map* mpMapToReset;
std::mutex mMutexReset;
bool CheckFinish();
void SetFinish();
bool mbFinishRequested;
bool mbFinished;
std::mutex mMutexFinish;
Atlas* mpAtlas;
LoopClosing* mpLoopCloser;
Tracking* mpTracker;
std::list<KeyFrame*> mlNewKeyFrames;
KeyFrame* mpCurrentKeyFrame;
std::list<MapPoint*> mlpRecentAddedMapPoints;
std::mutex mMutexNewKFs;
bool mbAbortBA;
bool mbStopped;
bool mbStopRequested;
bool mbNotStop;
std::mutex mMutexStop;
bool mbAcceptKeyFrames;
std::mutex mMutexAccept;
void InitializeIMU(float priorG = 1e2, float priorA = 1e6, bool bFirst = false);
void ScaleRefinement();
bool bInitializing;
Eigen::MatrixXd infoInertial;
int mNumLM;
int mNumKFCulling;
float mTinit;
int countRefinement;
//DEBUG
ofstream f_lm;
};
} //namespace ORB_SLAM
#endif // LOCALMAPPING_H