00001 #ifndef CARTOGRAPHER_IO_HYBRID_GRID_POINTS_PROCESSOR_H_ 00002 #define CARTOGRAPHER_IO_HYBRID_GRID_POINTS_PROCESSOR_H_ 00003 00004 // Library used for inserting range data points into a hybrid grid. 00005 00006 #include <memory> 00007 #include <string> 00008 00009 #include "cartographer/io/file_writer.h" 00010 #include "cartographer/io/points_batch.h" 00011 #include "cartographer/io/points_processor.h" 00012 #include "cartographer/mapping/3d/hybrid_grid.h" 00013 #include "cartographer/mapping/3d/range_data_inserter_3d.h" 00014 #include "cartographer/mapping/proto/3d/range_data_inserter_options_3d.pb.h" 00015 00016 namespace cartographer { 00017 namespace io { 00018 00019 // Creates a hybrid grid of the points with voxels being 'voxel_size' 00020 // big. 'range_data_inserter' options are used to configure the range 00021 // data ray tracing through the hybrid grid. 00022 class HybridGridPointsProcessor : public PointsProcessor { 00023 public: 00024 constexpr static const char* kConfigurationFileActionName = 00025 "write_hybrid_grid"; 00026 HybridGridPointsProcessor(double voxel_size, 00027 const mapping::proto::RangeDataInserterOptions3D& 00028 range_data_inserter_options, 00029 std::unique_ptr<FileWriter> file_writer, 00030 PointsProcessor* next); 00031 HybridGridPointsProcessor(const HybridGridPointsProcessor&) = delete; 00032 HybridGridPointsProcessor& operator=(const HybridGridPointsProcessor&) = 00033 delete; 00034 00035 static std::unique_ptr<HybridGridPointsProcessor> FromDictionary( 00036 const FileWriterFactory& file_writer_factory, 00037 common::LuaParameterDictionary* dictionary, PointsProcessor* next); 00038 00039 ~HybridGridPointsProcessor() override {} 00040 00041 void Process(std::unique_ptr<PointsBatch> batch) override; 00042 FlushResult Flush() override; 00043 00044 private: 00045 PointsProcessor* const next_; 00046 00047 mapping::RangeDataInserter3D range_data_inserter_; 00048 mapping::HybridGrid hybrid_grid_; 00049 std::unique_ptr<FileWriter> file_writer_; 00050 }; 00051 00052 } // namespace io 00053 } // namespace cartographer 00054 00055 #endif // CARTOGRAPHER_IO_HYBRID_GRID_POINTS_PROCESSOR_H_