Autoware.Auto
ndt_map.hpp
Go to the documentation of this file.
1 // Copyright 2019 the Autoware Foundation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // Co-developed by Tier IV, Inc. and Apex.AI, Inc.
16 
17 #ifndef NDT__NDT_MAP_HPP_
18 #define NDT__NDT_MAP_HPP_
19 
20 #include <ndt/ndt_common.hpp>
21 #include <ndt/ndt_voxel.hpp>
22 #include <ndt/ndt_voxel_view.hpp>
23 #include <ndt/ndt_grid.hpp>
24 #include <sensor_msgs/point_cloud2_iterator.hpp>
26 #include <vector>
27 #include <limits>
28 #include <unordered_map>
29 #include <utility>
30 #include <string>
31 
33 
34 namespace autoware
35 {
36 namespace localization
37 {
38 namespace ndt
39 {
47 uint32_t NDT_PUBLIC validate_pcl_map(const sensor_msgs::msg::PointCloud2 & msg);
48 
51 class NDT_PUBLIC DynamicNDTMap
52 {
53 public:
56  using Point = Eigen::Vector3d;
57  using TimePoint = std::chrono::system_clock::time_point;
58  using VoxelViewVector = std::vector<VoxelView<Voxel>>;
61 
62  explicit DynamicNDTMap(const Config & voxel_grid_config);
63 
66  void set(const sensor_msgs::msg::PointCloud2 & msg);
67 
71  void insert(const sensor_msgs::msg::PointCloud2 & msg);
72 
78  template<typename DeserializingMapT>
79  void serialize_as(sensor_msgs::msg::PointCloud2 & msg_out) const;
80 
85  const VoxelViewVector & cell(const Point & pt) const;
86 
93  const VoxelViewVector & cell(float32_t x, float32_t y, float32_t z) const;
94 
97  const std::string & frame_id() const noexcept;
98 
101  TimePoint stamp() const noexcept;
102 
105  bool valid() const noexcept;
106 
109  const ConfigPoint & cell_size() const noexcept;
110 
114  std::size_t size() const noexcept;
115 
118  typename VoxelGrid::const_iterator begin() const noexcept;
119 
122  typename VoxelGrid::const_iterator end() const noexcept;
123 
125  void clear() noexcept;
126 
127 private:
128  NDTGrid<DynamicNDTVoxel> m_grid;
129  TimePoint m_stamp{};
130  std::string m_frame_id{};
131 };
132 
136 class NDT_PUBLIC StaticNDTMap
137 {
138 public:
141  using TimePoint = std::chrono::system_clock::time_point;
142  using Point = Eigen::Vector3d;
143  using VoxelViewVector = std::vector<VoxelView<Voxel>>;
146 
147  explicit StaticNDTMap(const Config & voxel_grid_config);
148 
157  void set(const sensor_msgs::msg::PointCloud2 & msg);
158 
163  const VoxelViewVector & cell(const Point & pt) const;
164 
171  const VoxelViewVector & cell(float32_t x, float32_t y, float32_t z) const;
172 
175  const std::string & frame_id() const noexcept;
176 
179  TimePoint stamp() const noexcept;
180 
183  bool valid() const noexcept;
184 
187  const ConfigPoint & cell_size() const noexcept;
188 
192  std::size_t size() const noexcept;
193 
196  typename VoxelGrid::const_iterator begin() const noexcept;
197 
200  typename VoxelGrid::const_iterator end() const noexcept;
201 
203  void clear() noexcept;
204 
205 private:
208  void deserialize_from(const sensor_msgs::msg::PointCloud2 & msg);
209  NDTGrid<StaticNDTVoxel> m_grid;
210  TimePoint m_stamp{};
211  std::string m_frame_id{};
212 };
213 
214 } // namespace ndt
215 } // namespace localization
216 } // namespace autoware
217 #endif // NDT__NDT_MAP_HPP_
A voxel grid implementation for normal distribution transform.
Definition: ndt_grid.hpp:40
float float32_t
Definition: types.hpp:36
std::decay_t< decltype(std::declval< Config >().get_min_point())> ConfigPoint
Definition: ndt_grid.hpp:47
std::unordered_map< uint64_t, VoxelT > Grid
Definition: ndt_grid.hpp:43
std::vector< VoxelView< Voxel > > VoxelViewVector
Definition: ndt_map.hpp:143
Eigen::Vector3d Point
Definition: ndt_map.hpp:56
A configuration class for the VoxelGrid data structure, also includes some helper functionality for c...
Definition: perception/filters/voxel_grid/include/voxel_grid/config.hpp:52
NDTGrid< Voxel >::Grid VoxelGrid
Definition: ndt_map.hpp:59
NDTGrid< Voxel >::ConfigPoint ConfigPoint
Definition: ndt_map.hpp:60
DifferentialState x
Definition: kinematic_bicycle.snippet.hpp:28
std::chrono::system_clock::time_point TimePoint
Definition: ndt_map.hpp:57
DifferentialState y
Definition: kinematic_bicycle.snippet.hpp:28
uint32_t NDT_PUBLIC validate_pcl_map(const sensor_msgs::msg::PointCloud2 &msg)
Definition: ndt_map.cpp:28
Eigen::Vector3d Point
Definition: ndt_map.hpp:142
end
Definition: scripts/get_open_port.py:23
std::chrono::system_clock::time_point TimePoint
Definition: ndt_map.hpp:141
NDTGrid< Voxel >::Grid VoxelGrid
Definition: ndt_map.hpp:144
NDTGrid< Voxel >::ConfigPoint ConfigPoint
Definition: ndt_map.hpp:145
std::vector< VoxelView< Voxel > > VoxelViewVector
Definition: ndt_map.hpp:58
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24