Apollo 10.0
自动驾驶开放平台
apollo::localization::msf::NdtMapSingleCell类 参考

The data structure of a single ndt map cell. 更多...

#include <ndt_map_matrix.h>

apollo::localization::msf::NdtMapSingleCell 的协作图:

Public 成员函数

 NdtMapSingleCell ()
 The default constructor.
 
void Reset ()
 Reset to default value.
 
unsigned int LoadBinary (unsigned char *buf)
 Load the map cell from a binary chunk.
 
unsigned int CreateBinary (unsigned char *buf, unsigned int buf_size) const
 Create the binary.
 
unsigned int GetBinarySize () const
 Get the binary size of the object.
 
NdtMapSingleCelloperator= (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 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.
 
void MergeCell (const NdtMapSingleCell &cell_new)
 
void CentroidEigenSolver (const Eigen::Matrix3f &centroid_cov)
 

静态 Public 成员函数

static void Reduce (NdtMapSingleCell *cell, const NdtMapSingleCell &cell_new)
 Combine two NdtMapSingleCell instances (Reduce).
 

Public 属性

float intensity_ = 0
 The average intensity value.
 
float intensity_var_ = 0
 The variance intensity value.
 
unsigned int road_pt_count_ = 0
 The number of samples belonging to road surface.
 
unsigned int count_ = 0
 The number of samples in the cell.
 
Eigen::Vector3f centroid_
 the centroid of the cell.
 
Eigen::Matrix3f centroid_average_cov_
 the pose covariance of the cell.
 
Eigen::Matrix3f centroid_icov_
 the pose inverse covariance of the cell.
 
unsigned char is_icov_available_ = 0
 the inverse covariance available flag.
 
const unsigned int minimum_points_threshold_ = 6
 minimum number of points needed.
 

详细描述

The data structure of a single ndt map cell.

在文件 ndt_map_matrix.h34 行定义.

构造及析构函数说明

◆ NdtMapSingleCell()

apollo::localization::msf::NdtMapSingleCell::NdtMapSingleCell ( )

The default constructor.

在文件 ndt_map_matrix.cc24 行定义.

24 {
25 intensity_ = 0.0;
26 intensity_var_ = 0.0;
28 count_ = 0;
29 centroid_ = Eigen::Vector3f::Zero();
30 centroid_average_cov_ = Eigen::Matrix3f::Zero();
31 centroid_icov_ = Eigen::Matrix3f::Identity();
33}
float intensity_var_
The variance intensity value.
unsigned char is_icov_available_
the inverse covariance available flag.
Eigen::Vector3f centroid_
the centroid of the cell.
Eigen::Matrix3f centroid_icov_
the pose inverse covariance of the cell.
Eigen::Matrix3f centroid_average_cov_
the pose covariance of the cell.
unsigned int road_pt_count_
The number of samples belonging to road surface.
unsigned int count_
The number of samples in the cell.
float intensity_
The average intensity value.

成员函数说明

◆ AddSample()

void apollo::localization::msf::NdtMapSingleCell::AddSample ( const float  intensity,
const float  altitude,
const Eigen::Vector3f  centroid,
bool  is_road = false 
)
inline

Add an sample to the single 3d map cell.

在文件 ndt_map_matrix.h215 行定义.

218 {
219 ++count_;
220 float v1 = intensity - intensity_;
221 intensity_ += v1 / static_cast<float>(count_);
222 float v2 = intensity - intensity_;
223 intensity_var_ = (static_cast<float>(count_ - 1) * intensity_var_ + v1 * v2) /
224 static_cast<float>(count_);
225
226 if (is_road) {
228 }
229
230 Eigen::Vector3f v3 = centroid - centroid_;
231 centroid_ += v3 / static_cast<float>(count_);
232 Eigen::Matrix3f v4 = centroid * centroid.transpose() - centroid_average_cov_;
233 centroid_average_cov_ += v4 / static_cast<float>(count_);
235}
void CentroidEigenSolver(const Eigen::Matrix3f &centroid_cov)

◆ CentroidEigenSolver()

void apollo::localization::msf::NdtMapSingleCell::CentroidEigenSolver ( const Eigen::Matrix3f &  centroid_cov)
inline

在文件 ndt_map_matrix.h266 行定义.

267 {
268 // Contain more than five points, we calculate the eigen vector/value of cov.
269 // [Magnusson 2009]
271 Eigen::Matrix3f cov = centroid_cov - centroid_ * centroid_.transpose();
272 cov *= static_cast<float>((count_ - 1.0) / count_);
273 Eigen::SelfAdjointEigenSolver<Eigen::Matrix3f> eigen_solver;
274 eigen_solver.compute(cov);
275 Eigen::Matrix3f eigen_val = eigen_solver.eigenvalues().asDiagonal();
276 Eigen::Matrix3f centroid_evecs = eigen_solver.eigenvectors();
277 if (eigen_val(0, 0) < 0 || eigen_val(1, 1) < 0 || eigen_val(2, 2) <= 0) {
279 return;
280 }
281 // Avoid matrices near singularities (eq 6.11) [Magnusson 2009].
282 float min_covar_eigvalue = 0.01f * eigen_val(2, 2);
283 if (eigen_val(0, 0) < min_covar_eigvalue) {
284 eigen_val(0, 0) = min_covar_eigvalue;
285 if (eigen_val(1, 1) < min_covar_eigvalue) {
286 eigen_val(1, 1) = min_covar_eigvalue;
287 }
288 }
289 // Calculate inverse covariance
291 (centroid_evecs * eigen_val * centroid_evecs.inverse()).inverse();
292 if (centroid_icov_.maxCoeff() == std::numeric_limits<float>::infinity() ||
293 centroid_icov_.minCoeff() == -std::numeric_limits<float>::infinity()) {
295 return;
296 }
297 // Set icov available
299 }
300}
const unsigned int minimum_points_threshold_
minimum number of points needed.

