Apollo 11.0
自动驾驶开放平台
apollo::perception::lidar::BackgroundMap类 参考

#include <background_map.h>

apollo::perception::lidar::BackgroundMap 的协作图:

Public 成员函数

 BackgroundMap ()=default
 
 ~BackgroundMap ()=default
 
bool Init (int width, int height, float resolution, float height_threshold)
 Init background map
 
bool Init (float xmin, float xmax, float ymin, float ymax, float resolution, float height_threshold)
 
bool Reset (size_t point_number)
 Reset all data
 
bool UpdateMap (LidarFrame *frame)
 Update map, update mask and node
 
bool UpdateMask (LidarFrame *frame)
 Update point mask and point index
 
bool UpdateNodes (LidarFrame *frame)
 Update node feature based on points
 
void GetNodeCoord (float x, float y, int *grid_x, int *grid_y)
 Get Node Coordinate based on point
 
int id ()
 Get valid node number
 

Public 属性

std::vector< BgNode > bg_nodes_
 
std::vector< size_t > point_idx_
 
std::vector< size_t > point_importance_
 
std::vector< bool > point_mask_
 

详细描述

在文件 background_map.h 第 45 行定义.

构造及析构函数说明

◆ BackgroundMap()

apollo::perception::lidar::BackgroundMap::BackgroundMap ( )
default

◆ ~BackgroundMap()

apollo::perception::lidar::BackgroundMap::~BackgroundMap ( )
default

成员函数说明

◆ GetNodeCoord()

void apollo::perception::lidar::BackgroundMap::GetNodeCoord ( float  x,
float  y,
int *  grid_x,
int *  grid_y 
)

Get Node Coordinate based on point

参数
xthe value of x coordinate
ythe value of y coordinate
grid_xx coordinate of grid
grid_yy coordinate of grid

在文件 background_map.cc 第 162 行定义.

162 {
163 *grid_x = static_cast<int>((x - xmin_) / resolution_);
164 *grid_y = static_cast<int>((y - ymin_) / resolution_);
165}

◆ id()

int apollo::perception::lidar::BackgroundMap::id ( )
inline

Get valid node number

返回
int

在文件 background_map.h 第 108 行定义.

108 {
109 return valid_node_number_;
110 }

◆ Init() [1/2]

bool apollo::perception::lidar::BackgroundMap::Init ( float  xmin,
float  xmax,
float  ymin,
float  ymax,
float  resolution,
float  height_threshold 
)

在文件 background_map.cc 第 32 行定义.

32 {
33 resolution_ = resolution;
34 xmin_ = xmin;
35 xmax_ = xmax;
36 ymin_ = ymin;
37 ymax_ = ymax;
38 height_threshold_ = height_threshold;
39
40 // in pointcloud-cooridinate system
41 width_ = static_cast<int>((ymax - ymin) * 1.0f / resolution);
42 height_ = static_cast<int>((xmax - xmin) * 1.0f / resolution);
43 return true;
44}

◆ Init() [2/2]

bool apollo::perception::lidar::BackgroundMap::Init ( int  width,
int  height,
float  resolution,
float  height_threshold 
)

Init background map

参数
widthmap width
heightmap height
resolutiongrid resolution
height_thresholdpoint height threshold
返回
true
false

在文件 background_map.cc 第 24 行定义.

24 {
25 width_ = width;
26 height_ = height;
27 resolution_ = resolution;
28 height_threshold_ = height_threshold;
29 return true;
30}
uint32_t height
Height of point cloud
uint32_t width
Width of point cloud

◆ Reset()

bool apollo::perception::lidar::BackgroundMap::Reset ( size_t  point_number)

Reset all data

参数
point_numberpoint number
返回
true
false

在文件 background_map.cc 第 46 行定义.

46 {
47 // clear all data
48 bg_nodes_.clear();
49 point_idx_.clear();
50 point_importance_.clear();
51 point_mask_.clear();
52 point_number_ = point_number;
53 valid_node_number_ = 0;
54
55 // reset data
56 bg_nodes_.resize(width_ * height_);
57 point_idx_.resize(point_number_, 0);
58 point_mask_.resize(point_number_, false);
59 point_importance_.resize(point_number_, false);
60 return true;
61}

◆ UpdateMap()

bool apollo::perception::lidar::BackgroundMap::UpdateMap ( LidarFrame *  frame)

Update map, update mask and node

参数
framelidar frame
返回
true
false

在文件 background_map.cc 第 63 行定义.

63 {
64 // update idx and mask
65 ACHECK(UpdateMask(frame));
66 // update node
67 ACHECK(UpdateNodes(frame));
68 return true;
69}
bool UpdateMask(LidarFrame *frame)
Update point mask and point index
bool UpdateNodes(LidarFrame *frame)
Update node feature based on points
#define ACHECK(cond)
Definition log.h:80

◆ UpdateMask()

bool apollo::perception::lidar::BackgroundMap::UpdateMask ( LidarFrame *  frame)

Update point mask and point index

参数
framelidar frame
返回
true
false

在文件 background_map.cc 第 71 行定义.

