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

ROS PointCloud2 to CloudXYZRGBA [closed]

asked 2015-09-22 10:54:31 -0500

RodBelaFarin gravatar image

I have from ROS an incoming PointCloud2 message and want to convert it to a different PointCloud message format. Can anyone help me with it? Can anyone help me to get "msg" into "input_cloud" in the followinig example?

void pcl::ihs::InHandScanner::grab_pc(const sensor_msgs::PointCloud2::ConstPtr& msg) 
        boost::function <void (const CloudXYZRGBAConstPtr&)> input_cloud; 
        //fill input_cloud here

Thanks ;)

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by RodBelaFarin
close date 2015-09-24 05:19:19.894822

1 Answer

Sort by ยป oldest newest most voted

answered 2015-09-24 05:18:30 -0500

RodBelaFarin gravatar image

For anyone interested, here is my solution:

  #include <pcl/common/common.h>
  #include <pcl/common/common_headers.h>
  #include <pcl/PCLPointCloud2.h>
  #include <pcl/conversions.h>
  #include <pcl_conversions/pcl_conversions.h>
  #include <ros/ros.h>
  #include "sensor_msgs/PointCloud2.h"

  typedef pcl::PointXYZRGBA              PointXYZRGBA;
  typedef pcl::PointCloud <PointXYZRGBA> CloudXYZRGBA;

  void pcl::ihs::InHandScanner::grab_pc(const sensor_msgs::PointCloud2 msg)
    //ros_pcl2 to pcl2
    pcl::PCLPointCloud2 pcl_pc;
    pcl_conversions::toPCL(msg, pcl_pc);

    //pcl2 to pclxyzrgba
    pcl::PointCloud<PointXYZRGBA> input_cloud;
    pcl::fromPCLPointCloud2(pcl_pc, input_cloud);
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-09-22 10:54:31 -0500

Seen: 421 times

Last updated: Sep 24 '15