ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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

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

erwhelewoli gravatar image

Hello

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
0

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

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

Question Tools

1 follower

Stats

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

Seen: 1,847 times

Last updated: May 11 '16