71 {
72 if (frame->secondary_indices.indices.size() == 0) {
73 AINFO << "UpdateMask, secondary_indices size is 0.";
74 }
75 // secondary_indices
76 for (auto index : frame->secondary_indices.indices) {
77 if (index < 0 || static_cast<size_t>(index) >= point_number_) {
78 continue;
79 }
80 auto pt = frame->cloud->at(index);
81 // filter point beyond height_threshold_
82 Eigen::Vector4d trans_point(pt.x, pt.y, pt.z, 1);
83 trans_point = frame->lidar2novatel_extrinsics * trans_point;
84 if (trans_point(2) >= height_threshold_) {
85 continue;
86 }
87 // filter point use semantic_label
88 if (static_cast<PointSemanticLabel>(frame->cloud->points_semantic_label(index) & 15)
90 continue;
91 }
92 // filter point outside grid
93 int grid_x = -1;
94 int grid_y = -1;
95 GetNodeCoord(pt.x, pt.y, &grid_x, &grid_y);
96 if (grid_y < 0 || grid_y >= width_ || grid_x < 0 || grid_x >= height_) {
97 continue;
98 }
99 // valid point
100 size_t grid_idx = grid_x * width_ + grid_y;
101 point_mask_.at(index) = true;
102 point_idx_.at(index) = grid_idx;
103
104 // in novatel-cooridinate system
105 if (trans_point(1) > FLAGS_y_back && trans_point(1) < FLAGS_y_front && trans_point(0) > FLAGS_x_back
106 && trans_point(0) < FLAGS_x_front) {
107 point_importance_.at(index) = true;
108 }
109 }
110
111 return true;
112}
void GetNodeCoord(float x, float y, int *grid_x, int *grid_y)
Get Node Coordinate based on point
#define AINFO
Definition log.h:42

◆ UpdateNodes()

bool apollo::perception::lidar::BackgroundMap::UpdateNodes ( LidarFrame *  frame)

Update node feature based on points

参数
framelidar frame
返回
true
false

在文件 background_map.cc 第 114 行定义.

114 {
115 auto original_cloud = frame->cloud;
116 for (size_t i = 0; i < point_mask_.size(); ++i) {
117 if (!point_mask_.at(i)) {
118 continue;
119 }
120 auto pt = original_cloud->at(i);
121 // update node state
122 size_t grid_idx = point_idx_.at(i);
123 bg_nodes_.at(grid_idx).is_valid = true;
124 bg_nodes_.at(grid_idx).is_important = bg_nodes_.at(grid_idx).is_important || point_importance_.at(i);
125
126 if (bg_nodes_.at(grid_idx).point_number == 0) {
127 bg_nodes_.at(grid_idx).id = valid_node_number_;
128 valid_node_number_ += 1;
129 }
130 bg_nodes_.at(grid_idx).point_number += 1;
131 // update node feature
132 int pt_number = bg_nodes_.at(grid_idx).point_number;
133 // mean height, mean intensity
134 if (pt_number == 1) {
135 bg_nodes_.at(grid_idx).mean_height = pt.z;
136 bg_nodes_.at(grid_idx).mean_intensity = pt.intensity;
137 } else {
138 bg_nodes_.at(grid_idx).mean_height = bg_nodes_.at(grid_idx).mean_height
139 + (pt.z - bg_nodes_.at(grid_idx).mean_height) / static_cast<float>(pt_number);
140 bg_nodes_.at(grid_idx).mean_intensity = bg_nodes_.at(grid_idx).mean_intensity
141 + (pt.intensity - bg_nodes_.at(grid_idx).mean_intensity) / static_cast<float>(pt_number);
142 }
143 // max height
144 bg_nodes_.at(grid_idx).max_height = std::max(bg_nodes_.at(grid_idx).max_height, pt.z);
145
146 // get semantic label
147 PointSemanticLabel label = GetSemanticLabel(original_cloud->points_semantic_label(i));
148 int index = static_cast<int>(label);
149 if (index >= 0 && index < static_cast<int>(PointSemanticLabel::MAX_LABEL)) {
150 bg_nodes_.at(grid_idx).pc_semantic_types[index]++;
151 }
152 // get motion label
153 PointMotionLabel motion_label = GetMotionLabel(original_cloud->points_semantic_label(i));
154 int motion_index = static_cast<int>(motion_label);
155 if (motion_index >= 0 && motion_index < static_cast<int>(PointMotionLabel::MAX_LABEL)) {
156 bg_nodes_.at(grid_idx).pc_motion_types[motion_index]++;
157 }
158 }
159 return true;
160}
PointSemanticLabel GetSemanticLabel(uint8_t value)
PointMotionLabel GetMotionLabel(uint8_t value)

类成员变量说明

◆ bg_nodes_

std::vector<BgNode> apollo::perception::lidar::BackgroundMap::bg_nodes_

在文件 background_map.h 第 114 行定义.

◆ point_idx_

std::vector<size_t> apollo::perception::lidar::BackgroundMap::point_idx_

在文件 background_map.h 第 116 行定义.

◆ point_importance_

std::vector<size_t> apollo::perception::lidar::BackgroundMap::point_importance_

在文件 background_map.h 第 118 行定义.

◆ point_mask_

std::vector<bool> apollo::perception::lidar::BackgroundMap::point_mask_

在文件 background_map.h 第 120 行定义.


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