-
Notifications
You must be signed in to change notification settings - Fork 12
/
slam_viewer.hpp
149 lines (110 loc) · 3.97 KB
/
slam_viewer.hpp
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
#ifndef SLAM_VIEWER_HPP
#define SLAM_VIEWER_HPP
#include "opencv_viewer_data_publisher.hpp"
#include "../commandline/draw_gl.hpp"
#include "slam_implementation.hpp"
#include "viewer_data_publisher.hpp"
#include "../codegen/output/cmd_parameters.hpp"
#include "../commandline/command_queue.hpp"
#include <memory>
#include <mutex>
#include <Eigen/Dense>
#include <pangolin/pangolin.h>
namespace slam {
namespace viewer {
struct AtlasControl {
std::unique_ptr<pangolin::Var<float>> angle;
std::unique_ptr<pangolin::Var<float>> x;
std::unique_ptr<pangolin::Var<float>> y;
};
class Viewer {
public:
Viewer(const cmd::Parameters ¶meters, CommandQueue &commands);
void setup();
void draw();
/**
* Request to terminate the viewer
* (NOTE: this function does not wait for terminate)
*/
void request_terminate();
ViewerDataPublisher &get_data_publisher() { return dataPublisher; }
bool is_paused() const { return menu_paused_atomic.load(); }
private:
void create_menu_panel();
/**
* Update SLAM atlas if it was changed.
*/
void getAtlas();
/**
* Follow to the specified camera pose
* @param gl_cam_pose_wc
*/
void follow_camera(const pangolin::OpenGlMatrix &gl_cam_pose_wc);
void drawKeyframes();
void drawLoops();
void drawMapPoints();
OpenCVViewerDataPublisher dataPublisher;
/**
* Drawing displacement for atlas maps.
*/
Eigen::Vector2f atlasOffset(size_t mapInd) const;
cmd::ParametersViewer parameters;
CommandQueue &commands;
const float viewpoint_x_, viewpoint_y_, viewpoint_z_, viewpoint_f_;
const float keyfrm_line_width_;
const float graph_line_width_;
const float point_size_;
const float camera_size_;
draw::Theme theme;
int theme_ind;
pangolin::View d_cam;
pangolin::OpenGlMatrix gl_cam_pose_wc;
// menu panel
std::unique_ptr<pangolin::Var<bool>> menu_paused_;
std::unique_ptr<pangolin::Var<bool>> menu_follow_camera_;
std::unique_ptr<pangolin::Var<bool>> menu_grid_;
std::unique_ptr<pangolin::Var<bool>> menu_show_keyfrms_;
std::unique_ptr<pangolin::Var<bool>> menu_show_orig_poses_;
std::unique_ptr<pangolin::Var<bool>> menu_show_mps_;
std::unique_ptr<pangolin::Var<bool>> menu_show_stereo_pc_;
std::unique_ptr<pangolin::Var<bool>> menu_show_local_map_;
std::unique_ptr<pangolin::Var<bool>> menu_show_graph_;
std::unique_ptr<pangolin::Var<bool>> menu_show_loops_;
std::unique_ptr<pangolin::Var<bool>> menu_show_loop_cands_;
std::unique_ptr<pangolin::Var<bool>> menu_normal_colors_;
std::unique_ptr<pangolin::Var<bool>> menu_natural_colors_;
std::unique_ptr<pangolin::Var<float>> menu_mp_size_;
std::unique_ptr<pangolin::Var<float>> menu_mp_alpha_;
std::unique_ptr<pangolin::Var<float>> menu_map_scale_;
std::unique_ptr<pangolin::Var<bool>> menu_change_theme_;
std::atomic_bool menu_paused_atomic;
// camera renderer
std::unique_ptr<pangolin::OpenGlRenderState> s_cam_;
// current state
bool follow_camera_ = true;
// viewer appearance
const std::string map_viewer_name_{"Map Viewer"};
static constexpr float map_viewer_width_ = 1024;
static constexpr float map_viewer_height_ = 768;
// Data state which is not updated on every draw call.
std::unique_ptr<ViewerAtlas> atlas;
std::vector<AtlasControl> atlasControls;
double atlasOffsetX;
double atlasOffsetY;
draw::Animation animation;
std::set<std::pair<MapKf, double>> animatedLoopStages;
//-----------------------------------------
// management for terminate process
//! mutex for access to terminate procedure
mutable std::mutex mtx_terminate_;
/**
* Check if termination is requested or not
* @return
*/
bool terminate_is_requested();
//! flag which indicates termination is requested or not
bool terminate_is_requested_ = false;
};
} // namespace viewer
} // namespace slam
#endif //SLAM_VIEWER_HPP