0
$\begingroup$

Rosanswers logo

Hi,

Can anybody explain what the ROS_IP environment variable is for? I've read the "ROS/NetworkSetup" wiki, but didn't get the clear answer.

Here is my environment:

  • Hostname, IP address
  • robot, 192.168.25.80
  • pc, 192.168.25.112
  • android_phone, 192.168.25.113

my pc & android_phone can't resolve the hostname "robot". So, I specify the ROS_MASTER_URI=http://192.168.25.80

I want to run rviz to show the map in the robot. Also, I want to run "android_core" API to access the map in the app in android phone.

I know that I HAVE TO have the envirnment variable ROS_IP = 192.168.25.80

But, can anybody tell me why??

The strange thing is, if I didn't setup the ROS_IP environment variable, slaves still can send messages to /cmd_vel. But the slaves won't be able to retrieve the /map

If the robot has multiple network interfaces, things will be more difficulty. for example:

robot has two interfaces:

  • wlan0 192.168.25.80/24
  • usb0 192.168.10.10/24

Due to network reachability issue, some of the slaves have to access to 192.168.25.80, and others have to access to 192.168.10.10 In this case, what IP should be filled in ROS_IP in the robot??


Originally posted by [email protected] on ROS Answers with karma: 159 on 2016-01-28

Post score: 3

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

ROS nodes exchange topic and service data peer-to-peer; this means that all nodes need to be able to communicate over the network with all other nodes. Each node has a URI that it sends to the ROS master, along with its list of topics and services. When other nodes want to use a topic or service, they ask the ROS master for the URIs of the nodes on those topics, and the ROS master gives them those URIs. The other nodes then use the node's URI to establish topic and service connections.

By default, a node creates its URI from the hostname of the computer that it is running on. Setting ROS_IP overrides this, and causes the node to use the specified IP address when advertising itself. (ROS_HOSTNAME can also be used to override the hostname)

The ROS_IP should be set to the IP address of the computer that the ROS node is running on. If you want your node to be reachable on several different networks, you can either set up routing so that the node's IP is reachable from all networks, or set up DNS, hosts files, or some other mechanism for resolving hostnames to IP addresses. This way, hosts on one network will resolve one IP address for the node, and hosts on the other network will resolve the other IP address for the node.

For your specific environment, the correct settings (per-host) are:

  • robot, 192.168.25.80
    • ROS_IP=192.168.25.80
    • ROS_MASTER_URI=http://192.168.25.80:11311/
  • pc, 192.168.25.112
    • ROS_IP=192.168.25.112
    • ROS_MASTER_URI=http://192.168.25.80:11311/
  • android_phone, 192.168.25.113
    • ROS_IP=192.168.25.113
    • ROS_MASTER_URI=http://192.168.25.80:11311/

I gave a talk at ROSCon 2013 which goes into the full details of the topic setup process, and why topics can work in one direction but not another between hosts on a network: https://roscon.ros.org/2013/wp-content/uploads/2013/06/Networking-for-ROS-Users.pdf , https://vimeo.com/67806888


Originally posted by ahendrix with karma: 47576 on 2019-06-25

This answer was ACCEPTED on the original site

Post score: 6


Original comments

Comment by 130s on 2019-06-26:
For android_phone, isn't ROS_IP supposed to be 192.168.25.113 instead of 192.168.25.112?

Comment by [email protected] on 2019-06-26:
Thank you!

Comment by ahendrix on 2019-06-26:
Ooops; yes. The ROS_IP for android_phone should be 192.168.25.113.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.