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

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

#include <ndt_map_matrix.h>

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

静态 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::NdtMapCells::NdtMapCells ( )

The default constructor.

在文件 ndt_map_matrix.cc148 行定义.

148 {
149 max_altitude_index_ = static_cast<int>(-1e10);
150 min_altitude_index_ = static_cast<int>(1e10);
151}
int max_altitude_index_
The index of biggest altitude.
int min_altitude_index_
The index of smallest altitude.

成员函数说明

◆ AddSample()

int apollo::localization::msf::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.cc160 行定义.

162 {
163 int altitude_index = CalAltitudeIndex(resolution, altitude);
164 NdtMapSingleCell& cell = cells_[altitude_index];
165 cell.AddSample(intensity, altitude, centroid, is_road);
166 if (altitude_index > max_altitude_index_) {
167 max_altitude_index_ = altitude_index;
168 }
169 if (altitude_index < min_altitude_index_) {
170 min_altitude_index_ = altitude_index;
171 }
172 if (is_road) {
173 auto got = std::find(road_cell_indices_.begin(), road_cell_indices_.end(),
174 altitude_index);
175 if (got == road_cell_indices_.end()) {
176 road_cell_indices_.push_back(altitude_index);
177 }
178 }
179
180 return altitude_index;
181}
std::vector< int > road_cell_indices_
The indices of road surface.
static int CalAltitudeIndex(const float resolution, const float altitude)
Calculate altitude index from altitude.
std::unordered_map< int, NdtMapSingleCell > cells_
The multiple altitudes of the cell.

◆ CalAltitude()

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

Calculate altitude from altitude index.

在文件 ndt_map_matrix.cc281 行定义.

282 {
283 return static_cast<float>(resolution *
284 (static_cast<float>(altitude_index) + 0.5));
285}

◆ CalAltitudeIndex()

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

Calculate altitude index from altitude.

在文件 ndt_map_matrix.cc276 行定义.

277 {
278 return static_cast<int>(altitude / resolution);
279}

◆ CreateBinary()

unsigned int apollo::localization::msf::NdtMapCells::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.cc219 行定义.

220 {
221 unsigned int target_size = GetBinarySize();
222 if (buf_size >= target_size) {
223 unsigned int* p = reinterpret_cast<unsigned int*>(buf);
224 *p = static_cast<unsigned int>(cells_.size());
225 ++p;
226 buf_size -= static_cast<unsigned int>(sizeof(unsigned int));
227 unsigned char* pp = reinterpret_cast<unsigned char*>(p);
228 for (auto it = cells_.begin(); it != cells_.end(); ++it) {
229 int altitude_index = it->first;
230 const NdtMapSingleCell& cell = it->second;
231 int* ppp = reinterpret_cast<int*>(pp);
232 *ppp = altitude_index;
233 ++ppp;
234 pp = reinterpret_cast<unsigned char*>(ppp);
235 unsigned int processed_size = cell.CreateBinary(pp, buf_size);
236 assert(buf_size >= processed_size);
237 buf_size -= processed_size;
238 pp += processed_size;
239 }
240
241 int* ppp = reinterpret_cast<int*>(pp);
242 *ppp = max_altitude_index_;
243 ++ppp;
244 *ppp = min_altitude_index_;
245 ++ppp;
246
247 unsigned int size = static_cast<unsigned int>(road_cell_indices_.size());
248 p = reinterpret_cast<unsigned int*>(ppp);
249 *p = size;
250 ++p;
251 ppp = reinterpret_cast<int*>(p);
252 for (unsigned int i = 0; i < size; ++i) {
253 *ppp = road_cell_indices_[i];
254 ++ppp;
255 }
256 }
257 return target_size;
258}
unsigned int GetBinarySize() const
Get the binary size of the object.

◆ GetBinarySize()

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

Get the binary size of the object.

在文件 ndt_map_matrix.cc260 行定义.

