Skip to content

Instantly share code, notes, and snippets.

@Kyungpyo-Kim
Created April 30, 2018 06:07
Show Gist options
  • Select an option

  • Save Kyungpyo-Kim/b0cd1528913cb36bab6779a384dd2021 to your computer and use it in GitHub Desktop.

Select an option

Save Kyungpyo-Kim/b0cd1528913cb36bab6779a384dd2021 to your computer and use it in GitHub Desktop.
PCL, ROS, sensor_msgs::PointCloud2 to PCL type
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_types.h>
#include <pcl/PCLPointCloud2.h>
#include <pcl/conversions.h>
#include <pcl_ros/transforms.h>
void cloud_cb(const boost::shared_ptr<const sensor_msgs::PointCloud2>& input){
pcl::PCLPointCloud2 pcl_pc2;
pcl_conversions::toPCL(*input,pcl_pc2);
pcl::PointCloud<pcl::PointXYZ>::Ptr temp_cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::fromPCLPointCloud2(pcl_pc2,*temp_cloud);
//do stuff with temp_cloud here
}
// Reference
/*
/* https://answers.ros.org/question/136916/conversion-from-sensor_msgspointcloud2-to-pclpointcloudt/
*/
@Pran-Seven
Copy link
Copy Markdown

Hey, thanks a lot for the repo, but I need pointcloud stitching to be specfic and not just merge. My code works as expected only issue being the point cloud becomes unordered in the end leading to difficulties in using various pcl algorithms, trying to find workarounds for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment