GLIM
Loading...
Searching...
No Matches
standard_viewer.hpp
1#pragma once
2
3#include <mutex>
4#include <atomic>
5#include <thread>
6#include <memory>
7#include <vector>
8#include <unordered_map>
9#include <optional>
10#include <boost/weak_ptr.hpp>
11
12#include <Eigen/Core>
13#include <Eigen/Geometry>
14
15#include <gtsam_points/util/gtsam_migration.hpp>
16#include <glim/util/extension_module.hpp>
17#include <gtsam_points/util/runnning_statistics.hpp>
18
19namespace spdlog {
20class logger;
21}
22
23namespace gtsam {
24class NonlinearFactor;
25}
26
27namespace glim {
28
29class TrajectoryManager;
30struct EstimationFrame;
31
32struct SubMapMemoryStats;
33struct FactorMemoryStats;
34
36public:
37 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
38
40 virtual ~StandardViewer();
41
42 virtual bool ok() const override;
43
44 void invoke(const std::function<void()>& task);
45
46private:
47 Eigen::Isometry3f resolve_pose(const std::shared_ptr<const EstimationFrame>& frame);
48
49 void set_callbacks();
50 void viewer_loop();
51
52 bool drawable_filter(const std::string& name);
53 void drawable_selection();
54
55private:
56 std::atomic_bool viewer_started;
57 std::atomic_bool request_to_terminate;
58 std::atomic_bool kill_switch;
59 std::thread thread;
60
61 bool enable_partial_rendering;
62 int partial_rendering_budget;
63
64 bool track;
65 bool show_current_coord;
66 bool show_current_points;
67 int odom_color_mode;
68 int submap_color_mode;
69
70 bool show_odometry_scans;
71 bool show_odometry_keyframes;
72 bool show_odometry_factors;
73
74 bool show_submaps;
75 bool show_factors;
76
77 bool show_odometry_status;
78 int last_id;
79 int last_num_points;
80 std::pair<double, double> last_point_stamps;
81 Eigen::Vector3d last_imu_vel;
82 Eigen::Matrix<double, 6, 1> last_imu_bias;
83 double last_median_distance;
84 std::vector<double> last_voxel_resolutions;
85
86 using FactorLine = std::tuple<Eigen::Vector3f, Eigen::Vector3f, Eigen::Vector4f, Eigen::Vector4f>;
87 using FactorLineGetter = std::function<std::optional<FactorLine>(const gtsam::NonlinearFactor*)>;
88 std::vector<std::pair<gtsam_points::weak_ptr<gtsam::NonlinearFactor>, FactorLineGetter>> odometry_factor_lines;
89 std::unordered_map<std::uint64_t, Eigen::Isometry3f> odometry_poses;
90
91 bool show_mapping_tools;
92 float min_overlap;
93
94 bool show_memory_stats;
95 int submap_memstats_count;
96 std::vector<SubMapMemoryStats> submap_memstats;
97
98 int global_factor_stats_count;
99 std::vector<FactorMemoryStats> global_factor_memstats;
100
101 size_t total_gl_bytes;
102
103 double point_size;
104 bool point_size_metric;
105 bool point_shape_circle;
106
107 int z_range_mode;
108 Eigen::Vector2f z_range;
109 Eigen::Vector2f auto_z_range;
110 double last_submap_z;
111 double points_alpha;
112 double factors_alpha;
113
114 bool auto_intensity_range;
115 Eigen::Vector2f intensity_range;
117
118 std::unique_ptr<TrajectoryManager> trajectory;
119 std::vector<Eigen::Isometry3f> submap_keyframes;
120
121 std::vector<std::pair<int, int>> global_between_factors;
122
123 std::mutex invoke_queue_mutex;
124 std::vector<std::function<void()>> invoke_queue;
125
126 // Logging
127 std::shared_ptr<spdlog::logger> logger;
128};
129} // namespace glim
Extension module to be dynamically loaded via dynamic linking.
Definition extension_module.hpp:10
Definition standard_viewer.hpp:35
virtual bool ok() const override
Check if the module is alive. (If it returns false, the system will be shutdown)
Definition loose_initial_state_estimation.hpp:9