0
$\begingroup$

Rosanswers logo

Hey guys,

I'm using an XV-11 and IMU to create a 3D sensor_msgs::PointCloud which is successfully advertised on a topic. I want to convert that cloud into a sensor_msgs::PointCloud2 and then pcl::PointCloud. I would also like to convert the intensities into RGB values, but I was having too many problems accessing/editing the rgb values for pcl::PointCloudpcl::PointXYZRGB. So, I ended up with this code for just the XYZ values...

    sensor_msgs::PointCloud cloud_out;
    sensor_msgs::PointCloud2 cloud2_out;

... calculations and unnecessary code omitted

    sensor_msgs::convertPointCloudToPointCloud2 (cloud_out, cloud2_out);
    pcl::PointCloud<pcl::PointXYZ> pcl_cloud;
    pcl::fromROSMsg(cloud2_out, pcl_cloud);
    pcl::io::savePCDFileASCII ("test_pcd123.pcd", pcl_cloud);

which compiles and runs without any errors, except that test_pcd123.pcd cannot be found anywhere on my computer. Any ideas on what's going wrong?

When I use std::cerr << "Saved " << pcl_cloud.points.size () << " data points to test_pcd.pcd." << std::endl;, a correct message of Saved 360 data points to test_pcd.pcd. is shown


Originally posted by ateator on ROS Answers with karma: 37 on 2016-07-19

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Made a minor change, now it works

    pcl::PointCloud<pcl::PointXYZ> pcl_cloud;
    pcl::fromROSMsg(cloud2_out, pcl_cloud);

    writeCount++;
    char filename[100];
    sprintf(filename, "/home/ateator/catkin_ws/src/laser_assembler/src/outputpcd/output%dx.pcd", writeCount);

    pcl::io::savePCDFileASCII (filename, pcl_cloud);

Originally posted by ateator with karma: 37 on 2016-07-19

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.