// myPCL.cpp
#define PCL_NO_PRECOMPILE
...
#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
...
struct MyPointType
{
PCL_ADD_POINT4D;
uint16_t reflectivity;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
} EIGEN_ALIGN16;
POINT_CLOUD_REGISTER_POINT_STRUCT (MyPointType,
(float, x, x)
(float, y, y)
(float, z, z)
(uint16_t, reflectivity, reflectivity)
)
pcl::PointCloud<MyPointType>::Ptr cloud (new pcl::PointCloud<MyPointType>());
pcl::PointCloud<MyPointType>::Ptr cloud_passed (new pcl::PointCloud<MyPointType>);
pcl::PassThrough<MyPointType> pass;
pass.setInputCloud(cloud);
pass.setFilterFieldName("x");
pass.setFilterLimits(0.0, 20.0);
pass.filter(*cloud_passed);
pcl::VoxelGrid를 사용하여 다운샘플링을 하면 좌표(x,y,z)외의 데이터는 유실된다.