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

Is current value of a Topic obtainable if data is not changing?

asked 2014-06-24 20:23:01 -0500

I'm fairly new to ROS, so forgive me if this is a dumb question.

One of my Topics holds some initialization data that never really changes after several seconds of my node running. I noticed that when I run the rqt Topic Monitor plugin (rosrun rqt_topic rqt_topic) it does not show me a value for that topic if I click the checkbox after the last change was published.

Is this an rqt Topic Monitor bug or is this how all ROS Topics work? Do I need to actively cyclically publish the same data value over and over just for late subscribers to see? That seems lame. Does ROS have a means for late subscribers to grab the current value of a Topic?

Maybe I'm using the wrong tool for the job. Any advise would be appreciated. Thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-06-25 02:14:15 -0500

fergs gravatar image

What you want is a "latched" topic. Normally, when a new subscriber connects, it will only get messages which you publish after the connection is made. If you set the topic to latched, when a new subscriber connects, they will always get the last message published, regardless of how long ago you actually published it (of course, your publisher node still needs to be running). This is used for data that rarely changes, but needs to be available regardless of when a node starts (for instance, the map_server package uses a latched topic for the map).

The overview for each supported ROS language shows how to create a latched topic, by passing the right parameters when advertising, for python, this can be found at http://wiki.ros.org/rospy/Overview/Pu...

edit flag offensive delete link more

Comments

Great! Thanks! I'm new enough that I've gone through all the Tutorials but I had not explored the overview under Usage Docs. That's an area that I need to start reading. Here is the C++ version: http://wiki.ros.org/roscpp/Overview/Publishers%20and%20Subscribers

Kurt Leucht gravatar image Kurt Leucht  ( 2014-06-25 09:28:37 -0500 )edit
0

answered 2014-06-24 20:35:45 -0500

One option is to use the Parameter server to store data that hardly ever changes. The interested node(s) would need to poll for the data and will not be notified of changes. So that is one trade off.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-06-24 20:23:01 -0500

Seen: 1,285 times

Last updated: Jun 25 '14