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

#include <pointcloud_preprocessor.h>

类 apollo::perception::lidar::PointCloudPreprocessor 继承关系图:
apollo::perception::lidar::PointCloudPreprocessor 的协作图:

Public 成员函数

 PointCloudPreprocessor ()=default
 
 ~PointCloudPreprocessor ()=default
 
bool Init (const PointCloudPreprocessorInitOptions &options=PointCloudPreprocessorInitOptions())
 Init pointcloud preprocessor
 
bool Preprocess (const PointCloudPreprocessorOptions &options, const std::shared_ptr< apollo::drivers::PointCloud const > &message, LidarFrame *frame) const
 Ireprocess point cloud
 
bool Preprocess (const PointCloudPreprocessorOptions &options, LidarFrame *frame) const
 Preprocess point cloud
 
std::string Name () const
 Get class name
 
- Public 成员函数 继承自 apollo::perception::lidar::BasePointCloudPreprocessor
 BasePointCloudPreprocessor ()=default
 
virtual ~BasePointCloudPreprocessor ()=default
 

详细描述

在文件 pointcloud_preprocessor.h 第 32 行定义.

构造及析构函数说明

◆ PointCloudPreprocessor()

apollo::perception::lidar::PointCloudPreprocessor::PointCloudPreprocessor ( )
default

◆ ~PointCloudPreprocessor()

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

成员函数说明

◆ Init()

bool apollo::perception::lidar::PointCloudPreprocessor::Init ( const PointCloudPreprocessorInitOptions &  options = PointCloudPreprocessorInitOptions())
virtual

Init pointcloud preprocessor

参数
options
返回
true
false

实现了 apollo::perception::lidar::BasePointCloudPreprocessor.

在文件 pointcloud_preprocessor.cc 第 34 行定义.

35 {
36 std::string config_file =
37 GetConfigFile(options.config_path, options.config_file);
38 PointCloudPreprocessorConfig config;
40 filter_naninf_points_ = config.filter_naninf_points();
41 filter_nearby_box_points_ = config.filter_nearby_box_points();
42 box_forward_x_ = config.box_forward_x();
43 box_backward_x_ = config.box_backward_x();
44 box_forward_y_ = config.box_forward_y();
45 box_backward_y_ = config.box_backward_y();
46 filter_high_z_points_ = config.filter_high_z_points();
47 z_threshold_ = config.z_threshold();
48 return true;
49}
#define ACHECK(cond)
Definition log.h:80
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132
std::string GetConfigFile(const std::string &config_path, const std::string &config_file)
Definition util.cc:80

◆ Name()

std::string apollo::perception::lidar::PointCloudPreprocessor::Name ( ) const
inlinevirtual

Get class name

返回
std::string

实现了 apollo::perception::lidar::BasePointCloudPreprocessor.

在文件 pointcloud_preprocessor.h 第 75 行定义.

75{ return "PointCloudPreprocessor"; }

◆ Preprocess() [1/2]

bool apollo::perception::lidar::PointCloudPreprocessor::Preprocess ( const PointCloudPreprocessorOptions &  options,
const std::shared_ptr< apollo::drivers::PointCloud const > &  message,
LidarFrame *  frame 
) const
virtual

Ireprocess point cloud

参数
options
messagePoint cloud message
frameFill cloud and world_cloud data
返回
true
false

实现了 apollo::perception::lidar::BasePointCloudPreprocessor.

在文件 pointcloud_preprocessor.cc 第 51 行定义.

