outlier_removing_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_OUTLIER_REMOVING_POINTS_PROCESSOR_H_
18 #define CARTOGRAPHER_IO_OUTLIER_REMOVING_POINTS_PROCESSOR_H_
19 
23 
24 namespace cartographer {
25 namespace io {
26 
27 // Voxel filters the data and only passes on points that we believe are on
28 // non-moving objects.
30  public:
31  constexpr static const char* kConfigurationFileActionName =
32  "voxel_filter_and_remove_moving_objects";
33 
34  OutlierRemovingPointsProcessor(double voxel_size, PointsProcessor* next);
35 
36  static std::unique_ptr<OutlierRemovingPointsProcessor> FromDictionary(
38 
40 
42  delete;
44  const OutlierRemovingPointsProcessor&) = delete;
45 
46  void Process(std::unique_ptr<PointsBatch> batch) override;
47  FlushResult Flush() override;
48 
49  private:
50  // To reduce memory consumption by not having to keep all rays in memory, we
51  // filter outliers in three phases each going over all data: First we compute
52  // all voxels containing any hits, then we compute the rays passing through
53  // each of these voxels, and finally we output all hits in voxels that are
54  // considered obstructed.
55  struct VoxelData {
56  int hits = 0;
57  int rays = 0;
58  };
59  enum class State {
60  kPhase1,
61  kPhase2,
62  kPhase3,
63  };
64 
65  // First phase counts the number of hits per voxel.
66  void ProcessInPhaseOne(const PointsBatch& batch);
67 
68  // Second phase counts how many rays pass through each voxel. This is only
69  // done for voxels that contain hits. This is to reduce memory consumption by
70  // not adding data to free voxels.
71  void ProcessInPhaseTwo(const PointsBatch& batch);
72 
73  // Third phase produces the output containing all inliers. We consider each
74  // hit an inlier if it is inside a voxel that has a sufficiently high
75  // hit-to-ray ratio.
76  void ProcessInPhaseThree(std::unique_ptr<PointsBatch> batch);
77 
78  const double voxel_size_;
82 };
83 
84 } // namespace io
85 } // namespace cartographer
86 
87 #endif // CARTOGRAPHER_IO_OUTLIER_REMOVING_POINTS_PROCESSOR_H_
OutlierRemovingPointsProcessor(double voxel_size, PointsProcessor *next)
void Process(std::unique_ptr< PointsBatch > batch) override
void ProcessInPhaseThree(std::unique_ptr< PointsBatch > batch)
static std::unique_ptr< OutlierRemovingPointsProcessor > FromDictionary(common::LuaParameterDictionary *dictionary, PointsProcessor *next)
OutlierRemovingPointsProcessor & operator=(const OutlierRemovingPointsProcessor &)=delete


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