◆ CreateBinary()

unsigned int apollo::localization::msf::NdtMapSingleCell::CreateBinary ( unsigned char *  buf,
unsigned int  buf_size 
) const

Create the binary.

Serialization of the object.

参数
<buf,buf_size>The buffer and its size.
<return>The required or the used size of is returned.

在文件 ndt_map_matrix.cc77 行定义.

78 {
79 unsigned int target_size = GetBinarySize();
80 if (buf_size >= target_size) {
81 float* p = reinterpret_cast<float*>(buf);
82 *p = intensity_;
83 ++p;
84 *p = intensity_var_;
85 ++p;
86 unsigned int* pp =
87 reinterpret_cast<unsigned int*>(reinterpret_cast<void*>(p));
88 *pp = road_pt_count_;
89 ++pp;
90 *pp = count_;
91 ++pp;
92 float* ppp = reinterpret_cast<float*>(reinterpret_cast<void*>(pp));
93 *ppp = centroid_[0];
94 ++ppp;
95 *ppp = centroid_[1];
96 ++ppp;
97 *ppp = centroid_[2];
98
99 for (unsigned int i = 0; i < 3; ++i) {
100 for (unsigned int j = 0; j < 3; ++j) {
101 ++ppp;
102 *ppp = centroid_average_cov_(i, j);
103 }
104 }
106 for (unsigned int i = 0; i < 3; ++i) {
107 for (unsigned int j = 0; j < 3; ++j) {
108 ++ppp;
109 *ppp = centroid_icov_(i, j);
110 }
111 }
112 ++ppp;
113 unsigned char* pppp = reinterpret_cast<unsigned char*>(ppp);
114 *pppp = is_icov_available_;
115 }
116 }
117 return target_size;
118}
unsigned int GetBinarySize() const
Get the binary size of the object.

◆ GetBinarySize()

unsigned int apollo::localization::msf::NdtMapSingleCell::GetBinarySize ( ) const

Get the binary size of the object.

在文件 ndt_map_matrix.cc120 行定义.

120 {
121 unsigned int sz =
122 static_cast<unsigned int>(sizeof(float) * 2 + sizeof(unsigned int) * 2 +
123 sizeof(float) * 3 + sizeof(float) * 9);
125 sz += static_cast<unsigned int>(sizeof(float) * 9 +
126 sizeof(unsigned char) * 1);
127 }
128 return sz;
129}

◆ LoadBinary()

unsigned int apollo::localization::msf::NdtMapSingleCell::LoadBinary ( unsigned char *  buf)

Load the map cell from a binary chunk.

参数
<return>The size read (the real size of object).

在文件 ndt_map_matrix.cc35 行定义.

35 {
36 float* f_buf = reinterpret_cast<float*>(buf);
37 intensity_ = *f_buf;
38 ++f_buf;
39 intensity_var_ = *f_buf;
40 ++f_buf;
41 unsigned int* ui_buf =
42 reinterpret_cast<unsigned int*>(reinterpret_cast<void*>(f_buf));
43 road_pt_count_ = *ui_buf;
44 ++ui_buf;
45 count_ = *ui_buf;
46 ++ui_buf;
47 f_buf = reinterpret_cast<float*>(reinterpret_cast<void*>(ui_buf));
48 centroid_[0] = *f_buf;
49 ++f_buf;
50 centroid_[1] = *f_buf;
51 ++f_buf;
52 centroid_[2] = *f_buf;
53
54 for (unsigned int i = 0; i < 3; ++i) {
55 for (unsigned int j = 0; j < 3; ++j) {
56 ++f_buf;
57 centroid_average_cov_(i, j) = *f_buf;
58 }
59 }
61 for (unsigned int i = 0; i < 3; ++i) {
62 for (unsigned int j = 0; j < 3; ++j) {
63 ++f_buf;
64 centroid_icov_(i, j) = *f_buf;
65 }
66 }
67 ++f_buf;
68 unsigned char* uc_buf = reinterpret_cast<unsigned char*>(f_buf);
69 is_icov_available_ = *uc_buf;
70 } else {
71 centroid_icov_ = Eigen::Matrix3f::Identity();
73 }
74 return GetBinarySize();
75}

