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

Writing a Simple Subscriber

asked 2016-01-25 12:06:54 -0600

kmoy gravatar image

I went through the ROS tutorial for writing a simple publisher and subscriber with the '/chatter' topic, and I'm able to successfully subscribe to the 'chatter' topic and respond with the chatterCallback.

I wish to implement this simple subscriber with another existing ROS topic, called '/points', which is a PointCloud2 message. This topic shows up when I type 'rostopic list' and 'rostopic echo /points'. However, the subscriber will not respond when I change the topic from '/chatter' to '/points'.

I already modified the CMakeLists.txt and package.xml file to add the 'sensor_msgs' package as a build and run dependency. Is there something else I need to do?

edit retag flag offensive close merge delete



There likely are other things you need to do... If you are in C++, you'll need to include new files, change templates and callback signatures, and recompile your workspace. It would be helpful to see your code, and if it is C++, your CMakeLists.txt

jarvisschultz gravatar image jarvisschultz  ( 2016-01-25 17:28:40 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-01-26 02:49:12 -0600

Wolf gravatar image

As @jarvisschultz mentioned, you need to change the type also. A subscriber can only subscribe to messages of a specifc type. E. g. for C++ you need to bind your subcriber to a callback that can handle pointCloud2 msgs. An example for such callback including conversion to the native PCL type you need for accessing the data is given here:

edit flag offensive delete link more

Question Tools


Asked: 2016-01-25 12:06:54 -0600

Seen: 252 times

Last updated: Jan 26 '16