Apollo 11.0
自动驾驶开放平台
lossless_map.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
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
18
19#include "cyber/common/log.h"
21
22namespace apollo {
23namespace localization {
24namespace msf {
26
28
29void LosslessMap::SetValue(const Eigen::Vector3d& coordinate, int zone_id,
30 unsigned char intensity) {
31 for (size_t i = 0; i < map_config_->map_resolutions_.size(); ++i) {
33 *map_config_, coordinate, static_cast<unsigned int>(i), zone_id);
34 LosslessMapNode* node =
35 static_cast<LosslessMapNode*>(GetMapNodeSafe(index));
36 node->SetValue(coordinate, intensity);
37 }
38}
39
40void LosslessMap::SetValueLayer(const Eigen::Vector3d& coordinate, int zone_id,
41 unsigned char intensity) {
42 for (size_t i = 0; i < map_config_->map_resolutions_.size(); ++i) {
44 *map_config_, coordinate, static_cast<unsigned int>(i), zone_id);
45 LosslessMapNode* node =
46 static_cast<LosslessMapNode*>(GetMapNodeSafe(index));
47 node->SetValueLayer(coordinate, intensity);
48 }
49}
50
51void LosslessMap::GetValue(const Eigen::Vector3d& coordinate, int zone_id,
52 unsigned int resolution_id,
53 std::vector<unsigned char>* values) {
54 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
56 resolution_id, zone_id);
57 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNode(index));
58 node->GetValue(coordinate, values);
59}
60
61void LosslessMap::GetValueSafe(const Eigen::Vector3d& coordinate, int zone_id,
62 unsigned int resolution_id,
63 std::vector<unsigned char>* values) {
64 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
66 resolution_id, zone_id);
67 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNodeSafe(index));
68 node->GetValue(coordinate, values);
69}
70
71void LosslessMap::GetVar(const Eigen::Vector3d& coordinate, int zone_id,
72 unsigned int resolution_id, std::vector<float>* vars) {
73 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
75 resolution_id, zone_id);
76 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNode(index));
77 node->GetVar(coordinate, vars);
78}
79
80void LosslessMap::GetVarSafe(const Eigen::Vector3d& coordinate, int zone_id,
81 unsigned int resolution_id,
82 std::vector<float>* vars) {
83 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
85 resolution_id, zone_id);
86 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNodeSafe(index));
87 node->GetVar(coordinate, vars);
88}
89
90void LosslessMap::GetAlt(const Eigen::Vector3d& coordinate, int zone_id,
91 unsigned int resolution_id, std::vector<float>* alts) {
92 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
94 resolution_id, zone_id);
95 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNode(index));
96 node->GetAlt(coordinate, alts);
97}
98
99void LosslessMap::GetAltSafe(const Eigen::Vector3d& coordinate, int zone_id,
100 unsigned int resolution_id,
101 std::vector<float>* alts) {
102 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
104 resolution_id, zone_id);
105 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNodeSafe(index));
106 node->GetAlt(coordinate, alts);
107}
108
109void LosslessMap::GetAltVar(const Eigen::Vector3d& coordinate, int zone_id,
110 unsigned int resolution_id,
111 std::vector<float>* alt_vars) {
112 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
114 resolution_id, zone_id);
115 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNode(index));
116 node->GetAltVar(coordinate, alt_vars);
117}
118
119void LosslessMap::GetAltVarSafe(const Eigen::Vector3d& coordinate, int zone_id,
120 unsigned int resolution_id,
121 std::vector<float>* alt_vars) {
122 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
124 resolution_id, zone_id);
125 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNodeSafe(index));
126 node->GetAltVar(coordinate, alt_vars);
127}
128
129void LosslessMap::GetCount(const Eigen::Vector3d& coordinate, int zone_id,
130 unsigned int resolution_id,
131 std::vector<unsigned int>* counts) {
132 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
134 resolution_id, zone_id);
135 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNode(index));
136 node->GetCount(coordinate, counts);
137}
138
139void LosslessMap::GetCountSafe(const Eigen::Vector3d& coordinate, int zone_id,
140 unsigned int resolution_id,
141 std::vector<unsigned int>* counts) {
142 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
144 resolution_id, zone_id);
145 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNodeSafe(index));
146 node->GetCount(coordinate, counts);
147}
148
149unsigned char LosslessMap::GetValue(const Eigen::Vector3d& coordinate,
150 int zone_id, unsigned int resolution_id) {
151 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
153 resolution_id, zone_id);
154 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNode(index));
155 return node->GetValue(coordinate);
156}
157
158unsigned char LosslessMap::GetValueSafe(const Eigen::Vector3d& coordinate,
159 int zone_id,
160 unsigned int resolution_id) {
161 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
163 resolution_id, zone_id);
164 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNodeSafe(index));
165 return node->GetValue(coordinate);
166}
167
168float LosslessMap::GetVar(const Eigen::Vector3d& coordinate, int zone_id,
169 unsigned int resolution_id) {
170 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
172 resolution_id, zone_id);
173 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNode(index));
174 return node->GetVar(coordinate);
175}
176
177float LosslessMap::GetVarSafe(const Eigen::Vector3d& coordinate, int zone_id,
178 unsigned int resolution_id) {
179 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
181 resolution_id, zone_id);
182 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNodeSafe(index));
183 return node->GetVar(coordinate);
184}
185
186float LosslessMap::GetAlt(const Eigen::Vector3d& coordinate, int zone_id,
187 unsigned int resolution_id) {
188 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
190 resolution_id, zone_id);
191 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNode(index));
192 return node->GetAlt(coordinate);
193}
194
195float LosslessMap::GetAltSafe(const Eigen::Vector3d& coordinate, int zone_id,
196 unsigned int resolution_id) {
197 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
199 resolution_id, zone_id);
200 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNodeSafe(index));
201 return node->GetAlt(coordinate);
202}
203
204float LosslessMap::GetAltVar(const Eigen::Vector3d& coordinate, int zone_id,
205 unsigned int resolution_id) {
206 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
208 resolution_id, zone_id);
209 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNode(index));
210 return node->GetAltVar(coordinate);
211}
212
213float LosslessMap::GetAltVarSafe(const Eigen::Vector3d& coordinate, int zone_id,
214 unsigned int resolution_id) {
215 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
217 resolution_id, zone_id);
218 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNodeSafe(index));
219 return node->GetAltVar(coordinate);
220}
221
222unsigned int LosslessMap::GetCount(const Eigen::Vector3d& coordinate,
223 int zone_id, unsigned int resolution_id) {
224 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
226 resolution_id, zone_id);
227 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNode(index));
228 return node->GetCount(coordinate);
229}
230
231unsigned int LosslessMap::GetCountSafe(const Eigen::Vector3d& coordinate,
232 int zone_id,
233 unsigned int resolution_id) {
234 DCHECK_LT(resolution_id, map_config_->map_resolutions_.size());
236 resolution_id, zone_id);
237 LosslessMapNode* node = static_cast<LosslessMapNode*>(GetMapNodeSafe(index));
238 return node->GetCount(coordinate);
239}
240
241void LosslessMap::PreloadMapArea(const Eigen::Vector3d& location,
242 const Eigen::Vector3d& trans_diff,
243 unsigned int resolution_id,
244 unsigned int zone_id) {
245 BaseMap::PreloadMapArea(location, trans_diff, resolution_id, zone_id);
246}
247
248bool LosslessMap::LoadMapArea(const Eigen::Vector3d& seed_pt3d,
249 unsigned int resolution_id, unsigned int zone_id,
250 int filter_size_x, int filter_size_y) {
251 BaseMap::LoadMapArea(seed_pt3d, resolution_id, zone_id, filter_size_x,
252 filter_size_y);
253 return true;
254}
255
256} // namespace msf
257} // namespace localization
258} // namespace apollo
std::vector< float > map_resolutions_
The pixel resolutions in the map in meters.
The data structure of the base map.
Definition base_map.h:35
virtual bool LoadMapArea(const Eigen::Vector3d &seed_pt3d, unsigned int resolution_id, unsigned int zone_id, int filter_size_x, int filter_size_y)
Load map nodes for the location calculate of this frame.
Definition base_map.cc:407
BaseMapConfig * map_config_
The map settings.
Definition base_map.h:105
BaseMapNode * GetMapNodeSafe(const MapNodeIndex &index)
Return the map node, if it's not in the cache, safely load it.
Definition base_map.cc:67
virtual void PreloadMapArea(const Eigen::Vector3d &location, const Eigen::Vector3d &trans_diff, unsigned int resolution_id, unsigned int zone_id)
Preload map nodes for the next frame location calculation.
Definition base_map.cc:268
BaseMapNode * GetMapNode(const MapNodeIndex &index)
Get the map node, if it's not in the cache, return false.
Definition base_map.cc:61
The options of the reflectance map.
void SetValue(const Eigen::Vector3d &coordinate, unsigned char intensity)
Set the value of a pixel in the map node.
void GetAlt(const Eigen::Vector3d &coordinate, std::vector< float > *alts) const
Given the 3D global coordinate, get the map cell's average altitude of each layer.
void SetValueLayer(const Eigen::Vector3d &coordinate, unsigned char intensity)
Set the value of a pixel in a layer in the map node.
void GetAltVar(const Eigen::Vector3d &coordinate, std::vector< float > *alt_vars) const
Given the 3D global coordinate, get the map cell's variance of the altitude of each layer.
void GetValue(const Eigen::Vector3d &coordinate, std::vector< unsigned char > *values) const
Given the 3D global coordinate, get the map cell average intensity of each layer.
void GetCount(const Eigen::Vector3d &coordinate, std::vector< unsigned int > *counts) const
Given the 3D global coordinate, get the map cell's count of the samples of each layer.
void GetVar(const Eigen::Vector3d &coordinate, std::vector< float > *vars) const
Given the 3D global coordinate, get the map cell variance of the intensity of each layer.
void SetValueLayer(const Eigen::Vector3d &coordinate, int zone_id, unsigned char intensity)
Set the vlaue of a pixel in a layer in the map node.
void GetValueSafe(const Eigen::Vector3d &coordinate, int zone_id, unsigned int resolution_id, std::vector< unsigned char > *values)
Given the 3D global coordinate, this function loads the corresponding map node in the cache thread sa...
void GetVar(const Eigen::Vector3d &coordinate, int zone_id, unsigned int resolution_id, std::vector< float > *vars)
Given the 3D global coordinate, this function loads the corresponding map node in the cache and retur...
virtual void PreloadMapArea(const Eigen::Vector3d &location, const Eigen::Vector3d &trans_diff, unsigned int resolution_id, unsigned int zone_id)
Preload map nodes for the next frame location calculation.
void GetCount(const Eigen::Vector3d &coordinate, int zone_id, unsigned int resolution_id, std::vector< unsigned int > *counts)
Get the number of samples in the map cell.
void GetAltSafe(const Eigen::Vector3d &coordinate, int zone_id, unsigned int resolution_id, std::vector< float > *alts)
Given the 3D global coordinate, this function loads the corresponding map node in the cache thread sa...
void GetAltVarSafe(const Eigen::Vector3d &coordinate, int zone_id, unsigned int resolution_id, std::vector< float > *alt_vars)
Given the 3D global coordinate, this function loads the corresponding map node in the cache thread sa...
void GetCountSafe(const Eigen::Vector3d &coordinate, int zone_id, unsigned int resolution_id, std::vector< unsigned int > *counts)
Get the number of samples in the map cell thread safely.
void GetVarSafe(const Eigen::Vector3d &coordinate, int zone_id, unsigned int resolution_id, std::vector< float > *vars)
Given the 3D global coordinate, this function loads the corresponding map node in the cache thread sa...
void GetAlt(const Eigen::Vector3d &coordinate, int zone_id, unsigned int resolution_id, std::vector< float > *alts)
Given the 3D global coordinate, this function loads the corresponding map node in the cache and retur...
void GetAltVar(const Eigen::Vector3d &coordinate, int zone_id, unsigned int resolution_id, std::vector< float > *alt_vars)
Given the 3D global coordinate, this function loads the corresponding map node in the cache and retur...
virtual bool LoadMapArea(const Eigen::Vector3d &seed_pt3d, unsigned int resolution_id, unsigned int zone_id, int filter_size_x, int filter_size_y)
Load map nodes for the location calculate of this frame.
LosslessMap(LosslessMapConfig *config)
void GetValue(const Eigen::Vector3d &coordinate, int zone_id, unsigned int resolution_id, std::vector< unsigned char > *values)
Given the 3D global coordinate, this function loads the corresponding map node in the cache and retur...
void SetValue(const Eigen::Vector3d &coordinate, int zone_id, unsigned char intensity)
Set the value of a pixel in the map, including all the resolution levels.
static MapNodeIndex GetMapNodeIndex(const BaseMapConfig &option, const Eigen::Vector3d &coordinate, unsigned int resolution_id, int zone_id)
Construct a map node index, given a global coordinate, eigen version.
class register implement
Definition arena_queue.h:37