Automatically set the ROS MASTER ip within another machine belonging to the same network

asked 2018-07-22 22:37:38 -0500

moucrob gravatar image

updated 2018-07-23 04:28:40 -0500

gvdhoorn gravatar image


I have one work station, connected in DHCP IPv4 to an internet-providing router. This router provides to each of its plugged computers a different ip address, that changes (let's say) everyday.

So, from the workstation, I know how to automatically detect this changed ip and set it as the ROS MASTER one (in adding :11311)

My issue then is that I would want, from another laptop, connected to the same network/routeur, also in DHCP IPv4, but then receiving another allocated changing ip, to automatically (in the bashrc) know which address (of the workstation) write after the line $ export ROS_MASTER_URI = http://<what is the IP of the workstation?> ...

There are hundreds to thousands other computers on the network, so since I don't know much about linux commands, I would basically think about doing something like that :

  • workstation owns an access password, and assuming I write some command line / launch some .sh, "raises its hand" to say to the whole network temporarily << hey It's me I'm here >>

  • I write/launch then another thing through the other laptop, to try connecting to the only one device which stands out among those connected to the network

  • workstation asks for the password

  • laptop replies with some attempt

  • if the attempt is a success, then the workstation stands back in the list of all the connected devices, hence not anymore reachable by any candidate.

Does it already exist some similar ways of pairing machines that you ROS community members use? If you don't know, would you have some recipe/URLs toward some pages to explore?

By thanking you in advance.

edit retag flag offensive close merge delete


Most routers allow a device identified by its MAC address to be given a fixed IP. If you can do this instead it would be a far easier solution. It's what we do in our lab in this situation.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-07-23 02:51:23 -0500 )edit

What the OP describes is exactly why hostnames were introduced: IPs may change, but hostnames can stay the same. Instead of specifying an IP in ROST_MASTER_URI, use a hostname and a DNS server resolves that to the current IP.

However, that will require the availability of a DNS server.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-23 04:30:15 -0500 )edit

Have you tried using a broadcast? you would need a listener on the new laptop to see when the workstation changes the IP and set the new master

rdelgadov gravatar image rdelgadov  ( 2018-07-25 23:56:49 -0500 )edit