Ask Your Question

How to find if nodes are running on the same machine?

asked 2018-03-15 04:43:52 -0500

zcm gravatar image

Hello, everyone! I see ROS is a real distributed system, all nodes use node_name and node_uri to identify itself. Now I need to write a monitor process, to monitor all nodes on the same machine.

From , I can use getPid( ) to get the PID of that node server. But how can I check if that node is running on the same machine ? Is there a standard way of doing this ? Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-03-15 05:09:01 -0500

gvdhoorn gravatar image

rosnode machine will list the machines (ie: hosts) that the master knows about, and rosnode machine <hostname> will list all nodes that run on a particular machine (ie: hostname).

As for how to do this with the Master API, take a look at how rosnode does this internally, specifically the get_machines_by_nodes() and get_nodes_by_machine() methods (here).

If you're going to be using this often, consider that these methods incur quite some overhead:

This is a very costly procedure as it must do N lookups with the Master, where N is the number of nodes.

edit flag offensive delete link more


Thanks! I think Master get this hostname from every node's node_uri, if the hostname is unique for each machine, and each machine only use one hostname, then I think this approach is correct.

zcm gravatar image zcm  ( 2018-03-15 05:55:33 -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

1 follower


Asked: 2018-03-15 04:43:52 -0500

Seen: 948 times

Last updated: Mar 15 '18