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

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

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

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
1

answered 2016-11-04 11:04:12 -0500

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

Comments

Alternatively, you could use the Master API directly.

gvdhoorn gravatar image gvdhoorn  ( 2016-11-05 07:10:04 -0500 )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 -0500 )edit
0

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

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

jayess gravatar image

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

rospy.get_node_uri()
edit flag offensive delete link more

Comments

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 -0500 )edit

Question Tools

1 follower

Stats

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

Seen: 1,510 times

Last updated: Mar 12 '20