February 2018
Beginner
580 pages
13h 20m
English
We can save the point cloud to a PCD file by using the following code. The filename is pcl_write.cpp inside the src folder:
#include <ros/ros.h> #include <pcl/point_cloud.h> #include <pcl_conversions/pcl_conversions.h> #include <sensor_msgs/PointCloud2.h> //Header file for writing PCD file #include <pcl/io/pcd_io.h> void cloudCB(const sensor_msgs::PointCloud2 &input) { pcl::PointCloud<pcl::PointXYZ> cloud; pcl::fromROSMsg(input, cloud); //Save data as test.pcd file pcl::io::savePCDFileASCII ("test.pcd", cloud); } main (int argc, char **argv) { ros::init (argc, argv, "pcl_write"); ROS_INFO("Started PCL write node"); ros::NodeHandle nh; ros::Subscriber bat_sub = nh.subscribe("pcl_output", 10, cloudCB); ...Read now
Unlock full access