slam系列之openvslam解读2

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

三个模块:tracking ,mapping,  global_optimization

 

模块一:tracking

主要模块:

包括的数据结构

1)当前系统指针以及其他两个模块指针

    //! system
    system* system_ = nullptr;
    //! mapping module
    mapping_module* mapper_ = nullptr;
    //! global optimization module
    global_optimization_module* global_optimizer_ = nullptr;

2)基本的数据处理模块:初始化,帧跟踪,重定位,位姿优化以及插帧模块

    //! initializer
    module::initializer initializer_;

    //! frame tracker for current frame
    const module::frame_tracker frame_tracker_;

    //! relocalizer
    module::relocalizer relocalizer_;

    //! pose optimizer
    const optimize::pose_optimizer pose_optimizer_;

    //! keyframe inserter
    module::keyframe_inserter keyfrm_inserter_;

3)特征提取数据结构:orb特征提取模块

    // ORB extractors
    //! ORB extractor for left/monocular image
    feature::orb_extractor* extractor_left_ = nullptr;
    //! ORB extractor for right image
    feature::orb_extractor* extractor_right_ = nullptr;
    //! ORB extractor only when used in initializing
    feature::orb_extractor* ini_extractor_left_ = nullptr;

4)基本的数据结构:

 //(1)全局数据结构以及全局对应匹配的BOW数据结构
   //! map_database
    data::map_database* map_db_ = nullptr;

    // Bag of Words
    //! BoW vocabulary
    data::bow_vocabulary* bow_vocab_ = nullptr;
    //! BoW database
    data::bow_database* bow_db_ = nullptr;


//(2)跟踪对应的局部数据:三维点信息和局部关键帧信息,以及跟踪到的点数
    //! local keyframes
    std::vector<data::keyframe*> local_keyfrms_;
    //! local landmarks
    std::vector<data::landmark*> local_landmarks_;
    //! the number of tracked keyframes in the current keyframe
    unsigned int num_tracked_lms_ = 0;

//(3)参考数据帧与参考关键帧
    //! last frame
    data::frame last_frm_;
    //! reference keyframe
    data::keyframe* ref_keyfrm_ = nullptr;

//(4)重定位对应的数据帧id
    //! latest frame ID which succeeded in relocalization
    unsigned int last_reloc_frm_id_ = 0;

//(5)直线匀速运动对应的相机位姿以及当前帧相对于参考关键帧的相对位姿
    //! motion model
    Mat44_t velocity_;
    //! current camera pose from reference keyframe
    //! (to update last camera pose at the beginning of each tracking)
    Mat44_t last_cam_pose_from_ref_keyfrm_;

5)自身的一些flag

//(1)直线匀速运动是否得到验证
    //! motion model is valid or not
    bool velocity_is_valid_ = false;

//(2)mapping 模块的状态
    //! mutex for mapping module status
    mutable std::mutex mtx_mapping_;

    //! mapping module is enabled or not
    bool mapping_is_enabled_ = true;

//(3)处理过程中是否中止
    //! mutex for pause process
    mutable std::mutex mtx_pause_;

    //! the tracking module is paused or not
    bool is_paused_ = false;

    //! Pause of the tracking module is requested or not
    bool pause_is_requested_ = false;

6)当前帧主要的数据:控制参数,相机类型,跟踪状态,当前帧信息,灰度图以及时间戳

    //! config
    const std::shared_ptr<config> cfg_;

    //! camera model (equals to cfg_->camera_)
    camera::base* camera_;

    //! latest tracking state
    tracker_state_t tracking_state_ = tracker_state_t::NotInitialized;
    //! last tracking state
    tracker_state_t last_tracking_state_ = tracker_state_t::NotInitialized;

    //! current frame and its image
    data::frame curr_frm_;
    //! image of the current frame
    cv::Mat img_gray_;

    //! elapsed microseconds for each tracking
    double elapsed_ms_ = 0.0;

主要的操作

1)构造与析构,设置线程间的通信:

    //! Constructor
    tracking_module(const std::shared_ptr<config>& cfg, system* system, data::map_database* map_db,
                    data::bow_vocabulary* bow_vocab, data::bow_database* bow_db);

    //! Destructor
    ~tracking_module();

    //! Set the mapping module
    void set_mapping_module(mapping_module* mapper);

    //! Set the global optimization module
    void set_global_optimization_module(global_optimization_module* global_optimizer);
    
    //-----------------------------------------
    // interfaces

    //! Set mapping module status
    void set_mapping_module_status(const bool mapping_is_enabled);

    //! Get mapping module status
    bool get_mapping_module_status() const;

2)初始化:

    //! Get the keypoints of the initial frame
    std::vector<cv::KeyPoint> get_initial_keypoints() const;

    //! Get the keypoint matches between the initial frame and the current frame
    std::vector<int> get_initial_matches() const;

    //! Try to initialize with the current frame
    bool initialize();

3)主调函数:

//! Main stream of the tracking module
    void track();

4)主要操作:跟踪计算位姿三维点,更新三维点与优化等

    //! Track the current frame
    bool track_current_frame();

    //! Update the motion model using the current and last frames
    void update_motion_model();

    //! Replace the landmarks if the `replaced` member has the valid pointer
    void apply_landmark_replace();

    //! Update the camera pose of the last frame
    void update_last_frame();

    //! Optimize the camera pose of the current frame
    bool optimize_current_frame_with_local_map();

    //! Update the local map
    void update_local_map();

    //! Update the local keyframes
    void update_local_keyframes();

    //! Update the local landmarks
    void update_local_landmarks();

    //! Acquire more 2D-3D matches using initial camera pose estimation
    void search_local_landmarks();

    //! Check the new keyframe is needed or not
    bool new_keyframe_is_needed() const;

    //! Insert the new keyframe derived from the current frame
    void insert_new_keyframe();

5)传入数据处理:单目,双目还是RGBD

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

    //! Track a stereo frame
    //! (Note: Left and Right images must be stereo-rectified)
    Mat44_t track_stereo_image(const cv::Mat& left_img_rect, const cv::Mat& right_img_rect, const double timestamp, const cv::Mat& mask = cv::Mat{});

    //! Track an RGBD frame
    //! (Note: RGB and Depth images must be aligned)
    Mat44_t track_RGBD_image(const cv::Mat& img, const cv::Mat& depthmap, const double timestamp, const cv::Mat& mask = cv::Mat{});

6)重定位处理:

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

    //! Reset the databases
    void reset();

    //-----------------------------------------
    // management for pause process

    //! Request to pause the tracking module
    void request_pause();

    //! Check if the pause of the tracking module is requested or not
    bool pause_is_requested() const;

    //! Check if the tracking module is paused or not
    bool is_paused() const;

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值