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::proto::RangeDataInserterOptions3D&
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  const 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::proto::HybridGrid hybrid_grid_proto = hybrid_grid_.ToProto();
49  std::string serialized;
50  hybrid_grid_proto.SerializeToString(&serialized);
51  file_writer_->Write(serialized.data(), serialized.size());
52  CHECK(file_writer_->Close());
53 
54  switch (next_->Flush()) {
56  LOG(FATAL) << "Hybrid grid generation must be configured to occur after "
57  "any stages that require multiple passes.";
58 
61  }
62  LOG(FATAL) << "Failed to receive FlushResult::kFinished";
63  // The following unreachable return statement is needed to avoid a GCC bug
64  // described at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81508
66 }
67 
68 } // namespace io
69 } // namespace cartographer
virtual void Process(std::unique_ptr< PointsBatch > points_batch)=0
proto::HybridGrid ToProto() const
Definition: hybrid_grid.h:528
std::function< std::unique_ptr< FileWriter >(const std::string &filename)> FileWriterFactory
Definition: file_writer.h:66
proto::RangeDataInserterOptions3D CreateRangeDataInserterOptions3D(common::LuaParameterDictionary *parameter_dictionary)
HybridGrid hybrid_grid_
void Insert(const sensor::RangeData &range_data, HybridGrid *hybrid_grid) const
static std::unique_ptr< HybridGridPointsProcessor > FromDictionary(const FileWriterFactory &file_writer_factory, common::LuaParameterDictionary *dictionary, PointsProcessor *next)
std::unique_ptr< ProbabilityGridRangeDataInserter2D > range_data_inserter_
HybridGridPointsProcessor(double voxel_size, const mapping::proto::RangeDataInserterOptions3D &range_data_inserter_options, std::unique_ptr< FileWriter > file_writer, PointsProcessor *next)
virtual FlushResult Flush()=0
void Process(std::unique_ptr< PointsBatch > batch) override
std::unique_ptr< LuaParameterDictionary > GetDictionary(const std::string &key)


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58