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

conversion of PointCloud2 to pcl pointcloud using python

asked 2016-06-08 18:21:22 -0600

krishna43 gravatar image

Hello ROS gurus,

I am working on python pcl and point clouds. Is there a way where i can convert sensor_msgs.msg/PointCloud2 type to PCL point cloud using python, so i can use PCL functions on the data.

Any help is appreciated.

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-06-09 02:27:58 -0600

ROSkinect gravatar image

You can use this code even if it is in C++.. but I think you can write your own python version from it.

#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
    }
edit flag offensive delete link more

Comments

Hey,

Thanks for the code. I already came across this code snippet, as i mentioned in my post i am looking for python version of it. Do you have a code snippet in python version that i can develop on. I am not really good at C++ and in python with what modules should i import instead of .h files?

krishna43 gravatar image krishna43  ( 2016-06-10 15:15:57 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-06-08 18:21:22 -0600

Seen: 2,078 times

Last updated: Jun 09 '16