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

The data structure of ndt Map cell. 更多...

#include <ndt_map_matrix.h>

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

Public 成员函数

 NdtMapCells ()
 The default constructor.
 
void Reset ()
 Reset to default value.
 
int AddSample (const float intensity, const float altitude, const float resolution, const Eigen::Vector3f &centroid, bool is_road=false)
 Add an sample.
 
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.
 

静态 Public 成员函数

static int CalAltitudeIndex (const float resolution, const float altitude)
 Calculate altitude index from altitude.
 
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).
 

Public 属性

std::unordered_map< int, NdtMapSingleCellcells_
 The multiple altitudes of the cell.
 
int max_altitude_index_
 The index of biggest altitude.
 
int min_altitude_index_
 The index of smallest altitude.
 
std::vector< int > road_cell_indices_
 The indices of road surface.
 

详细描述

The data structure of ndt Map cell.

在文件 ndt_map_matrix.h97 行定义.

构造及析构函数说明

◆ NdtMapCells()

apollo::localization::msf::pyramid_map::NdtMapCells::NdtMapCells ( )

The default constructor.

在文件 ndt_map_matrix.cc245 行定义.

245 {
246 max_altitude_index_ = static_cast<int>(-1e10);
247 min_altitude_index_ = static_cast<int>(1e10);
248}
int min_altitude_index_
The index of smallest altitude.
int max_altitude_index_
The index of biggest altitude.

成员函数说明

◆ AddSample()

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

Add an sample.

在文件 ndt_map_matrix.cc257 行定义.

259 {
260 int altitude_index = CalAltitudeIndex(resolution, altitude);
261 NdtMapSingleCell& cell = cells_[altitude_index];
262 cell.AddSample(intensity, altitude, centroid, is_road);
263 if (altitude_index > max_altitude_index_) {
264 max_altitude_index_ = altitude_index;
265 }
266 if (altitude_index < min_altitude_index_) {
267 min_altitude_index_ = altitude_index;
268 }
269 if (is_road) {
270 auto got = std::find(road_cell_indices_.begin(), road_cell_indices_.end(),
271 altitude_index);
272 if (got == road_cell_indices_.end()) {
273 road_cell_indices_.push_back(altitude_index);
274 }
275 }
276
277 return altitude_index;
278}
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.
std::unordered_map< int, NdtMapSingleCell > cells_
The multiple altitudes of the cell.

◆ CalAltitude()

float apollo::localization::msf::pyramid_map::NdtMapCells::CalAltitude ( const float  resolution,
const int  altitude_index 
)
static

Calculate altitude from altitude index.

在文件 ndt_map_matrix.cc374 行定义.

375 {
376 return static_cast<float>(resolution *
377 (static_cast<float>(altitude_index) + 0.5));
378}

◆ CalAltitudeIndex()

int apollo::localization::msf::pyramid_map::NdtMapCells::CalAltitudeIndex ( const float  resolution,
const float  altitude 
)
static

Calculate altitude index from altitude.

在文件 ndt_map_matrix.cc369 行定义.

370 {
371 return static_cast<int>(altitude / resolution);
372}

◆ CreateBinary()

size_t apollo::localization::msf::pyramid_map::NdtMapCells::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.cc316 行定义.

316 {
317 size_t target_size = GetBinarySize();
318 if (buf_size >= target_size) {
319 unsigned int* p = reinterpret_cast<unsigned int*>(buf);
320 *p = static_cast<unsigned int>(cells_.size());
321 ++p;
322 buf_size -= static_cast<unsigned int>(sizeof(unsigned int));
323 unsigned char* pp = reinterpret_cast<unsigned char*>(p);
324 for (auto it = cells_.begin(); it != cells_.end(); ++it) {
325 int altitude_index = it->first;
326 const NdtMapSingleCell& cell = it->second;
327 int* ppp = reinterpret_cast<int*>(pp);
328 *ppp = altitude_index;
329 ++ppp;
330 pp = reinterpret_cast<unsigned char*>(ppp);
331 size_t processed_size = cell.CreateBinary(pp, buf_size);
332 assert(buf_size >= processed_size);
333 buf_size -= processed_size;
334 pp += processed_size;
335 }
336
337 int* ppp = reinterpret_cast<int*>(pp);
338 *ppp = max_altitude_index_;
339 ++ppp;
340 *ppp = min_altitude_index_;
341 ++ppp;
342
343 size_t size = road_cell_indices_.size();
344 p = reinterpret_cast<unsigned int*>(ppp);
345 *p = static_cast<unsigned int>(size);
346 ++p;
347 ppp = reinterpret_cast<int*>(p);
348 for (unsigned int i = 0; i < size; ++i) {
349 *ppp = road_cell_indices_[i];
350 ++ppp;
351 }
352 }
353 return target_size;
354}
size_t GetBinarySize() const
Get the binary size of the object.

