Apollo 10.0
自动驾驶开放平台
apollo::localization::msf::LosslessMapCell结构体 参考

The multiple layers of the cell. 更多...

#include <lossless_map_matrix.h>

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

Public 成员函数

 LosslessMapCell ()
 The default constructor.
 
void Reset ()
 Reset to default value.
 
void SetValueLayer (double altitude, unsigned char intensity, double altitude_thres=10.0)
 Set the value of a layer that layer_id > 0.
 
void SetValue (double altitude, unsigned char intensity)
 Set the 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.
 
unsigned int GetLayerId (double altitude) const
 Match a layer in the map cell given an altitude.
 
void GetValue (std::vector< unsigned char > *values) const
 Load the map cell from a binary chunk.
 
void GetVar (std::vector< float > *vars) const
 Get the variance of the intensity of all layers in the map cell.
 
void GetAlt (std::vector< float > *alts) const
 Get the average altitude of all layers in the map cell.
 
void GetAltVar (std::vector< float > *alt_vars) const
 Get the variance of the altitude of all layers in the map cell.
 
void GetCount (std::vector< unsigned int > *counts) const
 Get the count of the samples of all layers in the map cell.
 
unsigned char GetValue () const
 Get the average intensity of the map cell.
 
float GetVar () const
 Get the variance of the intensity of the map cell.
 
float GetAlt () const
 Get the average altitude of the map cell.
 
float GetAltVar () const
 Get the variance of the altitude of the map cell.
 
unsigned int GetCount () const
 Get the count of the samples in the map cell.
 
LosslessMapSingleCellGetLayer (unsigned int layer_id)
 Get a particular layer in the map cell.
 
const LosslessMapSingleCellGetLayer (unsigned int layer_id) const
 Get a perticular layer in the map cell.
 

Public 属性

unsigned int layer_num
 The layers of the cell.
 
LosslessMapSingleCell map_cells [IDL_CAR_NUM_RESERVED_MAP_LAYER]
 The multiple layers of the cell.
 

详细描述

The multiple layers of the cell.

在文件 lossless_map_matrix.h67 行定义.

构造及析构函数说明

◆ LosslessMapCell()

apollo::localization::msf::LosslessMapCell::LosslessMapCell ( )

The default constructor.

在文件 lossless_map_matrix.cc105 行定义.

105{ layer_num = 1; }
unsigned int layer_num
The layers of the cell.

成员函数说明

◆ CreateBinary()

unsigned int apollo::localization::msf::LosslessMapCell::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.

在文件 lossless_map_matrix.cc176 行定义.

177 {
178 unsigned int target_size = GetBinarySize();
179 if (buf_size >= target_size) {
180 unsigned int* p = reinterpret_cast<unsigned int*>(buf);
181 *p = layer_num;
182 ++p;
183 buf_size -= static_cast<unsigned int>(sizeof(unsigned int));
184 unsigned char* pp = reinterpret_cast<unsigned char*>(p);
185 for (size_t i = 0; i < layer_num; ++i) {
186 const LosslessMapSingleCell& cell = map_cells[i];
187 unsigned int processed_size = cell.CreateBinary(pp, buf_size);
188 DCHECK_GE(buf_size, processed_size);
189 buf_size -= processed_size;
190 pp += processed_size;
191 }
192 }
193 return target_size;
194}
LosslessMapSingleCell map_cells[IDL_CAR_NUM_RESERVED_MAP_LAYER]
The multiple layers of the cell.
unsigned int GetBinarySize() const
Get the binary size of the object.
unsigned int CreateBinary(unsigned char *buf, unsigned int buf_size) const
Create the binary.

◆ GetAlt() [1/2]

float apollo::localization::msf::LosslessMapCell::GetAlt ( ) const
inline

Get the average altitude of the map cell.

在文件 lossless_map_matrix.h117 行定义.

117{ return map_cells[0].altitude; }
float altitude
The average altitude of the cell.

◆ GetAlt() [2/2]

void apollo::localization::msf::LosslessMapCell::GetAlt ( std::vector< float > *  alts) const

Get the average altitude of all layers in the map cell.

在文件 lossless_map_matrix.cc236 行定义.

236 {
237 alts->clear();
238 for (unsigned int i = 1; i < layer_num; ++i) {
239 const LosslessMapSingleCell& cell = map_cells[i];
240 alts->push_back(cell.altitude);
241 }
242}

◆ GetAltVar() [1/2]

float apollo::localization::msf::LosslessMapCell::GetAltVar ( ) const
inline

Get the variance of the altitude of the map cell.

在文件 lossless_map_matrix.h119 行定义.

119{ return map_cells[0].altitude_var; }
float altitude_var
The variance altitude value of the cell.

