20 #include "pcl/filters/voxel_grid.h" 21 #include "pcl/io/pcd_io.h" 22 #include "pcl/point_types.h" 28 namespace perception {
42 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
50 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
55 pcl::PointCloud<PCLPointXYZIT> org_cloud;
56 if (pcl::io::loadPCDFile(file_path, org_cloud) < 0) {
57 AERROR <<
"Failed to load pcd file " << file_path;
60 cloud_out->
resize(org_cloud.size());
61 for (
size_t i = 0; i < org_cloud.size(); ++i) {
62 auto& pt = org_cloud.points[i];
63 auto& new_pt = cloud_out->
at(i);
67 new_pt.intensity = pt.intensity;
95 template <
typename Po
intT>
98 const pcl::PointCloud<pcl::PointXYZI>::Ptr& out_cloud_ptr) {
99 for (
size_t i = 0; i < org_cloud.
size(); ++i) {
100 PointT pt = org_cloud.
at(i);
101 pcl::PointXYZI point;
102 point.x =
static_cast<float>(pt.x);
103 point.y =
static_cast<float>(pt.y);
104 point.z =
static_cast<float>(pt.z);
105 point.intensity =
static_cast<float>(pt.intensity);
106 out_cloud_ptr->push_back(point);
111 const pcl::PointCloud<pcl::PointXYZI>::Ptr& org_cloud_ptr,
113 for (
size_t i = 0; i < org_cloud_ptr->size(); ++i) {
114 const auto& pt = org_cloud_ptr->at(i);
120 out_cloud_ptr->push_back(point);
125 const pcl::PointCloud<pcl::PointXYZI>::Ptr& cloud_ptr,
126 const pcl::PointCloud<pcl::PointXYZI>::Ptr& filtered_cloud_ptr,
127 float lx = 0.01f,
float ly = 0.01f,
float lz = 0.01f) {
128 pcl::VoxelGrid<pcl::PointXYZI> voxel_grid;
129 voxel_grid.setInputCloud(cloud_ptr);
130 voxel_grid.setLeafSize(lx, ly, lz);
131 voxel_grid.filter(*filtered_cloud_ptr);
139 (
float,
x,
x)(
float,
y,
y)(
float,
z,
z)(
144 (
float,
x,
x)(
float,
y,
y)(
float,
z,
z)(
145 std::uint32_t, label, label))
void resize(const size_t size) override
Definition: point_cloud.h:324
Definition: pcl_util.h:45
float z
Definition: pcl_util.h:39
void TransformFromPCLXYZI(const pcl::PointCloud< pcl::PointXYZI >::Ptr &org_cloud_ptr, const base::PointFCloudPtr &out_cloud_ptr)
Definition: pcl_util.h:110
float y
Definition: pcl_util.h:38
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:124
pcl::PointXYZRGB CPoint
Definition: pcl_util.h:31
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
pcl::PointCloud< CPoint >::Ptr CPointCloudPtr
Definition: pcl_util.h:33
pcl::PointCloud< CPoint > CPointCloud
Definition: pcl_util.h:32
pcl::PointCloud< CPoint >::ConstPtr CPointCloudConstPtr
Definition: pcl_util.h:34
T x
Definition: point.h:29
size_t size() const
Definition: point_cloud.h:83
double timestamp
Definition: pcl_util.h:41
float x
Definition: pcl_util.h:46
struct apollo::perception::lidar::PCLPointXYZIT EIGEN_ALIGN16
T z
Definition: point.h:31
Definition: point_cloud.h:264
uint32_t label
Definition: pcl_util.h:49
Definition: pcl_util.h:36
float z
Definition: pcl_util.h:48
float y
Definition: pcl_util.h:47
std::vector< double > * mutable_points_timestamp()
Definition: point_cloud.h:445
std::uint8_t intensity
Definition: pcl_util.h:40
bool LoadPCLPCD(const std::string &file_path, base::PointFCloud *cloud_out)
Definition: pcl_util.h:53
std::shared_ptr< PointFCloud > PointFCloudPtr
Definition: point_cloud.h:482
void TransformToPCLXYZI(const base::AttributePointCloud< PointT > &org_cloud, const pcl::PointCloud< pcl::PointXYZI >::Ptr &out_cloud_ptr)
Definition: pcl_util.h:96
T intensity
Definition: point.h:32
#define AERROR
Definition: log.h:44
float x
Definition: pcl_util.h:37
T y
Definition: point.h:30
const PointT * at(size_t col, size_t row) const
Definition: point_cloud.h:64