27 const double resolution,
28 const ::cartographer::mapping::proto::
29 ProbabilityGridRangeDataInserterOptions2D& range_data_inserter_options,
31 const std::string& filestem,
33 : filestem_(filestem),
35 file_writer_factory_(file_writer_factory),
40 std::unique_ptr<RosMapWritingPointsProcessor>
45 return ::cartographer::common::make_unique<RosMapWritingPointsProcessor>(
47 ::cartographer::mapping::CreateProbabilityGridRangeDataInserterOptions2D(
49 file_writer_factory, dictionary->
GetString(
"filestem"), next);
53 std::unique_ptr<::cartographer::io::PointsBatch> batch) {
56 next_->Process(std::move(batch));
61 Eigen::Array2i offset;
62 std::unique_ptr<::cartographer::io::Image> image =
64 if (image !=
nullptr) {
66 const std::string pgm_filename = pgm_writer->GetFilename();
68 image->Rotate90DegreesClockwise();
70 WritePgm(*image, limits.resolution(), pgm_writer.get());
71 CHECK(pgm_writer->Close());
73 const Eigen::Vector2d origin(
74 limits.max().x() - (offset.y() + image->width()) * limits.resolution(),
76 (offset.x() + image->height()) * limits.resolution());
78 WriteYaml(limits.resolution(), origin, pgm_filename, yaml_writer.get());
79 CHECK(yaml_writer->Close());
82 switch (
next_->Flush()) {
84 LOG(FATAL) <<
"ROS map writing must be configured to occur after any " 85 "stages that require multiple passes.";
void WriteYaml(const double resolution, const Eigen::Vector2d &origin, const std::string &pgm_filename, ::cartographer::io::FileWriter *file_writer)
std::function< std::unique_ptr< FileWriter >(const std::string &filename)> FileWriterFactory
std::string GetString(const std::string &key)
void WritePgm(const ::cartographer::io::Image &image, const double resolution, ::cartographer::io::FileWriter *file_writer)
::cartographer::mapping::ProbabilityGrid probability_grid_
double GetDouble(const std::string &key)
static std::unique_ptr< RosMapWritingPointsProcessor > FromDictionary(::cartographer::io::FileWriterFactory file_writer_factory, ::cartographer::common::LuaParameterDictionary *dictionary, PointsProcessor *next)
::cartographer::mapping::ProbabilityGridRangeDataInserter2D range_data_inserter_
mapping::ProbabilityGrid CreateProbabilityGrid(const double resolution)
::cartographer::io::FileWriterFactory file_writer_factory_
FlushResult Flush() override
const std::string filestem_
RangeDataInserter3D range_data_inserter_
std::unique_ptr< LuaParameterDictionary > GetDictionary(const std::string &key)
const MapLimits & limits() const
void Process(std::unique_ptr<::cartographer::io::PointsBatch > batch) override
ProbabilityGrid probability_grid_
virtual void Insert(const sensor::RangeData &range_data, GridInterface *grid) const override
PointsProcessor *const next_
RosMapWritingPointsProcessor(double resolution, const ::cartographer::mapping::proto::ProbabilityGridRangeDataInserterOptions2D &range_data_inserter_options, ::cartographer::io::FileWriterFactory file_writer_factory, const std::string &filestem, PointsProcessor *next)