ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Hello,
If your target is Linux based, you can use avahi-daemon
on it to advertise it on the network as <hostname>.local
by default (this can be modified by configuring the daemon). On the client side, you can then identify the target by its host name.
If you need the IP, the command avahi-browse -artp | grep <hostname>.local
will output records providing details about the Avahi services published by the target, including one containing the IP. It is pretty easy to select and parse it thanks to cut
and alike.
An alternative to the grep approach is to publish a service on the target side using avahi-publish
. On the client side you can then use avahi-browse -t <servicename> -p
which will limit the output records to the relevant ones.
This solution is independent from ROS and can be exploited in startup scripts, both on target an client sides. I've used it with success in a lot of various situations involving headless Linux based black boxes, including Raspberry ones.
Hope this helps
Regards, Eric