probability_grid_points_processor.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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 // Creates a probability grid with the specified 'resolution'. As all points are
00036 // projected into the x-y plane the z component of the data is ignored.
00037 // 'range_data_inserter' options are used to configure the range data ray
00038 // tracing through the probability grid.
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 // Draws 'probability_grid' into an image and fills in 'offset' with the cropped
00080 // map limits. Returns 'nullptr' if probability_grid was empty.
00081 std::unique_ptr<Image> DrawProbabilityGrid(
00082     const mapping::ProbabilityGrid& probability_grid, Eigen::Array2i* offset);
00083 
00084 // Create an initially empty probability grid with 'resolution' and a small
00085 // size, suitable for a PointsBatchProcessor.
00086 mapping::ProbabilityGrid CreateProbabilityGrid(
00087     const double resolution, mapping::ValueConversionTables* conversion_tables);
00088 
00089 }  // namespace io
00090 }  // namespace cartographer
00091 
00092 #endif  // CARTOGRAPHER_IO_PROBABILITY_GRID_POINTS_PROCESSOR_H_


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35