ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Convert sensor_msgs::PointCloud2ConstPtr to pcl::PointCloud<pcl::PointXYZ>::Ptr

asked 2016-05-11 03:22:23 -0500

erwhelewoli gravatar image


I'm using the SampleConsensusModelLine, which requires a pointcloud on the form of pcl::PointCloud<pcl::pointxyz>::Ptr. However, the callback for the point cloud uses the form sensor_msgs::PointCloud2ConstPtr. How do I convert one to the other?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-05-11 04:07:42 -0500

Jbot gravatar image

To convert PCLPointCloud2::Ptr to PointCloud<pcl::pointxyz> , you have to use the function "fromPCLPointCloud2".

For example :

pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2 ());
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered1 (new pcl::PointCloud<pcl::PointXYZ>()); 

pcl::fromPCLPointCloud2(*(cloud_filtered), *(cloud_filtered1));
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-05-11 03:22:23 -0500

Seen: 1,741 times

Last updated: May 11 '16