voxel_filter.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_SENSOR_INTERNAL_VOXEL_FILTER_H_
18 #define CARTOGRAPHER_SENSOR_INTERNAL_VOXEL_FILTER_H_
19 
20 #include <bitset>
21 #include <unordered_set>
22 
25 #include "cartographer/sensor/proto/adaptive_voxel_filter_options.pb.h"
27 
28 namespace cartographer {
29 namespace sensor {
30 
31 // Voxel filter for point clouds. For each voxel, the assembled point cloud
32 // contains the first point that fell into it from any of the inserted point
33 // clouds.
34 class VoxelFilter {
35  public:
36  // 'size' is the length of a voxel edge.
37  explicit VoxelFilter(float size) : resolution_(size) {}
38 
39  VoxelFilter(const VoxelFilter&) = delete;
40  VoxelFilter& operator=(const VoxelFilter&) = delete;
41 
42  // Returns a voxel filtered copy of 'point_cloud'.
43  PointCloud Filter(const PointCloud& point_cloud);
44 
45  // Same for TimedPointCloud.
46  TimedPointCloud Filter(const TimedPointCloud& timed_point_cloud);
47 
48  // Same for RangeMeasurement.
49  std::vector<sensor::TimedPointCloudOriginData::RangeMeasurement> Filter(
50  const std::vector<sensor::TimedPointCloudOriginData::RangeMeasurement>&
51  range_measurements);
52 
53  private:
54  using KeyType = std::bitset<3 * 32>;
55 
56  static KeyType IndexToKey(const Eigen::Array3i& index);
57 
58  Eigen::Array3i GetCellIndex(const Eigen::Vector3f& point) const;
59 
60  float resolution_;
61  std::unordered_set<KeyType> voxel_set_;
62 };
63 
64 proto::AdaptiveVoxelFilterOptions CreateAdaptiveVoxelFilterOptions(
65  common::LuaParameterDictionary* const parameter_dictionary);
66 
68  public:
69  explicit AdaptiveVoxelFilter(
70  const proto::AdaptiveVoxelFilterOptions& options);
71 
74 
75  PointCloud Filter(const PointCloud& point_cloud) const;
76 
77  private:
78  const proto::AdaptiveVoxelFilterOptions options_;
79 };
80 
81 } // namespace sensor
82 } // namespace cartographer
83 
84 #endif // CARTOGRAPHER_SENSOR_INTERNAL_VOXEL_FILTER_H_
static KeyType IndexToKey(const Eigen::Array3i &index)
Eigen::Array3i GetCellIndex(const Eigen::Vector3f &point) const
std::vector< Eigen::Vector3f > PointCloud
Definition: point_cloud.h:32
VoxelFilter & operator=(const VoxelFilter &)=delete
proto::AdaptiveVoxelFilterOptions CreateAdaptiveVoxelFilterOptions(common::LuaParameterDictionary *const parameter_dictionary)
std::vector< Eigen::Vector4f > TimedPointCloud
Definition: point_cloud.h:39
std::bitset< 3 *32 > KeyType
Definition: voxel_filter.h:54
const proto::AdaptiveVoxelFilterOptions options_
Definition: voxel_filter.h:78
std::unordered_set< KeyType > voxel_set_
Definition: voxel_filter.h:61
PointCloud Filter(const PointCloud &point_cloud)
Definition: voxel_filter.cc:81


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