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

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

#include <ndt_map_matrix.h>

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

Public 成员函数

 NdtMapSingleCell ()
 The default constructor.
 
void Reset ()
 Reset to default value.
 
size_t LoadBinary (const unsigned char *buf)
 Load the map cell from a binary chunk.
 
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.
 
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.h35 行定义.

构造及析构函数说明

◆ NdtMapSingleCell()

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

The default constructor.

在文件 ndt_map_matrix.cc26 行定义.

26 {
27 intensity_ = 0.0;
28 intensity_var_ = 0.0;
30 count_ = 0;
31 centroid_ = Eigen::Vector3f::Zero();
32 centroid_average_cov_ = Eigen::Matrix3f::Zero();
33 centroid_icov_ = Eigen::Matrix3f::Identity();
35}
unsigned int road_pt_count_
The number of samples belonging to road surface.
Eigen::Vector3f centroid_
the centroid of the cell.
unsigned int count_
The number of samples in the cell.
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.

成员函数说明

◆ AddSample()

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

Add an sample to the single 3d map cell.

在文件 ndt_map_matrix.cc159 行定义.

161 {
162 ++count_;
163 float v1 = intensity - intensity_;
164 intensity_ += v1 / static_cast<float>(count_);
165 float v2 = intensity - intensity_;
166 intensity_var_ = (static_cast<float>(count_ - 1) * intensity_var_ + v1 * v2) /
167 static_cast<float>(count_);
168
169 if (is_road) {
171 }
172
173 Eigen::Vector3f v3 = centroid - centroid_;
174 centroid_ += v3 / static_cast<float>(count_);
175 Eigen::Matrix3f v4 = centroid * centroid.transpose() - centroid_average_cov_;
176 centroid_average_cov_ += v4 / static_cast<float>(count_);
178}
void CentroidEigenSolver(const Eigen::Matrix3f &centroid_cov)

◆ CentroidEigenSolver()

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

在文件 ndt_map_matrix.cc209 行定义.

210 {
211 // Contain more than five points, we calculate the eigen vector/value of cov.
212 // [Magnusson 2009]
214 Eigen::Matrix3f cov = centroid_cov - centroid_ * centroid_.transpose();
215 cov *= static_cast<float>((count_ - 1.0) / count_);
216 Eigen::SelfAdjointEigenSolver<Eigen::Matrix3f> eigen_solver;
217 eigen_solver.compute(cov);
218 Eigen::Matrix3f eigen_val = eigen_solver.eigenvalues().asDiagonal();
219 Eigen::Matrix3f centroid_evecs = eigen_solver.eigenvectors();
220 if (eigen_val(0, 0) < 0 || eigen_val(1, 1) < 0 || eigen_val(2, 2) <= 0) {
222 return;
223 }
224 // Avoid matrices near singularities (eq 6.11) [Magnusson 2009].
225 float min_covar_eigvalue = 0.01f * eigen_val(2, 2);
226 if (eigen_val(0, 0) < min_covar_eigvalue) {
227 eigen_val(0, 0) = min_covar_eigvalue;
228 if (eigen_val(1, 1) < min_covar_eigvalue) {
229 eigen_val(1, 1) = min_covar_eigvalue;
230 }
231 }
232 // Calculate inverse covariance
234 (centroid_evecs * eigen_val * centroid_evecs.inverse()).inverse();
235 if (centroid_icov_.maxCoeff() == std::numeric_limits<float>::infinity() ||
236 centroid_icov_.minCoeff() == -std::numeric_limits<float>::infinity()) {
238 return;
239 }
240 // Set icov available
242 }
243}
const unsigned int minimum_points_threshold_
minimum number of points needed.

◆ CreateBinary()

size_t apollo::localization::msf::pyramid_map::NdtMapSingleCell::CreateBinary ( unsigned char *  buf,
size_t  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.cc90 行定义.

91 {
92 size_t target_size = GetBinarySize();
93 if (buf_size >= target_size) {
94 float* p = reinterpret_cast<float*>(buf);
95 *p = intensity_;
96 ++p;
97 *p = intensity_var_;
98 ++p;
99 unsigned int* pp =
100 reinterpret_cast<unsigned int*>(reinterpret_cast<void*>(p));
101 *pp = road_pt_count_;
102 ++pp;
103 *pp = count_;
104 ++pp;
105 float* ppp = reinterpret_cast<float*>(reinterpret_cast<void*>(pp));
106 *ppp = centroid_[0];
107 ++ppp;
108 *ppp = centroid_[1];
109 ++ppp;
110 *ppp = centroid_[2];
111
112 for (unsigned int i = 0; i < 3; ++i) {
113 for (unsigned int j = 0; j < 3; ++j) {
114 ++ppp;
115 *ppp = centroid_average_cov_(i, j);
116 }
117 }
119 for (unsigned int i = 0; i < 3; ++i) {
120 for (unsigned int j = 0; j < 3; ++j) {
121 ++ppp;
122 *ppp = centroid_icov_(i, j);
123 }
124 }
125 ++ppp;
126 unsigned char* pppp = reinterpret_cast<unsigned char*>(ppp);
127 *pppp = is_icov_available_;
128 }
129 }
130 return target_size;
131}
size_t GetBinarySize() const
Get the binary size of the object.

◆ GetBinarySize()

size_t apollo::localization::msf::pyramid_map::NdtMapSingleCell::GetBinarySize ( ) const

Get the binary size of the object.

在文件 ndt_map_matrix.cc133 行定义.

