0
$\begingroup$

Rosanswers logo

Hello, I am currently running ros electric on Ubuntu 10.04, using a Kinect sensor and trying to subscribe to the /camera/depth/points topic published by openni_launch. Doing it the following way works:

cloudsub = n.subscribe <sensor_msgs::PointCloud2> ("/camera/depth/points", 1, cloudcb);

However, when trying to subscribe to it as follows:

cloudsub = n.subscribe <pcl::PointCloud<pcl::PointXYZ> > ("/camera/depth/points", 1, cloudcb);

I get the error message below:

In file included from /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp_serialization/include/ros/serialization.h:37,
             from /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/publisher.h:34,
             from /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/node_handle.h:32,
             from /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/ros.h:45,
             from /home/rune/ros_workspace/hand_tracker/src/segment.cpp:1:
/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<M>::value() [with M = pcl::PointCloud<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::PointCloud<pcl::PointXYZ>]’
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/subscribe_options.h:110:   instantiated from ‘void ros::SubscribeOptions::init(const std::string&, uint32_t, const boost::function<void(const boost::shared_ptr<const M>&)>&, const boost::function<boost::shared_ptr<X>()>&) [with M = pcl::PointCloud<pcl::PointXYZ>]’
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/node_handle.h:665:   instantiated from ‘ros::Subscriber ros::NodeHandle::subscribe(const std::string&, uint32_t, void (*)(const boost::shared_ptr<const M>&), const ros::TransportHints&) [with M = pcl::PointCloud<pcl::PointXYZ>]’
/home/rune/ros_workspace/hand_tracker/src/segment.cpp:216:   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::PointCloud<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<M>::value() [with M = pcl::PointCloud<pcl::PointXYZ>]’:
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp_traits/include/ros/message_traits.h:237:   instantiated from ‘const char* ros::message_traits::datatype() [with M = pcl::PointCloud<pcl::PointXYZ>]’
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/subscribe_options.h:111:   instantiated from ‘void ros::SubscribeOptions::init(const std::string&, uint32_t, const boost::function<void(const boost::shared_ptr<const M>&)>&, const boost::function<boost::shared_ptr<X>()>&) [with M = pcl::PointCloud<pcl::PointXYZ>]’
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/node_handle.h:665:   instantiated from ‘ros::Subscriber ros::NodeHandle::subscribe(const std::string&, uint32_t, void (*)(const boost::shared_ptr<const M>&), const ros::TransportHints&) [with M = pcl::PointCloud<pcl::PointXYZ>]’
/home/rune/ros_workspace/hand_tracker/src/segment.cpp:216:   instantiated from here
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp_traits/include/ros/message_traits.h:138: error: ‘__s_getDataType’ is not a member of ‘pcl::PointCloud<pcl::PointXYZ>’
In file included from /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/publisher.h:34,
             from /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/node_handle.h:32,
             from /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/ros.h:45,
             from /home/rune/ros_workspace/hand_tracker/src/segment.cpp:1:
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp_serialization/include/ros/serialization.h: In static member function ‘static void ros::serialization::Serializer<T>::read(Stream&, typename boost::call_traits<T>::reference) [with Stream = ros::serialization::IStream, T = pcl::PointCloud<pcl::PointXYZ>]’:
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp_serialization/include/ros/serialization.h:161:   instantiated from ‘void ros::serialization::deserialize(Stream&, T&) [with T = pcl::PointCloud<pcl::PointXYZ>, Stream = ros::serialization::IStream]’
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/subscription_callback_helper.h:169:   instantiated from ‘ros::VoidConstPtr ros::SubscriptionCallbackHelperT<P, Enabled>::deserialize(const ros::SubscriptionCallbackHelperDeserializeParams&) [with P = const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZ> >&, Enabled = void]’
/home/rune/ros_workspace/hand_tracker/src/segment.cpp:228:   instantiated from here
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp_serialization/include/ros/serialization.h:134: error: ‘class pcl::PointCloud<pcl::PointXYZ>’ has no member named ‘deserialize’
make[3]: *** [CMakeFiles/segment.dir/src/segment.o] Error 1
make[3]: Leaving directory `/home/rune/ros_workspace/hand_tracker/build'
make[2]: *** [CMakeFiles/segment.dir/all] Error 2
make[2]: Leaving directory `/home/rune/ros_workspace/hand_tracker/build'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/rune/ros_workspace/hand_tracker/build'
make: *** [all] Error 2

The one that gives me the error message is the one suggested on http://www.ros.org/wiki/pcl_ros, but I dont seem to be able to make it work. At the moment, my cloudcb function isn't even doing anything, so that shouldn't be the problem. It looks like:

void cloudcb(const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &msg) { }

while the working function is:

void cloudcb(const sensor_msgs::PointCloud2ConstPtr &msg) { }

Btw, "cloudsub = n.subscribe ..." is line 216, while line 228 is the last one in the file


Originally posted by rune on ROS Answers with karma: 13 on 2011-10-13

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

To clarify fergs' answer, it looks like you've done

#include <pcl/point_cloud.h>
#include <pcl/point_types.h>

but not

#include <pcl_ros/point_cloud.h>

The pcl/XXX headers define pcl::PointCloud and pcl::PointXYZ types used by PCL. However, PCL is a stand-alone library that knows nothing about ROS. If you include only those headers, ROS doesn't know what to do with pcl::PointCloud, because it's not a native ROS message type. Thus the ROS serialization code barfs.

pcl_ros/point_cloud.h contains the glue code that tells ROS how to serialize/deserialize pcl::PointCloud. This code serializes pcl::PointCloud into exactly the same over-the-wire format as the ROS-native sensor_msgs/PointCloud2 message type, which is why you can use them interchangeably in your subscriber code.

If you exactly cut-and-paste the subscribing example, does it work?


Originally posted by Patrick Mihelich with karma: 4336 on 2011-10-13

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by rune on 2011-10-15:
It worked. Thanks!

Comment by rune on 2011-10-14:
Ah, how silly. I have indeed forgot to include pcl_ros/point_cloud.h. I am not able to test this at the moment, but I'm sure this will help. Thanks! I'll post an update when I have actually made sure it works

Comment by KARTHIK MURUGAN on 2012-12-08:
hi. I have a bagfile containing Velodyne pointcloud data. i rosbag play it to publish msgs on type sensor_msgs/PointCloud2. I want a range image. is it mandatory to convert it to PointCloud ?Any ideas how to use PointCloud2 type and obtain range image?any links?

$\endgroup$

Your Answer

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