目录
参考:How to use a PCL tutorial in ROS
1 创建功能包
$ catkin_create_pkg my_pcl_tutorial pcl_conversions pcl_ros roscpp sensor_msgs
修改package.xml
<build_depend>libpcl-all-dev</build_depend>
<exec_depend>libpcl-all</exec_depend>
2 代码框架
使用一个subscriber接收点云数据,在callback函数中处理点云,然后用一个publisher发送处理后的点云。(与PCL教程的最大区别就是数据的通信)
// scr/example.cpp
#include <ros/ros.h>
// PCL specific includes
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
ros::Publisher pub;
// callback function
void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input)
{
// Create a container for the data.
sensor_msgs::PointCloud2 output;
// Do data processing here...
output = *input;
// Publish the data.
pub.publish (output);
}
int main (int argc, char** argv)
{
// Initialize ROS
ros::init (argc, argv, &#