Apollo 11.0
自动驾驶开放平台
apollo::perception::lidar::OfflinePointcloudGroundDetection类 参考
apollo::perception::lidar::OfflinePointcloudGroundDetection 的协作图:

Public 成员函数

 OfflinePointcloudGroundDetection ()=default
 
 ~OfflinePointcloudGroundDetection ()=default
 
bool Init ()
 
bool TransformCloud (const base::PointFCloudPtr &local_cloud, const Eigen::Affine3d &pose, base::PointDCloudPtr world_cloud) const
 
bool Run ()
 
bool SavePCD (size_t frame_id, LidarFrame *frame, const std::string &path)
 

Protected 属性

std::unique_ptr< BaseGroundDetector > ground_detector_
 

详细描述

在文件 offline_pointcloud_ground_detection.cc 第 44 行定义.

构造及析构函数说明

◆ OfflinePointcloudGroundDetection()

apollo::perception::lidar::OfflinePointcloudGroundDetection::OfflinePointcloudGroundDetection ( )
default

◆ ~OfflinePointcloudGroundDetection()

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

成员函数说明

◆ Init()

bool apollo::perception::lidar::OfflinePointcloudGroundDetection::Init ( )
inline

在文件 offline_pointcloud_ground_detection.cc 第 50 行定义.

50 {
51 BaseGroundDetector* ground_detector =
52 BaseGroundDetectorRegisterer::GetInstanceByName(
53 FLAGS_ground_detector_name);
54 CHECK_NOTNULL(ground_detector);
55 ground_detector_.reset(ground_detector);
56
57 GroundDetectorInitOptions ground_detector_init_options;
58 ground_detector_init_options.config_path = FLAGS_config_path;
59 ground_detector_init_options.config_file = FLAGS_config_file;
60 ACHECK(ground_detector_->Init(ground_detector_init_options))
61 << "Failed to init ground detection.";
62
63 return true;
64 }
#define ACHECK(cond)
Definition log.h:80

◆ Run()

bool apollo::perception::lidar::OfflinePointcloudGroundDetection::Run ( )
inline

在文件 offline_pointcloud_ground_detection.cc 第 90 行定义.

90 {
91 std::string pcd_folder = FLAGS_pcd_path;
92 std::vector<std::string> pcd_file_names;
93 if (!algorithm::GetFileList(pcd_folder, ".pcd", &pcd_file_names)) {
94 AERROR << "pcd_folder: " << pcd_folder << " get file list error.";
95 return false;
96 }
97
98 std::sort(pcd_file_names.begin(), pcd_file_names.end(),
99 [](const std::string& lhs, const std::string& rhs) {
100 if (lhs.length() != rhs.length()) {
101 return lhs.length() < rhs.length();
102 }
103 return lhs <= rhs;
104 });
105
106 for (size_t i = 0; i < pcd_file_names.size(); ++i) {
107 AINFO << "***************** Frame " << i << " ******************";
108 AINFO << pcd_file_names[i];
109
110 std::shared_ptr<LidarFrame> frame = LidarFramePool::Instance().Get();
111 if (frame->cloud == nullptr) {
112 frame->cloud = base::PointFCloudPool::Instance().Get();
113 }
114 if (frame->world_cloud == nullptr) {
115 frame->world_cloud = base::PointDCloudPool::Instance().Get();
116 }
117 LoadPCLPCD(pcd_file_names[i], frame->cloud.get());
118 // frame->lidar2world_pose is default identity matrix
119 TransformCloud(frame->cloud, frame->lidar2world_pose, frame->world_cloud);
120 AINFO << "Read point cloud from " << pcd_file_names[i]
121 << " with cloud size: " << frame->cloud->size();
122
123 GroundDetectorOptions ground_detector_options;
124 if (!ground_detector_->Detect(ground_detector_options, frame.get())) {
125 AERROR << "Ground detect error.";
126 return false;
127 }
128
129 std::string output_path = FLAGS_output_path;
130 SavePCD(i, frame.get(), output_path);
131 }
132
133 return true;
134 }
std::shared_ptr< ObjectType > Get() override
bool SavePCD(size_t frame_id, LidarFrame *frame, const std::string &path)
bool TransformCloud(const base::PointFCloudPtr &local_cloud, const Eigen::Affine3d &pose, base::PointDCloudPtr world_cloud) const
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
bool GetFileList(const std::string &path, const std::string &suffix, std::vector< std::string > *files)
Definition io_util.cc:163
bool LoadPCLPCD(const std::string &file_path, base::PointFCloud *cloud_out)
Definition pcl_util.h:54

◆ SavePCD()

bool apollo::perception::lidar::OfflinePointcloudGroundDetection::SavePCD ( size_t  frame_id,
LidarFrame *  frame,
const std::string &  path 
)
inline

在文件 offline_pointcloud_ground_detection.cc 第 136 行定义.

136 {
138 AERROR << "Failed to create: " << path;
139 return false;
140 }
141
142 std::string file_path = absl::StrCat(path, "/", frame_id, ".pcd");
143 WritePcdByLabel(file_path, *(frame->cloud), LidarPointLabel::GROUND);
144
145 return true;
146 }
bool EnsureDirectory(const std::string &directory_path)
Check if a specified directory specified by directory_path exists.
Definition file.cc:285
bool WritePcdByLabel(const std::string &file_path, const base::PointFCloud &cloud, const LidarPointLabel &label)
Definition pcl_util.h:74

◆ TransformCloud()

bool apollo::perception::lidar::OfflinePointcloudGroundDetection::TransformCloud ( const base::PointFCloudPtr &  local_cloud,
const Eigen::Affine3d &  pose,
base::PointDCloudPtr  world_cloud 
) const
inline

在文件 offline_pointcloud_ground_detection.cc 第 66 行定义.

68 {
69 if (local_cloud == nullptr) {
70 return false;
71 }
72 world_cloud->clear();
73 world_cloud->reserve(local_cloud->size());
74 for (size_t i = 0; i < local_cloud->size(); ++i) {
75 auto& pt = local_cloud->at(i);
76 Eigen::Vector3d trans_point(pt.x, pt.y, pt.z);
77 trans_point = pose * trans_point;
78 base::PointD world_point;
79 world_point.x = trans_point(0);
80 world_point.y = trans_point(1);
81 world_point.z = trans_point(2);
82 world_point.intensity = pt.intensity;
83 world_cloud->push_back(world_point, local_cloud->points_timestamp(i),
84 std::numeric_limits<float>::max(),
85 local_cloud->points_beam_id()[i], 0);
86 }
87 return true;
88 }
Point< double > PointD
Definition point.h:57

类成员变量说明

◆ ground_detector_

std::unique_ptr<BaseGroundDetector> apollo::perception::lidar::OfflinePointcloudGroundDetection::ground_detector_
protected

在文件 offline_pointcloud_ground_detection.cc 第 149 行定义.


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