ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

rospy getting two publishers

asked 2014-09-22 19:21:42 -0500

felipe.roman gravatar image

updated 2014-09-22 19:30:37 -0500

ahendrix gravatar image

Hi All,

I have a two or more nodes publishing in the diagnostic topic.

roman@roman-virtual-machine1:~/nagios$ rostopic info diagnostics
Type: diagnostic_msgs/DiagnosticArray

 * /mobile_base_nodelet_manager (http://roman-virtual-machine1:35669/)
 * /play_1410810684593700345 (http://roman-virtual-machine1:40540/)

I am trying to read all Publishers information but when I use rospy I get only one Publisher at the time.

def listener():
    #rospy.init_node('check_battery_kobuki', anonymous=True,  disable_signals=True, log_level=rospy.DEBUG)
    rospy.init_node('ros_diagnostics', anonymous=True,  disable_signals=True)
    rospy.Subscriber("diagnostics", DiagnosticArray , callback_kobuki)

Is there a way to get all Publishers in the same connection ?

Thanks in advance, Felipe Roman

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-09-22 19:46:25 -0500

ahendrix gravatar image

In short: no.

The unit of transport in ROS is a message, and publishers are anonymous, so it doesn't make sense to ask which publisher a message came from. Publishers aren't required to publish at the same or with the same frequency either, so it doesn't make sense to deliver the data from all publishers simultaneously.

If you're trying to aggregate diagnostics data, you may want to look at the diagnostic_aggregator and either use it, or implement a similar algorithm in your own code.

edit flag offensive delete link more

answered 2014-09-23 05:44:37 -0500

felipe.roman gravatar image

Yes, I am trying to aggregate data. I already had a look on the diagnostic_agg topic as well, may I can use this one instead but the diagnostic is more complete (all information) then the diagnostic_agg that's why I am trying to get all information published in the diagnostic at the same time.

I developed the python testing in my local environment where there is only one publisher and it worked fine, when I tried in the lab with real robots the problem happened cause there are more than one publisher at the diagnostic topic.

But if is not possible I will try a new approach.


edit flag offensive delete link more


The diagnositc_aggregator actually provides MORE information than the raw diagnostics topic, because it aggregates all of the individual diagnostics by name, and provides staleness timeouts for each device.

ahendrix gravatar image ahendrix  ( 2014-09-23 13:19:02 -0500 )edit

If you want to implement something similar yourself, you should collect individual diagnostics by their device name.

ahendrix gravatar image ahendrix  ( 2014-09-23 13:19:50 -0500 )edit

I tested and compare the output of the /diagnostics and /diagnostics_agg for turtlebot and the raw data in the diagnostic topic is more completed (all sensor information) also the name of sensors in the diagnostics_agg is a short name instead of full name. Anyway it depends on what you need. thanks

felipe.roman gravatar image felipe.roman  ( 2014-09-23 13:43:49 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2014-09-22 19:21:42 -0500

Seen: 160 times

Last updated: Sep 23 '14