Apollo 11.0
自动驾驶开放平台
ndt_map_node.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
19
20namespace apollo {
21namespace localization {
22namespace msf {
23
29Eigen::Vector3d NdtMapNode::GetCoordinate3D(unsigned int x, unsigned int y,
30 int altitude_index) const {
31 const Eigen::Vector2d& left_top_corner = GetLeftTopCorner();
32 Eigen::Vector2d coord_2d;
33 coord_2d[0] =
34 left_top_corner[0] + (static_cast<double>(x)) * GetMapResolution();
35 coord_2d[1] =
36 left_top_corner[1] + (static_cast<double>(y)) * GetMapResolution();
37
38 double altitude =
40 Eigen::Vector3d coord_3d;
41 coord_3d[0] = coord_2d[0];
42 coord_3d[1] = coord_2d[1];
43 coord_3d[2] = altitude;
44
45 return coord_3d;
46}
47
48Eigen::Vector3d NdtMapNode::GetCoordinateCenter3D(unsigned int x,
49 unsigned int y,
50 int altitude_index) const {
51 const Eigen::Vector2d& left_top_corner = GetLeftTopCorner();
52 Eigen::Vector2d coord_2d;
53 coord_2d[0] =
54 left_top_corner[0] + (static_cast<double>(x) + 0.5) * GetMapResolution();
55 coord_2d[1] =
56 left_top_corner[1] + (static_cast<double>(y) + 0.5) * GetMapResolution();
57
58 double altitude =
60 Eigen::Vector3d coord_3d;
61 coord_3d[0] = coord_2d[0];
62 coord_3d[1] = coord_2d[1];
63 coord_3d[2] = altitude;
64
65 return coord_3d;
66}
67
68void NdtMapNode::Reduce(NdtMapNode* map_node, const NdtMapNode& map_node_new) {
69 assert(map_node->index_.m_ == map_node_new.index_.m_);
70 assert(map_node->index_.n_ == map_node_new.index_.n_);
71 assert(map_node->index_.resolution_id_ == map_node_new.index_.resolution_id_);
72 assert(map_node->index_.zone_id_ == map_node_new.index_.zone_id_);
74 static_cast<NdtMapMatrix*>(map_node->map_matrix_),
75 static_cast<const NdtMapMatrix&>(*map_node_new.map_matrix_));
76}
77
78} // namespace msf
79} // namespace localization
80} // namespace apollo
The data structure of a Node in the map.
const Eigen::Vector2d & GetLeftTopCorner() const
Get the left top corner of the map node.
BaseMapMatrix * map_matrix_
The data structure of the map datas, which is a matrix.
MapNodeIndex index_
The index of this node.
float GetMapResolution() const
Get the resolution of this map nodex.
unsigned int m_
The map node ID at the northing direction.
unsigned int n_
The map node ID at the easting direction.
unsigned int resolution_id_
The ID of the resolution.
static float CalAltitude(const float resolution, const int altitude_index)
Calculate altitude from altitude index.
The data structure of ndt Map matrix.
static void Reduce(NdtMapMatrix *cells, const NdtMapMatrix &cells_new)
Combine two NdtMapMatrix instances (Reduce).
unsigned int num_valid_cells_
The number of cells with elements.
static void Reduce(NdtMapNode *map_node, const NdtMapNode &map_node_new)
Combine two map nodes (Reduce operation in mapreduce).
unsigned int num_valid_single_cells_
The number of single cells with elements.
float GetMapResolutionZ() const
Get the resolution of this map nodex.
Eigen::Vector3d GetCoordinateCenter3D(unsigned int x, unsigned int y, int altitude_index) const
Given the local x, y, altitude index, return the global coordinate.
Eigen::Vector3d GetCoordinate3D(unsigned int x, unsigned int y, int altitude_index) const
Given the local x, y, altitude index, return the global coordinate.
class register implement
Definition arena_queue.h:37