◆ GetAltVar() [2/2]

void apollo::localization::msf::LosslessMapCell::GetAltVar ( std::vector< float > *  alt_vars) const

Get the variance of the altitude of all layers in the map cell.

在文件 lossless_map_matrix.cc244 行定义.

244 {
245 alt_vars->clear();
246 for (unsigned int i = 1; i < layer_num; ++i) {
247 const LosslessMapSingleCell& cell = map_cells[i];
248 alt_vars->push_back(cell.altitude_var);
249 }
250}

◆ GetBinarySize()

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

Get the binary size of the object.

在文件 lossless_map_matrix.cc196 行定义.

196 {
197 unsigned int target_size = sizeof(
198 unsigned int); // The size of the variable for the number of layers.
199 for (size_t i = 0; i < layer_num; ++i) {
200 const LosslessMapSingleCell& cell = map_cells[i];
201 target_size += cell.GetBinarySize();
202 }
203 return target_size;
204}
unsigned int GetBinarySize() const
Get the binary size of the object.

◆ GetCount() [1/2]

unsigned int apollo::localization::msf::LosslessMapCell::GetCount ( ) const
inline

Get the count of the samples in the map cell.

在文件 lossless_map_matrix.h121 行定义.

121{ return map_cells[0].count; }
unsigned int count
The number of samples in the cell.

◆ GetCount() [2/2]

void apollo::localization::msf::LosslessMapCell::GetCount ( std::vector< unsigned int > *  counts) const

Get the count of the samples of all layers in the map cell.

在文件 lossless_map_matrix.cc252 行定义.

252 {
253 counts->clear();
254 for (unsigned int i = 1; i < layer_num; ++i) {
255 const LosslessMapSingleCell& cell = map_cells[i];
256 counts->push_back(cell.count);
257 }
258}

◆ GetLayer() [1/2]

LosslessMapSingleCell & apollo::localization::msf::LosslessMapCell::GetLayer ( unsigned int  layer_id)
inline

Get a particular layer in the map cell.

The layer 0 is the layer includes all the samples.

在文件 lossless_map_matrix.h124 行定义.

124 {
125 DCHECK_LT(layer_id, layer_num);
126 return map_cells[layer_id];
127 }

◆ GetLayer() [2/2]

const LosslessMapSingleCell & apollo::localization::msf::LosslessMapCell::GetLayer ( unsigned int  layer_id) const
inline

Get a perticular layer in the map cell.

The layer 0 is the layer includes all the samples.

在文件 lossless_map_matrix.h130 行定义.

130 {
131 DCHECK_LT(layer_id, layer_num);
132 return map_cells[layer_id];
133 }

◆ GetLayerId()

unsigned int apollo::localization::msf::LosslessMapCell::GetLayerId ( double  altitude) const

Match a layer in the map cell given an altitude.

返回
The valid layer ID is 1 ~ N (The layer 0 is the layer includes all the samples). If there is no existing layer, return 0.

在文件 lossless_map_matrix.cc206 行定义.

206 {
207 unsigned int best_layer_id = 0;
208 double best_layer_alt_dif = 1e10;
209 for (unsigned int i = 1; i < layer_num; ++i) {
210 const LosslessMapSingleCell& cell = map_cells[i];
211 double layer_alt_dif = fabs(cell.altitude - altitude);
212 if (layer_alt_dif < best_layer_alt_dif) {
213 best_layer_alt_dif = layer_alt_dif;
214 best_layer_id = i;
215 }
216 }
217 return best_layer_id;
218}

◆ GetValue() [1/2]

unsigned char apollo::localization::msf::LosslessMapCell::GetValue ( ) const
inline

Get the average intensity of the map cell.

在文件 lossless_map_matrix.h111 行定义.

111 {
112 return static_cast<unsigned char>(map_cells[0].intensity);
113 }

◆ GetValue() [2/2]

void apollo::localization::msf::LosslessMapCell::GetValue ( std::vector< unsigned char > *  values) const

Load the map cell from a binary chunk.

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

Get the average intensity of all layers in the map cell.

在文件 lossless_map_matrix.cc220 行定义.

220 {
221 values->clear();
222 for (unsigned int i = 1; i < layer_num; ++i) {
223 const LosslessMapSingleCell& cell = map_cells[i];
224 values->push_back(static_cast<unsigned char>(cell.intensity));
225 }
226}

◆ GetVar() [1/2]

float apollo::localization::msf::LosslessMapCell::GetVar ( ) const
inline

Get the variance of the intensity of the map cell.

在文件 lossless_map_matrix.h115 行定义.

115{ return map_cells[0].intensity_var; }
float intensity_var
The variance intensity value.

◆ GetVar() [2/2]

