cartographer源码分析(18)-sensor-compressed_point_cloud

本文深入探讨了Cartographer源码中针对压缩点云传感器的数据处理,内容来源于github上的开源项目,同时也可在多个平台阅读到相关系列文章。
摘要由CSDN通过智能技术生成

源码可在https://github.com/learnmoreonce/SLAM 下载


文件:sensor/compressed_point_cloud.h



#ifndef CARTOGRAPHER_SENSOR_COMPRESSED_POINT_CLOUD_H_
#define CARTOGRAPHER_SENSOR_COMPRESSED_POINT_CLOUD_H_

#include <iterator>
#include <vector>

#include "Eigen/Core"
#include "cartographer/common/port.h"
#include "cartographer/sensor/point_cloud.h"
#include "cartographer/sensor/proto/sensor.pb.h"

namespace cartographer {
namespace sensor {

/*
CompressedPointCloud是点云压缩类,
目的:压缩ponits以减少存储空间,压缩后有精度损失。
方法:按照block分组。

只有一个私有的
*/
// A compressed representation of a point cloud consisting of a collection of
// points (Vector3f).
// Internally, points are grouped by blocks. Each block encodes a bit of meta
// data (number of points in block, coordinates of the block) and encodes each
// point with a fixed bit rate in relation to the block.
class CompressedPointCloud {
 public:
  class ConstIterator; //前置声明

  CompressedPointCloud() : num_points_(0) {}
  explicit CompressedPointCloud(const PointCloud& point_cloud);

  // Returns decompressed point cloud.
  PointCloud Decompress() const;

  bool empty() const;                   // num_points_==0
  size_t size() const;                  // num_points_
  ConstIterator begin() const;
  ConstIterator end() const;

  proto::CompressedPointCloud ToProto() const;

 private:
  CompressedPointCloud(const std::vector<int32>& point_data, size_t num_points);

  std::vector<int32> point_data_;
  size_t num_points_;
};

/*前行迭代器*/
// Forward iterator for compressed point clouds.
class CompressedPointCloud::ConstIterator
    : public std::iterator<std::forward_iterator_tag, Eigen::Vector3f> {
 public:
  // Creates begin iterator.
  explicit ConstIterator(const CompressedPointCloud* compressed_point_cloud);

  // Creates end iterator.
  static ConstIterator EndIterator(
      const CompressedPointCloud* compressed_point_cloud);

  Eigen::Vector3f operator*() const;
  ConstIterator& operator++();
  bool operator!=(const ConstIterator& it) const;

 private:
  // Reads next point from buffer. Also handles reading the meta data of the
  // next block, if the current block is depleted.
  void ReadNextPoint();

  const CompressedPointCloud* compressed_point_cloud_;
  size_t remaining_points_;
  int32 remaining_points_in_current_block_;
  Eigen::Vector3f current_point_;
  Eigen::Vector3i current_block_coordinates_;
  std::vector<int32>::const_iterator input_;
};

}  // n
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值