◆ GetBinarySize()

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

Get the binary size of the object.

在文件 ndt_map_matrix.cc356 行定义.

356 {
357 size_t target_size = sizeof(unsigned int);
358 for (auto it = cells_.begin(); it != cells_.end(); ++it) {
359 target_size += sizeof(int);
360 const NdtMapSingleCell& cell = it->second;
361 target_size += cell.GetBinarySize();
362 }
363 target_size += sizeof(int) * 2;
364 target_size += sizeof(unsigned int);
365 target_size += sizeof(int) * road_cell_indices_.size();
366 return target_size;
367}

◆ LoadBinary()

size_t apollo::localization::msf::pyramid_map::NdtMapCells::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.cc280 行定义.

280 {
281 const unsigned int* p = reinterpret_cast<const unsigned int*>(buf);
282 unsigned int size = *p;
283 ++p;
284
285 const unsigned char* pp = reinterpret_cast<const unsigned char*>(p);
286 for (unsigned int i = 0; i < size; ++i) {
287 const int* ppp = reinterpret_cast<const int*>(pp);
288 int altitude_index = *ppp;
289 ++ppp;
290 pp = reinterpret_cast<const unsigned char*>(ppp);
291 NdtMapSingleCell cell;
292 size_t processed_size = cell.LoadBinary(pp);
293 cells_[altitude_index] = cell;
294 pp += processed_size;
295 }
296
297 const int* ppp = reinterpret_cast<const int*>(pp);
298 max_altitude_index_ = *ppp;
299 ++ppp;
300 min_altitude_index_ = *ppp;
301 ++ppp;
302
303 p = reinterpret_cast<const unsigned int*>(ppp);
304 size = *p;
305 ++p;
306 ppp = reinterpret_cast<const int*>(p);
307 for (unsigned int i = 0; i < size; ++i) {
308 int index = *ppp;
309 ++ppp;
310 road_cell_indices_.push_back(index);
311 }
312
313 return GetBinarySize();
314}

◆ Reduce()

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

Combine two MapCell instances (Reduce).

在文件 ndt_map_matrix.cc380 行定义.

380 {
381 // Reduce cells
382 for (auto it = cell_new.cells_.begin(); it != cell_new.cells_.end(); ++it) {
383 int altitude_index = it->first;
384 auto got = cell->cells_.find(altitude_index);
385 if (got != cell->cells_.end()) {
386 cell->cells_[altitude_index].MergeCell(it->second);
387 } else {
388 cell->cells_[altitude_index] = NdtMapSingleCell(it->second);
389 }
390 }
391
392 if (cell_new.max_altitude_index_ > cell->max_altitude_index_) {
393 cell->max_altitude_index_ = cell_new.max_altitude_index_;
394 }
395
396 if (cell_new.min_altitude_index_ < cell->min_altitude_index_) {
397 cell->min_altitude_index_ = cell_new.min_altitude_index_;
398 }
399
400 for (auto it_new = cell_new.road_cell_indices_.begin();
401 it_new != cell_new.road_cell_indices_.end(); ++it_new) {
402 auto got_it = std::find(cell->road_cell_indices_.begin(),
403 cell->road_cell_indices_.end(), *it_new);
404 if (got_it != cell->road_cell_indices_.end()) {
405 *got_it += *it_new;
406 } else {
407 cell->road_cell_indices_.push_back(*it_new);
408 }
409 }
410}

◆ Reset()

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

Reset to default value.

在文件 ndt_map_matrix.cc250 行定义.

250 {
251 max_altitude_index_ = static_cast<int>(-1e10);
252 min_altitude_index_ = static_cast<int>(1e10);
253 cells_.clear();
254 road_cell_indices_.clear();
255}

类成员变量说明

◆ cells_

std::unordered_map<int, NdtMapSingleCell> apollo::localization::msf::pyramid_map::NdtMapCells::cells_

The multiple altitudes of the cell.

在文件 ndt_map_matrix.h131 行定义.

◆ max_altitude_index_

int apollo::localization::msf::pyramid_map::NdtMapCells::max_altitude_index_

The index of biggest altitude.

在文件 ndt_map_matrix.h133 行定义.

◆ min_altitude_index_

int apollo::localization::msf::pyramid_map::NdtMapCells::min_altitude_index_

The index of smallest altitude.

在文件 ndt_map_matrix.h135 行定义.

◆ road_cell_indices_

std::vector<int> apollo::localization::msf::pyramid_map::NdtMapCells::road_cell_indices_

The indices of road surface.

在文件 ndt_map_matrix.h137 行定义.


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