0
$\begingroup$

Rosanswers logo

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


Originally posted by Kel Guerin on ROS Answers with karma: 61 on 2013-06-26

Post score: 2

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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]

Originally posted by lindzey with karma: 1780 on 2013-06-26

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Kel Guerin on 2013-06-27:
Thank you so much, I will try this out!!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.