133 {
134 size_t sz = sizeof(float) * 2 + sizeof(unsigned int) * 2 + sizeof(float) * 3 +
135 sizeof(float) * 9;
137 sz += sizeof(float) * 9 + sizeof(unsigned char) * 1;
138 }
139 return sz;
140}

◆ LoadBinary()

size_t apollo::localization::msf::pyramid_map::NdtMapSingleCell::LoadBinary ( const unsigned char *  buf)

Load the map cell from a binary chunk.

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

在文件 ndt_map_matrix.cc48 行定义.

48 {
49 const float* f_buf = reinterpret_cast<const float*>(buf);
50 intensity_ = *f_buf;
51 ++f_buf;
52 intensity_var_ = *f_buf;
53 ++f_buf;
54 const unsigned int* ui_buf = reinterpret_cast<const unsigned int*>(
55 reinterpret_cast<const void*>(f_buf));
56 road_pt_count_ = *ui_buf;
57 ++ui_buf;
58 count_ = *ui_buf;
59 ++ui_buf;
60 f_buf = reinterpret_cast<const float*>(reinterpret_cast<const void*>(ui_buf));
61 centroid_[0] = *f_buf;
62 ++f_buf;
63 centroid_[1] = *f_buf;
64 ++f_buf;
65 centroid_[2] = *f_buf;
66
67 for (unsigned int i = 0; i < 3; ++i) {
68 for (unsigned int j = 0; j < 3; ++j) {
69 ++f_buf;
70 centroid_average_cov_(i, j) = *f_buf;
71 }
72 }
74 for (unsigned int i = 0; i < 3; ++i) {
75 for (unsigned int j = 0; j < 3; ++j) {
76 ++f_buf;
77 centroid_icov_(i, j) = *f_buf;
78 }
79 }
80 ++f_buf;
81 const unsigned char* uc_buf = reinterpret_cast<const unsigned char*>(f_buf);
82 is_icov_available_ = *uc_buf;
83 } else {
84 centroid_icov_ = Eigen::Matrix3f::Identity();
86 }
87 return GetBinarySize();
88}

◆ MergeCell() [1/2]

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

Merge two cells.

在文件 ndt_map_matrix.cc180 行定义.

185 {
186 unsigned int new_count = count_ + count;
187 float p0 = static_cast<float>(count_) / static_cast<float>(new_count);
188 float p1 = static_cast<float>(count) / static_cast<float>(new_count);
189 float intensity_diff = intensity_ - intensity;
190
191 intensity_ = intensity_ * p0 + intensity * p1;
192 intensity_var_ = intensity_var_ * p0 + intensity_var * p1 +
193 intensity_diff * intensity_diff * p0 * p1;
194
195 centroid_[0] = centroid_[0] * p0 + centroid[0] * p1;
196 centroid_[1] = centroid_[1] * p0 + centroid[1] * p1;
197 centroid_[2] = centroid_[2] * p0 + centroid[2] * p1;
198
199 count_ = new_count;
200 road_pt_count_ += road_pt_count;
201}

◆ MergeCell() [2/2]

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

在文件 ndt_map_matrix.cc203 行定义.

203 {
204 MergeCell(cell_new.intensity_, cell_new.intensity_var_,
205 cell_new.road_pt_count_, cell_new.count_, cell_new.centroid_,
206 cell_new.centroid_average_cov_);
207}
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::pyramid_map::NdtMapSingleCell::operator= ( const NdtMapSingleCell ref)

Overloading the assign operator.

在文件 ndt_map_matrix.cc142 行定义.

142 {
143 count_ = ref.count_;
144 intensity_ = ref.intensity_;
145 intensity_var_ = ref.intensity_var_;
146 road_pt_count_ = ref.road_pt_count_;
147 centroid_ = ref.centroid_;
148 centroid_average_cov_ = ref.centroid_average_cov_;
149 centroid_icov_ = ref.centroid_icov_;
150 is_icov_available_ = ref.is_icov_available_;
151 return *this;
152}

◆ Reduce()

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

Combine two NdtMapSingleCell instances (Reduce).

在文件 ndt_map_matrix.cc154 行定义.

155 {
156 cell->MergeCell(cell_new);
157}

◆ Reset()

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

Reset to default value.

在文件 ndt_map_matrix.cc37 行定义.

37 {
38 intensity_ = 0.0;
39 intensity_var_ = 0.0;
41 count_ = 0;
42 centroid_ = Eigen::Vector3f::Zero();
43 centroid_average_cov_ = Eigen::Matrix3f::Zero();
44 centroid_icov_ = Eigen::Matrix3f::Identity();
45 is_icov_available_ = false;
46}

类成员变量说明

◆ centroid_

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

the centroid of the cell.

在文件 ndt_map_matrix.h85 行定义.

◆ centroid_average_cov_

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

the pose covariance of the cell.

在文件 ndt_map_matrix.h87 行定义.

◆ centroid_icov_

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

the pose inverse covariance of the cell.

在文件 ndt_map_matrix.h89 行定义.

◆ count_

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

The number of samples in the cell.

在文件 ndt_map_matrix.h82 行定义.

◆ intensity_

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

The average intensity value.

在文件 ndt_map_matrix.h76 行定义.

◆ intensity_var_

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

The variance intensity value.

在文件 ndt_map_matrix.h78 行定义.

◆ is_icov_available_

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

the inverse covariance available flag.

在文件 ndt_map_matrix.h91 行定义.

◆ minimum_points_threshold_

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

minimum number of points needed.

在文件 ndt_map_matrix.h93 行定义.

◆ road_pt_count_

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

The number of samples belonging to road surface.

在文件 ndt_map_matrix.h80 行定义.


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