54 {
55 if (frame == nullptr) {
56 return false;
57 }
58 if (frame->cloud == nullptr) {
59 frame->cloud = base::PointFCloudPool::Instance().Get();
60 }
61 if (frame->world_cloud == nullptr) {
62 frame->world_cloud = base::PointDCloudPool::Instance().Get();
63 }
64
65 frame->cloud->set_timestamp(message->measurement_time());
66 if (message->point_size() > 0) {
67 frame->cloud->reserve(message->point_size());
68 base::PointF point;
69 for (int i = 0; i < message->point_size(); ++i) {
70 const apollo::drivers::PointXYZIT& pt = message->point(i);
71 if (filter_naninf_points_) {
72 if (std::isnan(pt.x()) || std::isnan(pt.y()) || std::isnan(pt.z())) {
73 continue;
74 }
75 if (fabs(pt.x()) > kPointInfThreshold ||
76 fabs(pt.y()) > kPointInfThreshold ||
77 fabs(pt.z()) > kPointInfThreshold) {
78 continue;
79 }
80 }
81 Eigen::Vector3d vec3d_lidar(pt.x(), pt.y(), pt.z());
82 // Eigen::Vector3d vec3d_novatel =
83 // options.sensor2novatel_extrinsics * vec3d_lidar;
84 Eigen::Vector3d vec3d_novatel = vec3d_lidar;
85 if (filter_nearby_box_points_ && vec3d_novatel[0] < box_forward_x_ &&
86 vec3d_novatel[0] > box_backward_x_ &&
87 vec3d_novatel[1] < box_forward_y_ &&
88 vec3d_novatel[1] > box_backward_y_) {
89 continue;
90 }
91 if (filter_high_z_points_ && pt.z() > z_threshold_) {
92 continue;
93 }
94 point.x = pt.x();
95 point.y = pt.y();
96 point.z = pt.z();
97 point.intensity = static_cast<float>(pt.intensity());
98 frame->cloud->push_back(point, static_cast<double>(pt.timestamp()) * 1e-9,
99 std::numeric_limits<float>::max(), i, 0);
100 }
101 TransformCloud(frame->cloud, frame->lidar2world_pose, frame->world_cloud);
102 }
103
104 return true;
105}
Point< float > PointF
Definition point.h:56

◆ Preprocess() [2/2]

bool apollo::perception::lidar::PointCloudPreprocessor::Preprocess ( const PointCloudPreprocessorOptions &  options,
LidarFrame *  frame 
) const
virtual

Preprocess point cloud

参数
options
frameFill cloud and world_cloud data
返回
true
false

实现了 apollo::perception::lidar::BasePointCloudPreprocessor.

在文件 pointcloud_preprocessor.cc 第 107 行定义.

108 {
109 if (frame == nullptr || frame->cloud == nullptr) {
110 return false;
111 }
112 if (frame->world_cloud == nullptr) {
113 frame->world_cloud = base::PointDCloudPool::Instance().Get();
114 }
115 if (frame->cloud->size() > 0) {
116 size_t size = frame->cloud->size();
117 size_t i = 0;
118 while (i < size) {
119 auto& pt = frame->cloud->at(i);
120 if (filter_naninf_points_) {
121 if (std::isnan(pt.x) || std::isnan(pt.y) || std::isnan(pt.z)) {
122 frame->cloud->SwapPoint(i, size--);
123 continue;
124 }
125 if (fabs(pt.x) > kPointInfThreshold ||
126 fabs(pt.y) > kPointInfThreshold ||
127 fabs(pt.z) > kPointInfThreshold) {
128 frame->cloud->SwapPoint(i, size--);
129 continue;
130 }
131 }
132 Eigen::Vector3d vec3d_lidar(pt.x, pt.y, pt.z);
133 // Eigen::Vector3d vec3d_novatel =
134 // options.sensor2novatel_extrinsics * vec3d_lidar;
135 Eigen::Vector3d vec3d_novatel = vec3d_lidar;
136 if (filter_nearby_box_points_ && vec3d_novatel[0] < box_forward_x_ &&
137 vec3d_novatel[0] > box_backward_x_ &&
138 vec3d_novatel[1] < box_forward_y_ &&
139 vec3d_novatel[1] > box_backward_y_) {
140 frame->cloud->SwapPoint(i, size--);
141 continue;
142 }
143 if (filter_high_z_points_ && pt.z > z_threshold_) {
144 frame->cloud->SwapPoint(i, size--);
145 continue;
146 }
147 ++i;
148 }
149 frame->cloud->resize(i);
150 TransformCloud(frame->cloud, frame->lidar2world_pose, frame->world_cloud);
151 AINFO << "Preprocessor filter points: " << size << " to " << i;
152 }
153 return true;
154}
#define AINFO
Definition log.h:42

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