slam系列之openvslam解读

接上一篇:https://blog.csdn.net/xiechaoyi123/article/details/104393764

本篇主要是解读openvslam的数据结构

 

接口函数:system

包含的数据结构

1)三个主要的线程及相关数据:

//! tracker
tracking_module* tracker_ = nullptr;

//! mapping module
mapping_module* mapper_ = nullptr;
//! mapping thread
std::unique_ptr<std::thread> mapping_thread_ = nullptr;

//! global optimization module
global_optimization_module* global_optimizer_ = nullptr;

//! global optimization thread
std::unique_ptr<std::thread> global_optimization_thread_ = nullptr;

//! mutex for flags of enable/disable mapping module
mutable std::mutex mtx_mapping_;

//! mutex for flags of enable/disable loop detector
mutable std::mutex mtx_loop_detector_;

其中tracking模块是主线程,其他两个模块是同步线程,所以需要锁进行全局数据的保护

2)包含全局数据的map_database,相机类型的camera_database以及用于匹配的bag of words对应的数据结构:

 // (1) camera 数据结构包括:相机类型base,以及所有图像对应的相机类型camera_database
   //! camera model
    camera::base* camera_ = nullptr;

    //! camera database
    data::camera_database* cam_db_ = nullptr;

// (2) map 数据结构包括:全局三维点云信息,关键帧信息以及局部三维点和局部关键帧等信息
    //! map database
    data::map_database* map_db_ = nullptr;

// (3) BOW 数据结构包括:bow_vocabulary词袋以及bow_database
    //! BoW vocabulary
    data::bow_vocabulary* bow_vocab_ = nullptr;

    //! BoW database
    data::bow_database* bow_db_ = nullptr;

3)system自身的一些flag:状态flag, 重置flag,  出错flag

   //! system running status flag
    std::atomic<bool> system_is_running_{false};

    //! mutex for reset flag
    mutable std::mutex mtx_reset_;
    //! reset flag
    bool reset_is_requested_ = false;

    //! mutex for terminate flag
    mutable std::mutex mtx_terminate_;
    //! terminate flag
    bool terminate_is_requested_ = false;

4)显示用的数据结构:显示数据帧frame, 显示三维信息map

//! frame publisher
std::shared_ptr<publish::frame_publisher> frame_publisher_ = nullptr;
//! map publisher
std::shared_ptr<publish::map_publisher> map_publisher_ = nullptr;

5)输入控制的参数:config

包含的操作

1)构造与析构,开始和终止:通过传入的控制参数去构造slam 系统,析构释放内存,开始当前系统,结束当前系统

    //! Constructor
    system(const std::shared_ptr<config>& cfg, const std::string& vocab_file_path);

    //! Destructor
    ~system();

    //-----------------------------------------
    // system startup and shutdown

    //! Startup the SLAM system
    void startup(const bool need_initialize = true);

    //! Shutdown the SLAM system
    void shutdown();

2)三个模块的一些处理:线程间的通信同步,是否开启第三个模块回环检测等

   //-----------------------------------------
    // module management

    //! Enable the mapping module
    void enable_mapping_module();

    //! Disable the mapping module
    void disable_mapping_module();

    //! The mapping module is enabled or not
    bool mapping_module_is_enabled() const;

    //! Enable the loop detector
    void enable_loop_detector();

    //! Disable the loop detector
    void disable_loop_detector();

    //! The loop detector is enabled or not
    bool loop_detector_is_enabled() const;

    //! Loop BA is running or not
    bool loop_BA_is_running() const;

    //! Abort the loop BA externally
    void abort_loop_BA();
    //-----------------------------------------
    // management for pause

    //! Pause the tracking module
    void pause_tracker();

    //! The tracking module is paused or not
    bool tracker_is_paused() const;

    //! Resume the tracking module
    void resume_tracker();

    //-----------------------------------------
    // management for reset

    //! Request to reset the system
    void request_reset();

    //! Reset of the system is requested or not
    bool reset_is_requested() const;

    //-----------------------------------------
    // management for terminate

    //! Request to terminate the system
    void request_terminate();

    //!! Termination of the system is requested or not
    bool terminate_is_requested() const;
    
    

    //! Check reset request of the system
    void check_reset_request();

    //! Pause the mapping module and the global optimization module
    void pause_other_threads() const;

    //! Resume the mapping module and the global optimization module
    void resume_other_threads() const;

3)数据的输入输出:map的读取与保存,数据的显示,关键帧的读取与保存

   //-----------------------------------------
    // data I/O

    //! Save the frame trajectory in the specified format
    void save_frame_trajectory(const std::string& path, const std::string& format) const;

    //! Save the keyframe trajectory in the specified format
    void save_keyframe_trajectory(const std::string& path, const std::string& format) const;

    //! Load the map database from the MessagePack file
    void load_map_database(const std::string& path) const;

    //! Save the map database to the MessagePack file
    void save_map_database(const std::string& path) const;

    //! Get the map publisher
    const std::shared_ptr<publish::map_publisher> get_map_publisher() const;

    //! Get the frame publisher
    const std::shared_ptr<publish::frame_publisher> get_frame_publisher() const;

4)传入的相机类型及相应数据传入:单目输入单张图像,双目输入两张图象,RGBD输入深度图和RGB图

    //-----------------------------------------
    // data feeding methods

    //! Feed a monocular frame to SLAM system
    //! (NOTE: distorted images are acceptable if calibrated)
    Mat44_t feed_monocular_frame(const cv::Mat& img, const double timestamp, const cv::Mat& mask = cv::Mat{});

    //! Feed a stereo frame to SLAM system
    //! (Note: Left and Right images must be stereo-rectified)
    Mat44_t feed_stereo_frame(const cv::Mat& left_img, const cv::Mat& right_img, const double timestamp, const cv::Mat& mask = cv::Mat{});

    //! Feed an RGBD frame to SLAM system
    //! (Note: RGB and Depth images must be aligned)
    Mat44_t feed_RGBD_frame(const cv::Mat& rgb_img, const cv::Mat& depthmap, const double timestamp, const cv::Mat& mask = cv::Mat{});

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值