Ask Your Question
0

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

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

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 http://wiki.ros.org/ROS/Slave_API , 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
1

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

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

Comments

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 imagezcm ( 2018-03-15 05:55:33 -0600 )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

Stats

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

Seen: 383 times

Last updated: Mar 15 '18