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 rqt_graph, 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 rqt_graph, 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)
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.
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.And
rqt_graph
will show you if perhaps you have a typo in your topic name, or a namespace problem or similar.Have edited the question with some extra implementation details.
Are you using C++ or Python for your subscriber code? If C++, do you have a
ros::spinOnce();
that is called periodically or aros::spin();
?I am having this exact same problem, no solution.
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 likeros::Subscriber sub = nh.subscribe(...
"