void apollo::localization::msf::LosslessMapCell::GetVar ( std::vector< float > *  vars) const

Get the variance of the intensity of all layers in the map cell.

在文件 lossless_map_matrix.cc228 行定义.

228 {
229 vars->clear();
230 for (unsigned int i = 1; i < layer_num; ++i) {
231 const LosslessMapSingleCell& cell = map_cells[i];
232 vars->push_back(cell.intensity_var);
233 }
234}

◆ LoadBinary()

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

Load the map cell from a binary chunk.

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

在文件 lossless_map_matrix.cc162 行定义.

162 {
163 unsigned int* p = reinterpret_cast<unsigned int*>(buf);
164 unsigned int size = *p;
165 ++p;
166 layer_num = size;
167 unsigned char* pp = reinterpret_cast<unsigned char*>(p);
168 for (unsigned int i = 0; i < size; ++i) {
169 LosslessMapSingleCell& cell = map_cells[i];
170 unsigned int processed_size = cell.LoadBinary(pp);
171 pp += processed_size;
172 }
173 return GetBinarySize();
174}
unsigned int LoadBinary(unsigned char *buf)
Load the map cell from a binary chunk.

◆ Reset()

void apollo::localization::msf::LosslessMapCell::Reset ( )

Reset to default value.

在文件 lossless_map_matrix.cc107 行定义.

107 {
108 for (unsigned int i = 0; i < IDL_CAR_NUM_RESERVED_MAP_LAYER; ++i) {
109 map_cells[i].Reset();
110 }
111 layer_num = 1;
112}
#define IDL_CAR_NUM_RESERVED_MAP_LAYER
The first layer (layer 0) includes all the intensities from any layers.

◆ SetValue()

void apollo::localization::msf::LosslessMapCell::SetValue ( double  altitude,
unsigned char  intensity 
)

Set the value.

参数
<altitude>The altitude of the cell.
<intensity>The reflectance intensity.

在文件 lossless_map_matrix.cc156 行定义.

156 {
158 LosslessMapSingleCell& cell = map_cells[0];
159 cell.AddSample(static_cast<float>(altitude), static_cast<float>(intensity));
160}
void AddSample(const float new_altitude, const float new_intensity)
Add a sample.

◆ SetValueLayer()

void apollo::localization::msf::LosslessMapCell::SetValueLayer ( double  altitude,
unsigned char  intensity,
double  altitude_thres = 10.0 
)

Set the value of a layer that layer_id > 0.

The target layer is found according to the altitude.

在文件 lossless_map_matrix.cc114 行定义.

115 {
117
118 unsigned int best_layer_id = GetLayerId(altitude);
119 DCHECK_LT(best_layer_id, layer_num);
120 if (best_layer_id == 0) {
122 // No layer yet, create a new one
123 LosslessMapSingleCell& cell = map_cells[layer_num++];
124 cell.AddSample(static_cast<float>(altitude),
125 static_cast<float>(intensity));
126 } else {
127 // No enough reserved map layers.
128 std::cerr << "[Warning] There are no enough reserved map cell layers. "
129 "Please increase IDL_CAR_NUM_RESERVED_MAP_LAYER."
130 << std::endl;
131 }
132 } else {
133 // There is a best layer
134 double layer_alt_dif = fabs(map_cells[best_layer_id].altitude - altitude);
135 if (layer_alt_dif < altitude_thres) {
136 // Still a good one
137 LosslessMapSingleCell& cell = map_cells[best_layer_id];
138 cell.AddSample(static_cast<float>(altitude),
139 static_cast<float>(intensity));
140 } else {
141 // Should create a new one
143 LosslessMapSingleCell& cell = map_cells[layer_num++];
144 cell.AddSample(static_cast<float>(altitude),
145 static_cast<float>(intensity));
146 } else {
147 // No enough reserved map layers.
148 std::cerr << "[Warning] There are no enough reserved map cell layers. "
149 "Please increase IDL_CAR_NUM_RESERVED_MAP_LAYER."
150 << std::endl;
151 }
152 }
153 }
154}
unsigned int GetLayerId(double altitude) const
Match a layer in the map cell given an altitude.

类成员变量说明

◆ layer_num

unsigned int apollo::localization::msf::LosslessMapCell::layer_num

The layers of the cell.

在文件 lossless_map_matrix.h136 行定义.

◆ map_cells

LosslessMapSingleCell apollo::localization::msf::LosslessMapCell::map_cells[IDL_CAR_NUM_RESERVED_MAP_LAYER]

The multiple layers of the cell.

The first layer (layer 0) includes all the intensities from any layers. Other layers only include the samples from a layer.

在文件 lossless_map_matrix.h140 行定义.


该结构体的文档由以下文件生成: