Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef CARTOGRAPHER_IO_PROBABILITY_GRID_POINTS_PROCESSOR_H_
00018 #define CARTOGRAPHER_IO_PROBABILITY_GRID_POINTS_PROCESSOR_H_
00019
00020 #include <memory>
00021
00022 #include "cartographer/io/file_writer.h"
00023 #include "cartographer/io/image.h"
00024 #include "cartographer/io/points_batch.h"
00025 #include "cartographer/io/points_processor.h"
00026 #include "cartographer/mapping/2d/probability_grid.h"
00027 #include "cartographer/mapping/2d/probability_grid_range_data_inserter_2d.h"
00028 #include "cartographer/mapping/proto/2d/probability_grid_range_data_inserter_options_2d.pb.h"
00029 #include "cartographer/mapping/proto/trajectory.pb.h"
00030 #include "cartographer/mapping/value_conversion_tables.h"
00031
00032 namespace cartographer {
00033 namespace io {
00034
00035
00036
00037
00038
00039 class ProbabilityGridPointsProcessor : public PointsProcessor {
00040 public:
00041 constexpr static const char* kConfigurationFileActionName =
00042 "write_probability_grid";
00043 enum class DrawTrajectories { kNo, kYes };
00044 enum class OutputType { kPng, kPb };
00045 ProbabilityGridPointsProcessor(
00046 double resolution,
00047 const mapping::proto::ProbabilityGridRangeDataInserterOptions2D&
00048 probability_grid_range_data_inserter_options,
00049 const DrawTrajectories& draw_trajectories, const OutputType& output_type,
00050 std::unique_ptr<FileWriter> file_writer,
00051 const std::vector<mapping::proto::Trajectory>& trajectories,
00052 PointsProcessor* next);
00053 ProbabilityGridPointsProcessor(const ProbabilityGridPointsProcessor&) =
00054 delete;
00055 ProbabilityGridPointsProcessor& operator=(
00056 const ProbabilityGridPointsProcessor&) = delete;
00057
00058 static std::unique_ptr<ProbabilityGridPointsProcessor> FromDictionary(
00059 const std::vector<mapping::proto::Trajectory>& trajectories,
00060 const FileWriterFactory& file_writer_factory,
00061 common::LuaParameterDictionary* dictionary, PointsProcessor* next);
00062
00063 ~ProbabilityGridPointsProcessor() override {}
00064
00065 void Process(std::unique_ptr<PointsBatch> batch) override;
00066 FlushResult Flush() override;
00067
00068 private:
00069 const DrawTrajectories draw_trajectories_;
00070 const OutputType output_type_;
00071 const std::vector<mapping::proto::Trajectory> trajectories_;
00072 std::unique_ptr<FileWriter> file_writer_;
00073 PointsProcessor* const next_;
00074 mapping::ProbabilityGridRangeDataInserter2D range_data_inserter_;
00075 mapping::ValueConversionTables conversion_tables_;
00076 mapping::ProbabilityGrid probability_grid_;
00077 };
00078
00079
00080
00081 std::unique_ptr<Image> DrawProbabilityGrid(
00082 const mapping::ProbabilityGrid& probability_grid, Eigen::Array2i* offset);
00083
00084
00085
00086 mapping::ProbabilityGrid CreateProbabilityGrid(
00087 const double resolution, mapping::ValueConversionTables* conversion_tables);
00088
00089 }
00090 }
00091
00092 #endif // CARTOGRAPHER_IO_PROBABILITY_GRID_POINTS_PROCESSOR_H_