GLIM
Loading...
Searching...
No Matches
async_odometry_estimation.hpp
1#pragma once
2
3#include <mutex>
4#include <thread>
5#include <atomic>
6
7#include <glim/util/concurrent_vector.hpp>
8#include <glim/odometry/odometry_estimation_base.hpp>
9
10namespace spdlog {
11class logger;
12}
13
14namespace glim {
15
22public:
27 AsyncOdometryEstimation(const std::shared_ptr<OdometryEstimationBase>& odometry_estimation, bool enable_imu);
28
33
34#ifdef GLIM_USE_OPENCV
40 void insert_image(const double stamp, const cv::Mat& image);
41#endif
42
49 void insert_imu(const double stamp, const Eigen::Vector3d& linear_acc, const Eigen::Vector3d& angular_vel);
50
55 void insert_frame(const PreprocessedFrame::Ptr& frame);
56
60 void join();
61
65 int workload() const;
66
72 void get_results(std::vector<EstimationFrame::ConstPtr>& estimation_results, std::vector<EstimationFrame::ConstPtr>& marginalized_frames);
73
74private:
75 void run();
76
77private:
78 std::atomic_bool kill_switch; // Flag to stop the thread immediately (Hard kill switch)
79 std::atomic_bool end_of_sequence; // Flag to stop the thread when the input queues become empty (Soft kill switch)
80 std::thread thread;
81
82// Input queues
83#ifdef GLIM_USE_OPENCV
85#endif
88
89 // Output queues
90 ConcurrentVector<EstimationFrame::ConstPtr> output_estimation_results;
91 ConcurrentVector<EstimationFrame::ConstPtr> output_marginalized_frames;
92
93 bool enable_imu;
94 std::atomic_int internal_frame_queue_size;
95 std::shared_ptr<OdometryEstimationBase> odometry_estimation;
96
97 // Logging
98 std::shared_ptr<spdlog::logger> logger;
99};
100
101} // namespace glim
Odometry estimation executor to wrap and asynchronously run OdometryEstimationBase.
Definition async_odometry_estimation.hpp:21
AsyncOdometryEstimation(const std::shared_ptr< OdometryEstimationBase > &odometry_estimation, bool enable_imu)
Construct a new Async Odometry Estimation object.
void get_results(std::vector< EstimationFrame::ConstPtr > &estimation_results, std::vector< EstimationFrame::ConstPtr > &marginalized_frames)
Get the estimation results.
void insert_frame(const PreprocessedFrame::Ptr &frame)
Insert a preprocessed point cloud into odometry estimation.
~AsyncOdometryEstimation()
Destroy the Async Odometry Estimation object.
int workload() const
Get the size of the input queue.
void insert_imu(const double stamp, const Eigen::Vector3d &linear_acc, const Eigen::Vector3d &angular_vel)
Insert an IMU data into the odometry estimation.
void join()
Wait for the odometry estimation thread.
Simple thread-safe vector with mutex-lock.
Definition concurrent_vector.hpp:48