260 {
261 unsigned int target_size = sizeof(unsigned int);
262 for (auto it = cells_.begin(); it != cells_.end(); ++it) {
263 target_size += static_cast<unsigned int>(sizeof(int));
264 const NdtMapSingleCell& cell = it->second;
265 target_size += cell.GetBinarySize();
266 }
267
268 target_size += static_cast<unsigned int>(sizeof(int) * 2);
269 target_size += static_cast<unsigned int>(sizeof(unsigned int));
270 target_size +=
271 static_cast<unsigned int>(sizeof(int) * road_cell_indices_.size());
272
273 return target_size;
274}

◆ LoadBinary()

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

Load the map cell from a binary chunk.

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

在文件 ndt_map_matrix.cc183 行定义.

183 {
184 unsigned int* p = reinterpret_cast<unsigned int*>(buf);
185 unsigned int size = *p;
186 ++p;
187
188 unsigned char* pp = reinterpret_cast<unsigned char*>(p);
189 for (unsigned int i = 0; i < size; ++i) {
190 int* ppp = reinterpret_cast<int*>(pp);
191 int altitude_index = *ppp;
192 ++ppp;
193 pp = reinterpret_cast<unsigned char*>(ppp);
194 NdtMapSingleCell cell;
195 unsigned int processed_size = cell.LoadBinary(pp);
196 cells_[altitude_index] = cell;
197 pp += processed_size;
198 }
199
200 int* ppp = reinterpret_cast<int*>(pp);
201 max_altitude_index_ = *ppp;
202 ++ppp;
203 min_altitude_index_ = *ppp;
204 ++ppp;
205
206 p = reinterpret_cast<unsigned int*>(ppp);
207 size = *p;
208 ++p;
209 ppp = reinterpret_cast<int*>(p);
210 for (unsigned int i = 0; i < size; ++i) {
211 int index = *ppp;
212 ++ppp;
213 road_cell_indices_.push_back(index);
214 }
215
216 return GetBinarySize();
217}

◆ Reduce()

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

Combine two MapCell instances (Reduce).

在文件 ndt_map_matrix.cc287 行定义.

287 {
288 // Reduce cells
289 for (auto it = cell_new.cells_.begin(); it != cell_new.cells_.end(); ++it) {
290 int altitude_index = it->first;
291 auto got = cell->cells_.find(altitude_index);
292 if (got != cell->cells_.end()) {
293 cell->cells_[altitude_index].MergeCell(it->second);
294 } else {
295 cell->cells_[altitude_index] = NdtMapSingleCell(it->second);
296 }
297 }
298
299 if (cell_new.max_altitude_index_ > cell->max_altitude_index_) {
300 cell->max_altitude_index_ = cell_new.max_altitude_index_;
301 }
302
303 if (cell_new.min_altitude_index_ < cell->min_altitude_index_) {
304 cell->min_altitude_index_ = cell_new.min_altitude_index_;
305 }
306
307 for (auto it_new = cell_new.road_cell_indices_.begin();
308 it_new != cell_new.road_cell_indices_.end(); ++it_new) {
309 auto got_it = std::find(cell->road_cell_indices_.begin(),
310 cell->road_cell_indices_.end(), *it_new);
311 if (got_it != cell->road_cell_indices_.end()) {
312 *got_it += *it_new;
313 } else {
314 cell->road_cell_indices_.push_back(*it_new);
315 }
316 }
317}

◆ Reset()

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

Reset to default value.

在文件 ndt_map_matrix.cc153 行定义.

153 {
154 max_altitude_index_ = static_cast<int>(-1e10);
155 min_altitude_index_ = static_cast<int>(1e10);
156 cells_.clear();
157 road_cell_indices_.clear();
158}

类成员变量说明

◆ cells_

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

The multiple altitudes of the cell.

在文件 ndt_map_matrix.h131 行定义.

◆ max_altitude_index_

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

The index of biggest altitude.

在文件 ndt_map_matrix.h133 行定义.

◆ min_altitude_index_

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

The index of smallest altitude.

在文件 ndt_map_matrix.h135 行定义.

◆ road_cell_indices_

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

The indices of road surface.

在文件 ndt_map_matrix.h137 行定义.


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