Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Subscribe to sensor_msgs/PointCloud

Hey,

i have a node that publishes sensor_msgs/PointCloud data and i want to subscribe to this. My Subscriber looks like this:

distance_sub = nh.subscribe<pcl::PointCloud<pcl::PointXYZ>>("/distance_sensors", 1, &SafetyBelt::distanceCallback, this);

I included the point_cloud.h and the point_types.h headers. But i am not able to compile this Code and i have no idea what the error means:

/opt/ros/indigo/include/ros/subscribe_options.h:111:54:   required from ‘void ros::SubscribeOptions::init(const 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>; std::string = std::basic_string<char>; uint32_t = unsigned int]’
  /opt/ros/indigo/include/ros/node_handle.h:443:5:   required from ‘ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(const boost::shared_ptr<const M>&), T*, const ros::TransportHints&) [with M = pcl::PointCloud<pcl::PointXYZ>; T = SafetyBelt; std::string = std::basic_string<char>; uint32_t = unsigned int]’
  /home/daniel/Desktop/robotino/trunk2/trunk/robotino/robotino_teleop/src/SafetyBelt.cpp:16:121:   required from here
  /opt/ros/indigo/include/ros/message_traits.h:138:31: error: ‘__s_getDataType’ is not a member of ‘pcl::PointCloud<pcl::PointXYZ>’
       return M::__s_getDataType().c_str();
                                 ^
  In file included from /opt/ros/indigo/include/ros/publisher.h:34:0,
                   from /opt/ros/indigo/include/ros/node_handle.h:32,
                   from /opt/ros/indigo/include/ros/ros.h:45,
                   from /home/daniel/Desktop/robotino/trunk2/trunk/robotino/robotino_teleop/include/SafetyBelt.h:1,
                   from /home/daniel/Desktop/robotino/trunk2/trunk/robotino/robotino_teleop/src/SafetyBelt.cpp:1:
  /opt/ros/indigo/include/ros/serialization.h: In instantiation of ‘static void ros::serialization::Serializer<T>::read(Stream&, typename boost::call_traits<T>::reference) [with Stream = ros::serialization::IStream; T = pcl::PointCloud<pcl::PointXYZ>; typename boost::call_traits<T>::reference = pcl::PointCloud<pcl::PointXYZ>&]’:
  /opt/ros/indigo/include/ros/serialization.h:163:32:   required from ‘void ros::serialization::deserialize(Stream&, T&) [with T = pcl::PointCloud<pcl::PointXYZ>; Stream = ros::serialization::IStream]’
  /opt/ros/indigo/include/ros/subscription_callback_helper.h:136:34:   required from ‘ros::VoidConstPtr ros::SubscriptionCallbackHelperT<P, Enabled>::deserialize(const ros::SubscriptionCallbackHelperDeserializeParams&) [with P = const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZ> >&; Enabled = void; ros::VoidConstPtr = boost::shared_ptr<const void>]’
  /home/daniel/Desktop/robotino/trunk2/trunk/robotino/robotino_teleop/src/SafetyBelt.cpp:81:1:   required from here
  /opt/ros/indigo/include/ros/serialization.h:136:5: error: ‘class pcl::PointCloud<pcl::PointXYZ>’ has no member named ‘deserialize’
       t.deserialize(stream.getData());
       ^
  In file included from /opt/ros/indigo/include/ros/serialization.h:37:0,
                   from /opt/ros/indigo/include/ros/publisher.h:34,
                   from /opt/ros/indigo/include/ros/node_handle.h:32,
                   from /opt/ros/indigo/include/ros/ros.h:45,
                   from /home/daniel/Desktop/robotino/trunk2/trunk/robotino/robotino_teleop/include/SafetyBelt.h:1,
                   from /home/daniel/Desktop/robotino/trunk2/trunk/robotino/robotino_teleop/src/SafetyBelt.cpp:1:
  /opt/ros/indigo/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/indigo/include/ros/message_traits.h:122:3: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
  /opt/ros/indigo/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/indigo/include/ros/message_traits.h:139:3: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^

Can anyone tell me how to correctly subscribe to this topic?

Best regards Daniel