slam系列之openvslam解读3

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

三个模块:tracking ,mapping,  global_optimization

模块二:mapping

主要模块

包括的数据结构

1)基本数据结构:全局数据map_database, 局部关键帧序列keyfrms,以及当前关键帧

    //! map database
    data::map_database* map_db_ = nullptr;


    //! mutex for access to keyframe queue
    mutable std::mutex mtx_keyfrm_queue_;
    //! queue for keyframes
    std::list<data::keyframe*> keyfrms_queue_;

    //! current keyframe which is used in the current mapping
    data::keyframe* cur_keyfrm_ = nullptr;

2)线程间通信结构:tracking以及global optimization

    //! tracking module
    tracking_module* tracker_ = nullptr;
    //! global optimization module
    global_optimization_module* global_optimizer_ = nullptr;

3)重定位,停止,出错操作对应的数据结构:

 // (1)重定位
    //-----------------------------------------
    // management for reset process
    //! mutex for access to reset procedure
    mutable std::mutex mtx_reset_;
    //! flag which indicates whether reset is requested or not
    bool reset_is_requested_ = false;

//(2)等待
    //-----------------------------------------
    // management for pause process
    //! mutex for access to pause procedure
    mutable std::mutex mtx_pause_;
    //! flag which indicates termination is requested or not
    bool pause_is_requested_ = false;
    //! flag which indicates whether the main loop is paused or not
    bool is_paused_ = false;
    //! flag to force the mapping module to be run
    bool force_to_run_ = false;

//(3)出错
    //-----------------------------------------
    // management for terminate process
    //! mutex for access to terminate procedure
    mutable std::mutex mtx_terminate_;
    //! flag which indicates termination is requested or not
    bool terminate_is_requested_ = false;
    //! flag which indicates whether the main loop is terminated or not
    bool is_terminated_ = true;

4)局部优化与清理

    //-----------------------------------------
    // optimizer
    //! local bundle adjuster
    std::unique_ptr<optimize::local_bundle_adjuster> local_bundle_adjuster_ = nullptr;
    //! bridge flag to abort local BA
    bool abort_local_BA_ = false;


    //! local map cleaner
    std::unique_ptr<module::local_map_cleaner> local_map_cleaner_ = nullptr;

5)自身的一些flag:是否为单目,是否可接受

    //! flag which indicates the tracking camera is monocular or not
    const bool is_monocular_;

    //! flag for keyframe acceptability
    std::atomic<bool> keyfrm_acceptability_{true};

主要的操作

1)构造与析构,重置与终止机制,等待机制等

 //(1)构造与析构
   //! Constructor
    mapping_module(data::map_database* map_db, const bool is_monocular);
    //! Destructor
    ~mapping_module();

//(2)重置机制
    //-----------------------------------------
    // management for reset process
    //! Request to reset the mapping module
    //! (NOTE: this function waits for reset)
    void request_reset();

    //! Check and execute reset
    bool reset_is_requested() const;
    //! Reset the variables
    void reset();

//(3)等待机制
    //-----------------------------------------
    // management for pause process
    //! Request to pause the mapping module
    //! (NOTE: this function does not wait for reset)
    void request_pause();
    //! Check if the mapping module is requested to be paused or not
    bool pause_is_requested() const;
    //! Check if the mapping module is paused or not
    bool is_paused() const;
    //! Set the flag to force to run the mapping module
    bool set_force_to_run(const bool force_to_run);
    //! Resume the mapping module
    void resume();

    //! Pause the mapping module
    void pause();

//(4)终止机制
    //-----------------------------------------
    // management for terminate process
    //! Request to terminate the mapping module
    //! (NOTE: this function does not wait for terminate)
    void request_terminate();
    //! Check if the mapping module is terminated or not
    bool is_terminated() const;

    //! Check if termination is requested or not
    bool terminate_is_requested() const;
    //! Raise the flag which indicates the main loop has been already terminated
    void terminate();

2)设置获取结构信息

//(1)设置线程间通信
    //! Set the tracking module
    void set_tracking_module(tracking_module* tracker);
    //! Set the global optimization module
    void set_global_optimization_module(global_optimization_module* global_optimizer);


//(2)获取局部关键帧信息及是否可达设置获取
    //! Get the number of queued keyframes
    unsigned int get_num_queued_keyframes() const;
    //! Get keyframe acceptability
    bool get_keyframe_acceptability() const;
    //! Set keyframe acceptability
    void set_keyframe_acceptability(const bool acceptability);

3)主要操作:

//(1)主调接口与数据输入处理
    //-----------------------------------------
    // main process
    //! Run main loop of the mapping module
    void run();
    //! Queue a keyframe to process the mapping
    void queue_keyframe(data::keyframe* keyfrm);


//(2)创建新的关键帧并更新map中的关键帧信息
    //! Create and extend the map with the new keyframe
    void mapping_with_new_keyframe();
    //! Store the new keyframe to the map database
    void store_new_keyframe();
    //! Update the new keyframe
    void update_new_keyframe();

//(3)创建新的三维点并更新map中的landmark
    //! Create new landmarks using neighbor keyframes
    void create_new_landmarks();
    //! Triangulate landmarks between the keyframes 1 and 2
    void triangulate_with_two_keyframes(data::keyframe* keyfrm_1, data::keyframe* keyfrm_2,
                                        const std::vector<std::pair<unsigned int, unsigned int>>& matches);
    //! Fuse duplicated landmarks between current keyframe and covisibility keyframes
    void fuse_landmark_duplication(const std::unordered_set<data::keyframe*>& fuse_tgt_keyfrms);
    

//(4)更新关键帧网络结构
    //! Get the first and second order covisibilities of current keyframe
    std::unordered_set<data::keyframe*> get_second_order_covisibilities(const unsigned int first_order_thr,
                                                                        const unsigned int second_order_thr);

    

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值