Apollo 10.0
自动驾驶开放平台
ndt_map_matrix.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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
17#pragma once
18
19#include <limits>
20#include <memory>
21#include <unordered_map>
22#include <vector>
23
24#include "Eigen/Eigenvalues"
25
28
29namespace apollo {
30namespace localization {
31namespace msf {
32namespace pyramid_map {
33
36 public:
40 void Reset();
44 size_t LoadBinary(const unsigned char* buf);
49 size_t CreateBinary(unsigned char* buf, size_t buf_size) const;
51 size_t GetBinarySize() const;
54
56 static void Reduce(NdtMapSingleCell* cell, const NdtMapSingleCell& cell_new);
57
59 void AddSample(const float intensity, const float altitude,
60 const Eigen::Vector3f& centroid, bool is_road = false);
61
63 void MergeCell(const float intensity, const float intensity_var,
64 const unsigned int road_pt_count, const unsigned int count,
65 const Eigen::Vector3f& centroid,
66 const Eigen::Matrix3f& centroid_cov);
67
68 void MergeCell(const NdtMapSingleCell& cell_new);
69
70 void CentroidEigenSolver(const Eigen::Matrix3f& centroid_cov);
71
72 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
73
74 public:
76 float intensity_ = 0;
78 float intensity_var_ = 0;
80 unsigned int road_pt_count_ = 0;
82 unsigned int count_ = 0;
83
85 Eigen::Vector3f centroid_;
87 Eigen::Matrix3f centroid_average_cov_;
89 Eigen::Matrix3f centroid_icov_;
91 unsigned char is_icov_available_ = 0;
93 const unsigned int minimum_points_threshold_ = 6;
94};
95
98 public:
100 NdtMapCells();
102 void Reset();
104 int AddSample(const float intensity, const float altitude,
105 const float resolution, const Eigen::Vector3f& centroid,
106 bool is_road = false);
107
111 size_t LoadBinary(const unsigned char* buf);
116 size_t CreateBinary(unsigned char* buf, size_t buf_size) const;
118 size_t GetBinarySize() const;
119
121 static int CalAltitudeIndex(const float resolution, const float altitude);
122
124 static float CalAltitude(const float resolution, const int altitude_index);
125
127 static void Reduce(NdtMapCells* cell, const NdtMapCells& cell_new);
128
129 public:
131 std::unordered_map<int, NdtMapSingleCell> cells_;
137 std::vector<int> road_cell_indices_;
138};
139
142 public:
144 NdtMapMatrix();
148 NdtMapMatrix(const NdtMapMatrix& cells);
149
151 virtual void Init(const BaseMapConfig& config);
153 virtual void Reset();
154
156 void Init(unsigned int rows, unsigned int cols);
158 void Reset(unsigned int rows, unsigned int cols);
162 virtual size_t LoadBinary(const unsigned char* buf);
167 virtual size_t CreateBinary(unsigned char* buf, size_t buf_size) const;
169 virtual size_t GetBinarySize() const;
170
171 virtual bool GetIntensityImg(cv::Mat* intensity_img) const;
172
174 inline const NdtMapCells& GetMapCell(unsigned int row,
175 unsigned int col) const {
176 assert(row < rows_);
177 assert(col < cols_);
178 return map3d_cells_[row * cols_ + col];
179 }
181 inline NdtMapCells& GetMapCell(unsigned int row, unsigned int col) {
182 assert(row < rows_);
183 assert(col < cols_);
184 return map3d_cells_[row * cols_ + col];
185 }
187 unsigned int GetRows() const { return rows_; }
189 unsigned int GetCols() const { return cols_; }
190
192 static void Reduce(NdtMapMatrix* cells, const NdtMapMatrix& cells_new);
193
194 private:
196 unsigned int rows_;
198 unsigned int cols_;
200 std::unique_ptr<NdtMapCells[]> map3d_cells_;
201};
202
203} // namespace pyramid_map
204} // namespace msf
205} // namespace localization
206} // namespace apollo
The data structure of the map cells in a map node.
int AddSample(const float intensity, const float altitude, const float resolution, const Eigen::Vector3f &centroid, bool is_road=false)
Add an sample.
int min_altitude_index_
The index of smallest altitude.
int max_altitude_index_
The index of biggest altitude.
static int CalAltitudeIndex(const float resolution, const float altitude)
Calculate altitude index from altitude.
std::vector< int > road_cell_indices_
The indices of road surface.
static float CalAltitude(const float resolution, const int altitude_index)
Calculate altitude from altitude index.
static void Reduce(NdtMapCells *cell, const NdtMapCells &cell_new)
Combine two MapCell instances (Reduce).
size_t GetBinarySize() const
Get the binary size of the object.
size_t LoadBinary(const unsigned char *buf)
Load the map cell from a binary chunk.
std::unordered_map< int, NdtMapSingleCell > cells_
The multiple altitudes of the cell.
size_t CreateBinary(unsigned char *buf, size_t buf_size) const
Create the binary.
The data structure of ndt Map matrix.
NdtMapCells & GetMapCell(unsigned int row, unsigned int col)
Get a map cell.
virtual bool GetIntensityImg(cv::Mat *intensity_img) const
get intensity image of node.
static void Reduce(NdtMapMatrix *cells, const NdtMapMatrix &cells_new)
Combine two NdtMapMatrix instances (Reduce).
unsigned int GetRows() const
Get the size of row.
virtual size_t LoadBinary(const unsigned char *buf)
Load the map cell from a binary chunk.
unsigned int GetCols() const
Get the size of cols.
virtual void Reset()
Reset the matrix item to default value.
virtual size_t GetBinarySize() const
Get the binary size of the object.
virtual size_t CreateBinary(unsigned char *buf, size_t buf_size) const
Create the binary.
virtual void Init(const BaseMapConfig &config)
Initialize the matrix with the config.
const NdtMapCells & GetMapCell(unsigned int row, unsigned int col) const
Get a const map cell.
The data structure of a single ndt map cell.
void MergeCell(const float intensity, const float intensity_var, const unsigned int road_pt_count, const unsigned int count, const Eigen::Vector3f &centroid, const Eigen::Matrix3f &centroid_cov)
Merge two cells.
unsigned int road_pt_count_
The number of samples belonging to road surface.
size_t LoadBinary(const unsigned char *buf)
Load the map cell from a binary chunk.
Eigen::Vector3f centroid_
the centroid of the cell.
unsigned int count_
The number of samples in the cell.
NdtMapSingleCell & operator=(const NdtMapSingleCell &ref)
Overloading the assign operator.
void AddSample(const float intensity, const float altitude, const Eigen::Vector3f &centroid, bool is_road=false)
Add an sample to the single 3d map cell.
void CentroidEigenSolver(const Eigen::Matrix3f &centroid_cov)
static void Reduce(NdtMapSingleCell *cell, const NdtMapSingleCell &cell_new)
Combine two NdtMapSingleCell instances (Reduce).
Eigen::Matrix3f centroid_average_cov_
the pose covariance of the cell.
unsigned char is_icov_available_
the inverse covariance available flag.
Eigen::Matrix3f centroid_icov_
the pose inverse covariance of the cell.
const unsigned int minimum_points_threshold_
minimum number of points needed.
size_t CreateBinary(unsigned char *buf, size_t buf_size) const
Create the binary.
size_t GetBinarySize() const
Get the binary size of the object.
class register implement
Definition arena_queue.h:37