forked from sair-lab/AirSLAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_refiner.h
105 lines (81 loc) · 2.33 KB
/
map_refiner.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
#ifndef MAP_REFINER_H_
#define MAP_REFINER_H_
#include <iostream>
#include <chrono>
#include <opencv2/opencv.hpp>
#include <Eigen/Core>
#include "super_point.h"
#include "super_glue.h"
#include "read_configs.h"
#include "imu.h"
#include "dataset.h"
#include "camera.h"
#include "frame.h"
#include "point_matcher.h"
#include "line_processor.h"
#include "map.h"
#include "ros_publisher.h"
#include "g2o_optimization/types.h"
#include "bow/database.h"
struct LoopGroupCandidate{
LoopGroupCandidate(): group_score(0) {}
std::set<FramePtr> group_frames;
double group_score;
};
struct LoopFramePair{
LoopFramePair() {}
FramePtr query_frame;
FramePtr loop_frame;
Eigen::Matrix3d Rlq;
Eigen::Vector3d tlq;
};
class MapRefiner{
public:
MapRefiner();
MapRefiner(MapRefinementConfigs& configs, ros::NodeHandle nh);
void LoadMap(const std::string& map_root);
// for loop closure
void LoadVocabulary(const std::string voc_path);
void UpdateCovisibilityGraph();
int LoopDetection();
void LoopDetection(FramePtr frame, DBoW2::WordIdToFeatures& word_features, DBoW2::BowVector& bow_vector);
void RelativatePoseEstimation(FramePtr frame, DBoW2::WordIdToFeatures& word_features,
FramePtr loop_frame, std::vector<cv::DMatch>& loop_matches, std::map<FramePtr, LoopGroupCandidate>& group_candidates);
void PoseGraphRefinement();
void MergeMap();
void MergeMappoints();
void MergeMappointGroup(const std::set<int>& mappoint_group);
void MergeMaplines();
void MergeMaplineGroup(const std::set<int>& mapline_group);
void GlobalMapOptimization();
// for junction database
void BuildJunctionDatabase();
// for saving
void SaveTrajectory(std::string save_path);
void SaveFinalMap(std::string map_root);
// for visualization
void PubMap();
void StopVisualization();
void Wait(int breakpoint);
private:
// tmp
double odometry_length;
std::vector<LoopFramePair> loop_frame_pairs;
std::map<MappointPtr, std::set<MappointPtr>> merged_mappoints;
private:
// class
MapRefinementConfigs _configs;
PointMatcherPtr _point_matcher;
MapPtr _map;
CameraPtr _camera;
// for loop closure
DatabasePtr _database;
// for visualization
RosPublisherPtr _ros_publisher;
std::mutex _map_mutex;
bool _stop;
bool _stopped;
bool _map_ready;
std::thread _visualization_thread;
};
#endif // MAP_REFINER_H_