hybrid_grid_points_processor.cc
Go to the documentation of this file.
2 
3 #include <memory>
4 #include <string>
5 
6 #include "Eigen/Core"
14 #include "glog/logging.h"
15 
16 namespace cartographer {
17 namespace io {
18 
20  const double voxel_size,
21  const mapping_3d::proto::RangeDataInserterOptions&
22  range_data_inserter_options,
23  std::unique_ptr<FileWriter> file_writer, PointsProcessor* const next)
24  : next_(next),
25  range_data_inserter_(range_data_inserter_options),
26  hybrid_grid_(voxel_size),
27  file_writer_(std::move(file_writer)) {}
28 
29 std::unique_ptr<HybridGridPointsProcessor>
31  FileWriterFactory file_writer_factory,
32  common::LuaParameterDictionary* const dictionary,
33  PointsProcessor* const next) {
34  return common::make_unique<HybridGridPointsProcessor>(
35  dictionary->GetDouble("voxel_size"),
37  dictionary->GetDictionary("range_data_inserter").get()),
38  file_writer_factory(dictionary->GetString("filename")), next);
39 }
40 
41 void HybridGridPointsProcessor::Process(std::unique_ptr<PointsBatch> batch) {
42  range_data_inserter_.Insert({batch->origin, batch->points, {}},
43  &hybrid_grid_);
44  next_->Process(std::move(batch));
45 }
46 
48  const mapping_3d::proto::HybridGrid hybrid_grid_proto =
50  string serialized;
51  hybrid_grid_proto.SerializeToString(&serialized);
52  file_writer_->Write(serialized.data(), serialized.size());
53  CHECK(file_writer_->Close());
54 
55  switch (next_->Flush()) {
57  LOG(FATAL) << "Hybrid grid generation must be configured to occur after "
58  "any stages that require multiple passes.";
59 
62  }
63  LOG(FATAL) << "Failed to receive FlushResult::kFinished";
64 }
65 
66 } // namespace io
67 } // namespace cartographer
virtual void Process(std::unique_ptr< PointsBatch > points_batch)=0
proto::RangeDataInserterOptions CreateRangeDataInserterOptions(common::LuaParameterDictionary *parameter_dictionary)
std::function< std::unique_ptr< FileWriter >(const string &filename)> FileWriterFactory
Definition: file_writer.h:63
HybridGrid hybrid_grid_
static std::unique_ptr< HybridGridPointsProcessor > FromDictionary(FileWriterFactory file_writer_factory, common::LuaParameterDictionary *dictionary, PointsProcessor *next)
virtual FlushResult Flush()=0
void Process(std::unique_ptr< PointsBatch > batch) override
HybridGridPointsProcessor(double voxel_size, const mapping_3d::proto::RangeDataInserterOptions &range_data_inserter_options, std::unique_ptr< FileWriter > file_writer, PointsProcessor *next)
proto::HybridGrid ToProto(const HybridGrid &grid)
Definition: hybrid_grid.h:530
std::unique_ptr< RangeDataInserter > range_data_inserter_
std::unique_ptr< LuaParameterDictionary > GetDictionary(const string &key)
void Insert(const sensor::RangeData &range_data, HybridGrid *hybrid_grid) const


cartographer
Author(s):
autogenerated on Mon Jun 10 2019 12:51:38