Rosanswers logo

I received a very long error when I try to publish a point cloud of type pcl::PointXYZ. I suspect there is no way to publish it using that pcl type, and that I've to convert to ros PointCloud2. Is that the case.

The defined publisher:

point_cloud_pcl_publisher_ = n.advertise<pcl::PointXYZ> ("/cloud_pcl", 100);

Thanks in advance.


I declared the publisher as below:

pcl::PointCloud<pcl::PointXYZ> cloud_pcl;

In the header:

#include "ros/ros.h"
#include "std_msgs/String.h"
#include <sstream>
#include <fstream>
#include <sensor_msgs/LaserScan.h>
#include <sensor_msgs/PointCloud.h>
#include <sensor_msgs/PointCloud2.h>
#include <tf/transform_listener.h>
#include <boost/algorithm/string.hpp>
#include "tf/tf.h"
#include "tf/transform_datatypes.h"
#include <tf/transform_broadcaster.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl_ros/point_cloud.h>

The error message:

/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp_traits/include/ros/message_traits.h: In static member function ‘static const char* ros::message_traits::MD5Sum::value() [with M = pcl::PointXYZ]’: /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp_traits/include/ros/message_traits.h:228: instantiated from ‘const char* ros::message_traits::md5sum() [with M = pcl::PointXYZ]’ /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/advertise_options.h:92: instantiated from ‘void ros::AdvertiseOptions::init(const std::string&, uint32_t, const ros::SubscriberStatusCallback&, const ros::SubscriberStatusCallback&) [with M = pcl::PointXYZ]’ /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/node_handle.h:239: instantiated from ‘ros::Publisher ros::NodeHandle::advertise(const std::string&, uint32_t, bool) [with M = pcl::PointXYZ]’ /home/shah/code/ros_workspace/point_cloud_drone/src/pointcloud_builder_node.cpp:192: instantiated from here /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp_traits/include/ros/message_traits.h:121: error: ‘__s_getMD5Sum’ is not a member of ‘pcl::PointXYZ’ /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp_traits/include/ros/message_traits.h: In static member function ‘static const char* ros::message_traits::DataType::value() [with M = pcl::PointXYZ]’:

Originally posted by alfa_80 on ROS Answers with karma: 1053 on 2012-02-11

Post score: 0


2 Answers 2


Rosanswers logo

You need to advertise the PointCloud templated on the Point type, not just the point type.

Something like:

point_cloud_pcl_publisher_ = n.advertise<pcl::PointCloud<pcl::PointXYZ> > ("/cloud_pcl", 100);

Originally posted by tfoote with karma: 58457 on 2012-02-11

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by alfa_80 on 2012-02-11:
Sorry, no need for the link, it's actually there in my declaration, the type itself..what a silly mistake.

Comment by alfa_80 on 2012-02-11:
Thanks a lot tfoote, could you provide the link so that I or others won't repeat this kind of mistake.

Comment by gaussian on 2015-02-01:
Is it enough if I import PointXYZ and publish using that datatype in python? Does the conversion take place implicitly?

Comment by alfa_80 on 2015-02-08:
Yes, it's enough. It takes place implicitly.


Rosanswers logo

Make sure you have this in your code:

#include <pcl_ros/point_cloud.h>

And the dependency to pcl_ros in your manifest.

Originally posted by Ivan Dryanovski with karma: 4954 on 2012-02-11

This answer was NOT ACCEPTED on the original site

Post score: 1

Original comments

Comment by Ivan Dryanovski on 2012-02-11:
Could you post a little more code? The headers you include, and the error itself?

Comment by alfa_80 on 2012-02-11:
Yes, those 2 were already there. However, it still complaints.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.