Robotics StackExchange | Archived questions

ROS PointCloud2 to CloudXYZRGBA

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 ;)

Asked by RodBelaFarin on 2015-09-22 10:54:31 UTC

Comments

Answers

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);
  } 

Asked by RodBelaFarin on 2015-09-24 05:18:30 UTC

Comments