I have an application where 2 nodes are talking to each other over a certain topic, based on where the nodes are at in the program flow they either don't care about the topic or they do. My question is something that the tutorials didn't help with, is there a command that can check a topic on demand? or check a specific piece of a topic on demand?
elevator_talk.publish(status);
works great for publishing on demand, is there something similar for subscribing?
Originally posted by Rydel on ROS Answers with karma: 600 on 2012-07-03
Post score: 1
Original comments
Comment by cagatay on 2012-07-03:
I am not sure but you may keep the track of subscribed topic by checking out the last time you received the data. For example if it was 10 seconds ago , then you would think that a problem might happen to the publishing node ? or you may use diagnostic_msgs to understand what is happening
Comment by Rydel on 2012-07-03:
yea your comment doesn't really help me. I guess what I'm asking is when a node is listening to a topic how would i have that node extract the most recent data from that topic and use it?
Comment by Thomas D on 2012-07-03:
You could just always go to your callback function when you receive a message, which will be the most recent one, and have a class variable you check at the beginning of the callback function to see if you should do anything with that data. Elsewhere in your code you can set the class variable.