cartographer源码分析(30)-io-counting_points_processor.h
2017-07-28 21:27
537 查看
源码可在https://github.com/learnmoreonce/SLAM 下载
本文发于:
* http://www.jianshu.com/u/9e38d2febec1
* https://zhuanlan.zhihu.com/learnmoreonce
* http://blog.csdn.net/learnmoreonce
* slam源码分析微信公众号:slamcode
文件:counting_points_processor.h #ifndef CARTOGRAPHER_IO_COUNTING_POINTS_PROCESSOR_H_ #define CARTOGRAPHER_IO_COUNTING_POINTS_PROCESSOR_H_ #include "cartographer/common/lua_parameter_dictionary.h" #include "cartographer/io/points_processor.h" namespace cartographer { namespace io { /* PointsProcessor的第二个子类(2). 功能:记录有多少 point被输出处理 数据成员: 1),num_points_记录points数量 2),next_下一阶段的PointsProcessor. */ // Passes through points, but keeps track of how many points it saw and output // that on Flush. class CountingPointsProcessor : public PointsProcessor { public: constexpr static const char* kConfigurationFileActionName = "dump_num_points"; explicit CountingPointsProcessor(PointsProcessor* next); static std::unique_ptr<CountingPointsProcessor> FromDictionary( common::LuaParameterDictionary* dictionary, PointsProcessor* next); ~CountingPointsProcessor() override {} CountingPointsProcessor(const CountingPointsProcessor&) = delete; CountingPointsProcessor& operator=(const CountingPointsProcessor&) = delete; void Process(std::unique_ptr<PointsBatch> points) override; FlushResult Flush() override; private: int64 num_points_; PointsProcessor* next_; }; } // namespace io } // namespace cartographer #endif // CARTOGRAPHER_IO_COUNTING_POINTS_PROCESSOR_H_
counting_points_processor.cc #include "cartographer/io/counting_points_processor.h" #include "cartographer/common/make_unique.h" #include "glog/logging.h" namespace cartographer { namespace io { //初始化是num是0 CountingPointsProcessor::CountingPointsProcessor(PointsProcessor* next) : num_points_(0), next_(next) {} //与其他FromDictionary()函数统一写法 std::unique_ptr< a099 CountingPointsProcessor> CountingPointsProcessor::FromDictionary( common::LuaParameterDictionary* const dictionary, PointsProcessor* const next) { return common::make_unique<CountingPointsProcessor>(next); } //不处理points,而是将num_points_加上batch.size(),,即统计点云数据。然后直接流水线到下一PointsProcessor void CountingPointsProcessor::Process(std::unique_ptr<PointsBatch> batch) { num_points_ += batch->points.size();//相加 next_->Process(std::move(batch)); } //依据下一阶段的状态重置本阶段的状态。 PointsProcessor::FlushResult CountingPointsProcessor::Flush() { switch (next_->Flush()) { case FlushResult::kFinished: LOG(INFO) << "Processed " << num_points_ << " and finishing."; return FlushResult::kFinished; case FlushResult::kRestartStream: LOG(INFO) << "Processed " << num_points_ << " and restarting stream."; num_points_ = 0; //重启,则置为0 return FlushResult::kRestartStream; } LOG(FATAL); } } // namespace io } // namespace cartographer
本文发于:
* http://www.jianshu.com/u/9e38d2febec1
* https://zhuanlan.zhihu.com/learnmoreonce
* http://blog.csdn.net/learnmoreonce
* slam源码分析微信公众号:slamcode
相关文章推荐
- cartographer源码分析(35)-io-fixed_ratio_sampling_points_processor.h
- cartographer源码分析(28)-io-points_processor.h
- cartographer源码分析(29)-io-min_max_range_filtering_points_processor.h
- cartographer源码分析(36)-io- outlier_removing_points_processor.h
- cartographer源码分析(32)-io-intensity_to_color_points_processor.h
- cartographer源码分析(33)-io-ply_writing_points_processor.h
- cartographer源码分析(37)-io-pcd_writing_points_processor.h
- cartographer源码分析(34)-io-coloring_points_processor.h
- cartographer源码分析(38)-io-null_points_processor.h
- [置顶] 40-总结-【cartographer源码分析】系列的第四部分【io源码分析】
- cartographer源码分析(26)-io-file_writer.h
- cartographer源码分析(31)-io-xray_points_processor.h
- cartographer源码分析(22)-sensor-collator.h
- JAVA IO之缓冲流源码分析
- tornado 源码分析 之 异步io的实现方式
- 谷歌浏览器的源码分析(30)
- google源码cartographer分析一
- Mina源码分析——IoService
- Java IO 之 FileInputStream & FileOutputStream源码分析
- java io系列02之 ByteArrayInputStream的简介,源码分析和示例(包括InputStream)