xray_points_processor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016 The Cartographer Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CARTOGRAPHER_IO_XRAY_POINTS_PROCESSOR_H_
18 #define CARTOGRAPHER_IO_XRAY_POINTS_PROCESSOR_H_
19 
20 #include <map>
21 
22 #include "Eigen/Core"
28 #include "cartographer/mapping/proto/trajectory.pb.h"
30 
31 namespace cartographer {
32 namespace io {
33 
34 // Creates X-ray cuts through the points with pixels being 'voxel_size' big.
36  public:
37  constexpr static const char* kConfigurationFileActionName =
38  "write_xray_image";
39  enum class DrawTrajectories { kNo, kYes };
41  double voxel_size, const transform::Rigid3f& transform,
42  const std::vector<mapping::Floor>& floors,
43  const DrawTrajectories& draw_trajectories,
44  const std::string& output_filename,
45  const std::vector<mapping::proto::Trajectory>& trajectories,
46  FileWriterFactory file_writer_factory, PointsProcessor* next);
47 
48  static std::unique_ptr<XRayPointsProcessor> FromDictionary(
49  const std::vector<mapping::proto::Trajectory>& trajectories,
50  FileWriterFactory file_writer_factory,
52 
53  ~XRayPointsProcessor() override {}
54 
55  void Process(std::unique_ptr<PointsBatch> batch) override;
56  FlushResult Flush() override;
57 
58  Eigen::AlignedBox3i bounding_box() const { return bounding_box_; }
59 
60  private:
61  struct ColumnData {
62  float sum_r = 0.;
63  float sum_g = 0.;
64  float sum_b = 0.;
65  uint32_t count = 0;
66  };
67 
68  struct Aggregation {
70  std::map<std::pair<int, int>, ColumnData> column_data;
71  };
72 
73  void WriteVoxels(const Aggregation& aggregation,
74  FileWriter* const file_writer);
75  void Insert(const PointsBatch& batch, Aggregation* aggregation);
76 
78  const std::vector<mapping::proto::Trajectory> trajectories_;
81 
82  // If empty, we do not separate into floors.
83  std::vector<mapping::Floor> floors_;
84 
85  const std::string output_filename_;
87 
88  // Only has one entry if we do not separate into floors.
89  std::vector<Aggregation> aggregations_;
90 
91  // Bounding box containing all cells with data in all 'aggregations_'.
92  Eigen::AlignedBox3i bounding_box_;
93 };
94 
95 } // namespace io
96 } // namespace cartographer
97 
98 #endif // CARTOGRAPHER_IO_XRAY_POINTS_PROCESSOR_H_
std::function< std::unique_ptr< FileWriter >(const std::string &filename)> FileWriterFactory
Definition: file_writer.h:66
void Insert(const PointsBatch &batch, Aggregation *aggregation)
std::map< std::pair< int, int >, ColumnData > column_data
XRayPointsProcessor(double voxel_size, const transform::Rigid3f &transform, const std::vector< mapping::Floor > &floors, const DrawTrajectories &draw_trajectories, const std::string &output_filename, const std::vector< mapping::proto::Trajectory > &trajectories, FileWriterFactory file_writer_factory, PointsProcessor *next)
Eigen::AlignedBox3i bounding_box() const
std::vector< mapping::Floor > floors_
int count
Definition: submap_3d.cc:33
std::vector< Aggregation > aggregations_
static std::unique_ptr< XRayPointsProcessor > FromDictionary(const std::vector< mapping::proto::Trajectory > &trajectories, FileWriterFactory file_writer_factory, common::LuaParameterDictionary *dictionary, PointsProcessor *next)
const std::vector< mapping::proto::Trajectory > trajectories_
void WriteVoxels(const Aggregation &aggregation, FileWriter *const file_writer)
static constexpr const char * kConfigurationFileActionName
void Process(std::unique_ptr< PointsBatch > batch) override


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