cartographer 代码思想解读(6)- submap封装与维护

cartographer 代码思想解读(6)- submap封装与维护


前面两节描述了submap2d的存储形式、表示形式、概率地图、继承关系,同时也包含了submap具体的初始化、更新原理和过程,即算法核心具体实现。这节主要描述下cartographer如何在代码中进行封装和调用的。cartographer代码中并没有直接调用submap的类进行处理,而是将submap类封装成submap2d进行调用,同时将其submap2d重新封装成了ActiveSubmaps2D类进行维护和管理。
其代码目录如下:
cartographer/mapping/2d/submap2d.h

ActiveSubmaps2D类实际是对submap在使用过程进行了特殊管理和操作,其内部包含了两个submap2D,一个用于匹配,一个用于插入。其类定义如下:

// ActiveSubmaps2D类维护了两个submap,一个old 和一个new,
// old用于matching,而new用于插入
// 当new submap达到一定数量时,则停止插入。
// 抛弃old,将new变为old
// 创建一个新的new submap
class ActiveSubmaps2D {
 public:
  explicit ActiveSubmaps2D(const proto::SubmapsOptions2D& options);

  ActiveSubmaps2D(const ActiveSubmaps2D&) = delete;
  ActiveSubmaps2D& operator=(const ActiveSubmaps2D&) = delete;

  // Inserts 'range_data' into the Submap collection.
  std::vector<std::shared_ptr<const Submap2D>> InsertRangeData(
      const sensor::RangeData& range_data);

  std::vector<std::shared_ptr<const Submap2D>> submaps() const;

 private:
  // 创建插入器接口
  std::unique_ptr<RangeDataInserterInterface> CreateRangeDataInserter();
  // 创建grid地图接口
  std::unique_ptr<GridInterface> CreateGrid(const Eigen::Vector2f& origin);
  void FinishSubmap();    //无用,估计是代码升级后,删除的方法
  // 加入一个新的
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值