Robotics StackExchange | Archived questions

Subscriber not receiving messages even though publisher is continuously publishing on the given same topic

Hey! Had a question I needed your clarification with! I have a publisher that continuously publishes onto a topic, and I have a subscriber node that is defined as a part of the class. For some reason, the subscriber is not receiving any messages, but when I do rostopic echo for the topic I am publishing my data on, I can see the proper data over there. I understand that this is the simple ROS setup, but for some reason, I am not able to debug this..Would you have any particular places that I can look for bugs ?

EDIT -

I ran the rqtgraph, and I have found something interesting. When I do a rostopic echo, I get a list of all the topics that I have created (as expected). But when I run the rqtgraph, I dont see any of these topics. If required, I can provide screenshots of the same.

One implementation detail that I'd like to explain - I have a .h file (headers file) where I define a class, and have declared the Publishers and Subscribers in the public variables space.

In my .cpp file, I have a constructor to which I am passing the nodehandle from my main function. I am initializing my Publishers and Suscribers.

Would this kind of an implementation be an issue???

P.S. - I am not hiding any of the below in my rqt_graph:

Dead sinks (ie: subscriptions that have no publisher) Leaf topics (ie: publishers with no subscriptions) Debug (ie: all topics used for logging msgs and related infra)

Asked by Aruco on 2018-09-05 01:01:11 UTC

Comments

Would you have any particular places that I can look for bugs ?

Well .. the first place would be your code.

But if you want our help with that you'll need to to show that code to us.

Asked by gvdhoorn on 2018-09-05 01:16:59 UTC

Also, rostopic info <your topic> will tell you what nodes are publishing/subscribing to it. rosnode info <node> is also useful. This might give you some hints as to where the node fails. Add debug statements to your code, printing out variables etc, to see where it fails.

Asked by Reamees on 2018-09-05 02:12:34 UTC

And rqt_graph will show you if perhaps you have a typo in your topic name, or a namespace problem or similar.

Asked by KenYN on 2018-09-05 02:39:43 UTC

Have edited the question with some extra implementation details.

Asked by Aruco on 2018-09-05 09:56:31 UTC

Are you using C++ or Python for your subscriber code? If C++, do you have a ros::spinOnce(); that is called periodically or a ros::spin();?

Asked by Gary Servin on 2018-09-06 09:37:25 UTC

I am having this exact same problem, no solution.

Asked by db on 2020-08-14 06:29:37 UTC

Ok, in my case the problem was that I was doing nh.subscribe("topic", 1, &cla::mehtod, this), without assigning the result anywhere. You need to assign like ros::Subscriber sub = nh.subscribe(..."

Asked by db on 2020-08-14 06:57:32 UTC

Answers