◆ MergeCell() [1/2]

void apollo::localization::msf::NdtMapSingleCell::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 
)
inline

Merge two cells.

在文件 ndt_map_matrix.h237 行定义.

242 {
243 unsigned int new_count = count_ + count;
244 float p0 = static_cast<float>(count_) / static_cast<float>(new_count);
245 float p1 = static_cast<float>(count) / static_cast<float>(new_count);
246 float intensity_diff = intensity_ - intensity;
247
248 intensity_ = intensity_ * p0 + intensity * p1;
249 intensity_var_ = intensity_var_ * p0 + intensity_var * p1 +
250 intensity_diff * intensity_diff * p0 * p1;
251
252 centroid_[0] = centroid_[0] * p0 + centroid[0] * p1;
253 centroid_[1] = centroid_[1] * p0 + centroid[1] * p1;
254 centroid_[2] = centroid_[2] * p0 + centroid[2] * p1;
255
256 count_ = new_count;
257 road_pt_count_ += road_pt_count;
258}

◆ MergeCell() [2/2]

void apollo::localization::msf::NdtMapSingleCell::MergeCell ( const NdtMapSingleCell cell_new)
inline

在文件 ndt_map_matrix.h260 行定义.

260 {
261 MergeCell(cell_new.intensity_, cell_new.intensity_var_,
262 cell_new.road_pt_count_, cell_new.count_, cell_new.centroid_,
263 cell_new.centroid_average_cov_);
264}
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.

◆ operator=()

NdtMapSingleCell & apollo::localization::msf::NdtMapSingleCell::operator= ( const NdtMapSingleCell ref)

Overloading the assign operator.

在文件 ndt_map_matrix.cc131 行定义.

131 {
132 count_ = ref.count_;
133 intensity_ = ref.intensity_;
134 intensity_var_ = ref.intensity_var_;
135 road_pt_count_ = ref.road_pt_count_;
136 centroid_ = ref.centroid_;
137 centroid_average_cov_ = ref.centroid_average_cov_;
138 centroid_icov_ = ref.centroid_icov_;
139 is_icov_available_ = ref.is_icov_available_;
140 return *this;
141}

◆ Reduce()

void apollo::localization::msf::NdtMapSingleCell::Reduce ( NdtMapSingleCell cell,
const NdtMapSingleCell cell_new 
)
static

Combine two NdtMapSingleCell instances (Reduce).

在文件 ndt_map_matrix.cc143 行定义.

144 {
145 cell->MergeCell(cell_new);
146}

◆ Reset()

void apollo::localization::msf::NdtMapSingleCell::Reset ( )
inline

Reset to default value.

在文件 ndt_map_matrix.h204 行定义.

204 {
205 intensity_ = 0.0;
206 intensity_var_ = 0.0;
207 road_pt_count_ = 0;
208 count_ = 0;
209 centroid_ = Eigen::Vector3f::Zero();
210 centroid_average_cov_ = Eigen::Matrix3f::Zero();
211 centroid_icov_ = Eigen::Matrix3f::Identity();
212 is_icov_available_ = false;
213}

类成员变量说明

◆ centroid_

Eigen::Vector3f apollo::localization::msf::NdtMapSingleCell::centroid_

the centroid of the cell.

在文件 ndt_map_matrix.h85 行定义.

◆ centroid_average_cov_

Eigen::Matrix3f apollo::localization::msf::NdtMapSingleCell::centroid_average_cov_

the pose covariance of the cell.

在文件 ndt_map_matrix.h87 行定义.

◆ centroid_icov_

Eigen::Matrix3f apollo::localization::msf::NdtMapSingleCell::centroid_icov_

the pose inverse covariance of the cell.

在文件 ndt_map_matrix.h89 行定义.

◆ count_

unsigned int apollo::localization::msf::NdtMapSingleCell::count_ = 0

The number of samples in the cell.

在文件 ndt_map_matrix.h82 行定义.

◆ intensity_

float apollo::localization::msf::NdtMapSingleCell::intensity_ = 0

The average intensity value.

在文件 ndt_map_matrix.h76 行定义.

◆ intensity_var_

float apollo::localization::msf::NdtMapSingleCell::intensity_var_ = 0

The variance intensity value.

在文件 ndt_map_matrix.h78 行定义.

◆ is_icov_available_

unsigned char apollo::localization::msf::NdtMapSingleCell::is_icov_available_ = 0

the inverse covariance available flag.

在文件 ndt_map_matrix.h91 行定义.

◆ minimum_points_threshold_

const unsigned int apollo::localization::msf::NdtMapSingleCell::minimum_points_threshold_ = 6

minimum number of points needed.

在文件 ndt_map_matrix.h93 行定义.

◆ road_pt_count_

unsigned int apollo::localization::msf::NdtMapSingleCell::road_pt_count_ = 0

The number of samples belonging to road surface.

在文件 ndt_map_matrix.h80 行定义.


该类的文档由以下文件生成: