cartographer源码分析(29)-io-min_max_range_filtering_points_processor.h
来源:互联网 发布:淘宝seo怎么优化关键词 编辑:程序博客网 时间:2024/06/05 06:51
源码可在https://github.com/learnmoreonce/SLAM 下载
文件:min_max_range_filtering_points_processor.h#ifndef CARTOGRAPHER_IO_MIN_MAX_RANGE_FILTERING_POINTS_PROCESSOR_H_#define CARTOGRAPHER_IO_MIN_MAX_RANGE_FILTERING_POINTS_PROCESSOR_H_#include <memory>#include "cartographer/common/lua_parameter_dictionary.h"#include "cartographer/io/points_processor.h"namespace cartographer {namespace io {/*PointsProcessor的第一个子类(1).功能:继承自PointsProcessor点云虚基类.距离过滤器,L2 距离不在Min-Max范围内的都过滤掉.数据成员:1),min_range_ 最小范围2),max_range_ 最大范围3),PointsProcessor* const next_:完成本轮Processor,接下来进行下一次Processor.*/// Filters all points that are farther away from their 'origin' as 'max_range'// or closer than 'min_range'.class MinMaxRangeFiteringPointsProcessor : public PointsProcessor { public: constexpr static const char* kConfigurationFileActionName = "min_max_range_filter"; MinMaxRangeFiteringPointsProcessor(double min_range, double max_range, PointsProcessor* next); //从.lua文件加载min_range和max_range,如:0-30 static std::unique_ptr<MinMaxRangeFiteringPointsProcessor> FromDictionary( common::LuaParameterDictionary* dictionary, PointsProcessor* next); ~MinMaxRangeFiteringPointsProcessor() override {}//覆盖 MinMaxRangeFiteringPointsProcessor( const MinMaxRangeFiteringPointsProcessor&) = delete; MinMaxRangeFiteringPointsProcessor& operator=( const MinMaxRangeFiteringPointsProcessor&) = delete;//点云处理,删除[min,max]以外的point,并把数据传递到下一轮Processor处理。 void Process(std::unique_ptr<PointsBatch> batch) override; FlushResult Flush() override; //调用next_->Flush();父类调用Flush(),但在运行时才会决定是否调用子类的Flush() private: const double min_range_; const double max_range_; PointsProcessor* const next_;};} // namespace io} // namespace cartographer#endif // CARTOGRAPHER_IO_MIN_MAX_RANGE_FILTERING_POINTS_PROCESSOR_H_
min_max_range_filtering_points_processor.cc#include "cartographer/io/min_max_range_filtering_points_processor.h"#include "cartographer/common/lua_parameter_dictionary.h"#include "cartographer/common/make_unique.h"#include "cartographer/io/points_batch.h"namespace cartographer {namespace io {//从.lua文件加载min_range和max_range,如:0-30std::unique_ptr<MinMaxRangeFiteringPointsProcessor>MinMaxRangeFiteringPointsProcessor::FromDictionary( common::LuaParameterDictionary* const dictionary, PointsProcessor* const next) { return common::make_unique<MinMaxRangeFiteringPointsProcessor>( dictionary->GetDouble("min_range"), dictionary->GetDouble("max_range"), //trajectory_builder_2d.lua:0,30 //assets_writer_backpack_2d.lua 1-60 next);}/*构造函数,传递min ,max2个范围参数和 PointsProcessor* next指针*/MinMaxRangeFiteringPointsProcessor::MinMaxRangeFiteringPointsProcessor( const double min_range, const double max_range, PointsProcessor* next) : min_range_(min_range), max_range_(max_range), next_(next) {}void MinMaxRangeFiteringPointsProcessor::Process( std::unique_ptr<PointsBatch> batch) { std::vector<int> to_remove; //待移除的索引 for (size_t i = 0; i < batch->points.size(); ++i) { //计算sensor到远点的l2距离 const float range = (batch->points[i] - batch->origin).norm(); if (!(min_range_ <= range && range <= max_range_)) { //不在给定范围内,加入移除队列. to_remove.push_back(i); } } RemovePoints(to_remove, batch.get()); next_->Process(std::move(batch));//完成本轮过滤,接下来进行下一次过滤.即模拟流水线操作.}PointsProcessor::FlushResult MinMaxRangeFiteringPointsProcessor::Flush() { return next_->Flush();}} // namespace io} // namespace cartographer
本文发于:
* http://www.jianshu.com/u/9e38d2febec1
* https://zhuanlan.zhihu.com/learnmoreonce
* http://blog.csdn.net/learnmoreonce
* slam源码分析微信公众号:slamcode
阅读全文
0 0
- cartographer源码分析(29)-io-min_max_range_filtering_points_processor.h
- cartographer源码分析(26)-io-file_writer.h
- cartographer源码分析(27)-io-points_batch.h
- cartographer源码分析(28)-io-points_processor.h
- cartographer源码分析(30)-io-counting_points_processor.h
- cartographer源码分析(31)-io-xray_points_processor.h
- cartographer源码分析(32)-io-intensity_to_color_points_processor.h
- cartographer源码分析(33)-io-ply_writing_points_processor.h
- cartographer源码分析(34)-io-coloring_points_processor.h
- cartographer源码分析(35)-io-fixed_ratio_sampling_points_processor.h
- cartographer源码分析(36)-io- outlier_removing_points_processor.h
- cartographer源码分析(37)-io-pcd_writing_points_processor.h
- cartographer源码分析(38)-io-null_points_processor.h
- cartographer源码分析(3)-common-port.h
- cartographer源码分析(4)-common-time.h
- cartographer源码分析(5)-common-rate_time.h
- cartographer源码分析(6)-common-histogram.h
- cartographer源码分析(7)-common-math.h
- vb.net 教程 12-1 WebBrowser 3
- Eclipse环境安装Python插件PyDev
- cartographer源码分析(28)-io-points_processor.h
- 古文觀止卷七_原毁_韓愈
- 解决excel导出大数字溢出或者被科学计数法格式化
- cartographer源码分析(29)-io-min_max_range_filtering_points_processor.h
- Lucas–Kanade光流算法
- C++Windows下CONTAINING_RECORD宏的用法和详解
- int数组里的元素查重问题
- Vue项目启动问题
- cartographer源码分析(30)-io-counting_points_processor.h
- cartographer源码分析(31)-io-xray_points_processor.h
- JVM性能调优监控工具jps、jstack、jmap、jhat、jstat、hprof使用详解
- 系统日志