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

PCL Header to Sensor_msg convertion problem

asked 2015-01-21 13:42:12 -0600

Pototo gravatar image

updated 2015-01-21 15:37:48 -0600


I have this code snippet (I wrote it):

#include "depth_image_proc.h"
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <sensor_msgs/image_encodings.h>
#include <image_geometry/pinhole_camera_model.h>
#include <sensor_msgs/PointCloud2.h>

generatePCL::generatePCL(const sensor_msgs::ImageConstPtr& depth_msg,          
        const sensor_msgs::CameraInfoConstPtr& info_m)                         
    cloud_msg.header = depth_msg->header;                                      
    cloud_msg.height = depth_msg->height;                                      
    cloud_msg.width  = depth_msg->width;                                       
    cloud_msg.is_dense = false;
    cloud_msg.points.resize(cloud_msg.height * cloud_msg.width);                                                 

Where cloud_msg is defined as:

pcl::PointCloud<pcl::PointXYZ> cloud_msg;

But after I run the code I get this error:

depth_image_proc.cpp: In constructor ‘generatePCL::generatePCL(const ImageConstPtr&, const CameraInfoConstPtr&)’:
depth_image_proc.cpp:16:19: error: no match for ‘operator=’ (operand types are ‘pcl::PCLHeader’ and ‘const _header_type {aka const std_msgs::Header_<std::allocator<void> >}’)
  cloud_msg.header = depth_msg->header;

Is there a library I am missing? Or a new format? This code was running in Fuerte, and now I am trying to make it run in Indigo.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2015-01-21 16:15:52 -0600

joq gravatar image

updated 2015-01-22 14:06:35 -0600

There were incompatible changes to the way ROS uses PCL between Groovy and Hydro.

Please consult the Hydro migration guide for details.

EDIT: since Groovy there is a new pcl_conversions package that may help with your problem. The API doc is here.

edit flag offensive delete link more


I still can't find the way to convert sensor_msgs::ImageConstPtr& to pcl::PointCloud<pcl::pointxyz> Every function I sue (such as pcl::toPCL) always gives me an error that there is not matching function.

Pototo gravatar image Pototo  ( 2015-01-21 18:06:48 -0600 )edit

Question Tools

1 follower


Asked: 2015-01-21 13:42:12 -0600

Seen: 1,323 times

Last updated: Jan 22 '15