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

rosnode name of connected publishers (rospy)

asked 2013-06-26 12:47:18 -0500

Kel Guerin gravatar image

Hello,

I have a rospy Subscriber which is connected to several publishers, and I would like to retrieve a list of the names of the rosnodes that are connected as publishers to that subscriber, via a rospy interface. I have looked at the Subscriber.impl API and I thought that maybe it was in impl.connections or impl.get_stats, but connections gives you the address (I think) of the connected nodes... something like

[<rospy.impl.tcpros_base.TCPROSTransport object at 0x17e3450>, ...]

Thanks for the help!

Cheers, Kel

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-06-26 14:34:42 -0500

lindzey gravatar image

updated 2013-06-26 15:10:42 -0500

I'm not sure if this is exactly what you're going for, but you can check where each message came from:

def callback(data):
    print data._connection_header['callerid']

For more information, see Section 2.1 here.

Edit:

This information is available if you're willing to interact directly with the rosmaster. I sure hope somebody comes along with a better way to do this! (Building on the example here):

import os
import xmlrpclib
caller_id = '/script'
m = xmlrpclib.ServerProxy(os.environ['ROS_MASTER_URI'])
code, msg, val = m.getSystemState(caller_id)
topic = '/chatter'
if code == 1:
    pubs, subs, srvs = val
    pub_names = [elem[1] for elem in pubs if elem[0] == topic]
edit flag offensive delete link more

Comments

Thank you so much, I will try this out!!

Kel Guerin gravatar image Kel Guerin  ( 2013-06-27 05:45:10 -0500 )edit

Question Tools

Stats

Asked: 2013-06-26 12:47:18 -0500

Seen: 183 times

Last updated: Jun 26 '13