Ask Your Question
1

what the ROS_IP for?

asked 2016-01-28 01:26:35 -0500

kevin.kuei.0321@gmail.com gravatar image

updated 2019-06-25 19:22:35 -0500

130s gravatar image

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??

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-06-25 22:24:23 -0500

ahendrix gravatar image

updated 2019-06-26 14:26:59 -0500

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-conten... , https://vimeo.com/67806888

edit flag offensive delete link more

Comments

For android_phone, isn't ROS_IP supposed to be 192.168.25.113 instead of 192.168.25.112?

130s gravatar image130s ( 2019-06-26 07:14:48 -0500 )edit

Thank you!

kevin.kuei.0321@gmail.com gravatar imagekevin.kuei.0321@gmail.com ( 2019-06-26 08:43:24 -0500 )edit

Ooops; yes. The ROS_IP for android_phone should be 192.168.25.113.

ahendrix gravatar imageahendrix ( 2019-06-26 14:27:37 -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

2 followers

Stats

Asked: 2016-01-28 01:26:35 -0500

Seen: 430 times

Last updated: Jun 26