Apollo 11.0
自动驾驶开放平台
pcl_down_sample.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2024 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
18
19#include <algorithm>
20
23
24namespace apollo {
25namespace perception {
26namespace lidar {
27
29 std::string config_file =
30 GetConfigFile(options.config_path, options.config_file);
32 ACHECK(cyber::common::GetProtoFromFile(config_file, &config));
33 downsample_voxel_size_x_ = config.downsample_voxel_size_x();
34 downsample_voxel_size_y_ = config.downsample_voxel_size_y();
35 downsample_voxel_size_z_ = config.downsample_voxel_size_z();
36 AINFO << "PclDownSample plugin init success.";
37 return true;
38}
39
41 base::PointFCloudPtr& cloud_ptr) {
42 pcl::PointCloud<pcl::PointXYZI>::Ptr pcl_cloud_ptr(
43 new pcl::PointCloud<pcl::PointXYZI>());
44 pcl::PointCloud<pcl::PointXYZI>::Ptr filtered_cloud_ptr(
45 new pcl::PointCloud<pcl::PointXYZI>());
46
47 TransformToPCLXYZI(*cloud_ptr, pcl_cloud_ptr);
48 DownSampleCloudByVoxelGrid(pcl_cloud_ptr, filtered_cloud_ptr,
49 downsample_voxel_size_x_, downsample_voxel_size_y_,
50 downsample_voxel_size_z_);
51 // transform pcl point cloud to apollo point cloud
52 base::PointFCloudPtr downsample_voxel_cloud_ptr(new base::PointFCloud());
53 TransformFromPCLXYZI(filtered_cloud_ptr, downsample_voxel_cloud_ptr);
54 cloud_ptr = downsample_voxel_cloud_ptr;
55 return true;
56}
57
58} // namespace lidar
59} // namespace perception
60} // namespace apollo
bool Init(const DownSampleInitOptions &options=DownSampleInitOptions()) override
Init of PclDownSample object
bool Process(const DownSampleOptions &options, base::PointFCloudPtr &cloud_ptr) override
Down sample pointcloud
#define ACHECK(cond)
Definition log.h:80
#define AINFO
Definition log.h:42
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::shared_ptr< PointFCloud > PointFCloudPtr
void TransformToPCLXYZI(const base::AttributePointCloud< PointT > &org_cloud, const pcl::PointCloud< pcl::PointXYZI >::Ptr &out_cloud_ptr)
Definition pcl_util.h:100
void DownSampleCloudByVoxelGrid(const pcl::PointCloud< pcl::PointXYZI >::Ptr &cloud_ptr, const pcl::PointCloud< pcl::PointXYZI >::Ptr &filtered_cloud_ptr, float lx=0.01f, float ly=0.01f, float lz=0.01f)
Definition pcl_util.h:128
void TransformFromPCLXYZI(const pcl::PointCloud< pcl::PointXYZI >::Ptr &org_cloud_ptr, const base::PointFCloudPtr &out_cloud_ptr)
Definition pcl_util.h:114
std::string GetConfigFile(const std::string &config_path, const std::string &config_file)
Definition util.cc:80
class register implement
Definition arena_queue.h:37