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

How to get the URI of a ROS node in Python?

asked 2016-11-04 09:58:38 -0600

I'm trying to find machines that publish a certain type of message. Therefore I'm inspecting the list of rosnodes rosnode.rosnode_listnodes() and would like to get the IP address of the corresponding machines running a specific node.

There is a method rosnode.lookup_uri(...), but I have no idea how to use it. I also looked into the rospy, rosgraph, names and network modules - so far without success. Among other information,rosnode.rosnode_info(node_name) prints the URI. But it might be a rather expensive method and, unfortunately, it returns None.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-11-04 11:04:12 -0600

huanxiner gravatar image
>>> import rosgraph
>>> master = rosgraph.Master('/mynode')
>>> master.lookupNode("node_name')

This worked for me, but not sure if it's safe to deal with ros master directly this way.

edit flag offensive delete link more


Alternatively, you could use the Master API directly.

gvdhoorn gravatar image gvdhoorn  ( 2016-11-05 07:10:04 -0600 )edit

Great, thanks! Apparently, you can even get the master via rosgraph.Master(''). It's definitely the answer I was looking for. :)

Falko gravatar image Falko  ( 2016-11-07 03:08:20 -0600 )edit

answered 2020-03-12 08:03:43 -0600

updated 2020-03-12 18:06:14 -0600

jayess gravatar image

If you are looking into this 4 years later then this seems to work well:

edit flag offensive delete link more


There are plenty of ways to get the IP of the current node. But the question was how to find the IP for another node publishing a certain message.

Falko gravatar image Falko  ( 2020-03-13 03:06:20 -0600 )edit

Question Tools

1 follower


Asked: 2016-11-04 09:58:38 -0600

Seen: 1,477 times

Last updated: Mar 12 '20