Compatibility of .pcd files in ROS and standalone PCL
Hi,
This is not a question but I don't know where to post it, so please move the topic to the appropriate forum.
For the last few days I've had trouble displaying .pcd files in pcl_visualization pcd_viewer that work properly with the standalone PCL's pcd_viewer and vice-versa (mainly I wanted to process the .pcd files saved generated in RGBDSLAM).
I was unable to find a solution on the Web (just suggestions to install the unstable version of ROS) but now I've found one, so I post it here in case someone has the same problem.
SOLUTION: Create a ros package and add a source file with the following code (the output cloud is XYZ with no color):
#include <pcl/ros/conversions.h>
#include <pcl/io/pcd_io.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
int
main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
if (pcl::io::loadPCDFile<pcl::PointXYZ> (argv[1], *cloud) == -1)
{
std::cout << "ERROR: couldn't read the pcd file!" << std::endl;
return (-1);
}
pcl::io::savePCDFileASCII ("output_cloud.pcd", *cloud);
std::cout << "Converted!" << std::endl;
return (0);
}
rosmake it and execute passing the name of your .pcd file. You'll be able to open correctly the output file either with ROS and standalone PCL.