ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
13

How to solve "Couldn't find an AF_INET address for " problem

asked 2014-05-10 14:55:19 -0600

skyhawk gravatar image

updated 2017-09-26 14:26:04 -0600

130s gravatar image

Hi, I am running four computers with only one the ROS master, and I am sure I set the correct ROS_MASTER_URI (=http://192.168.10.101:11311) to the other three computers. Then the problems like this: I run a node in the master computer, and also I publish some message to that node. In this master computer, I can use "rostopic echo" to see the published messages, but in another computer, if I run "rostopic list", I see all the topics, but if I run "rostopic echo /xxxx" then I cannot see anything. Most importantly, I see the master computer threw out a message saying Couldn't find an AF_INET address for [msl]. It is probably some network problem, so please help.

edit retag flag offensive close merge delete

9 Answers

Sort by » oldest newest most voted
30

answered 2014-07-30 14:25:05 -0600

mattc12345 gravatar image

skyhawk is right, set the ROS_IP for each computer. So for each computer, find the IP address in a terminal with

hostname -I

It will be the first set of numbers, like 10.0.0.25. To set it,

export ROS_IP=10.0.0.25

Make sure you're exporting the right address on each one, it'll be different for each computer.

edit flag offensive delete link more

Comments

This worked for me! Thanks

fabbro gravatar image fabbro  ( 2019-10-08 03:29:29 -0600 )edit

(as mentioned in posts below): In case this does not solve your problem edit /etc/hosts to contain the name for the rosnode. For example in there add 192.168.3.5 my_hostname

blubbi321 gravatar image blubbi321  ( 2020-05-22 04:40:33 -0600 )edit
7

answered 2014-05-10 15:37:35 -0600

skyhawk gravatar image

You should set the ROS_IP for each computer that is in the network running the ROS.

edit flag offensive delete link more
6

answered 2015-03-17 05:43:30 -0600

dim_sgou gravatar image

The only solution that worked for me was to list the ip address of each computer along with its hostname to the /etc/hosts file.

edit flag offensive delete link more

Comments

Thank you! In my case, having two ip address on the robot and two on the workstation, this was the only one working solution!

pulver gravatar image pulver  ( 2015-06-08 11:41:09 -0600 )edit

I also already had the suggested #1 solution implemented and this helped to get rid of the error

blubbi321 gravatar image blubbi321  ( 2020-05-22 04:38:35 -0600 )edit
5

answered 2014-09-04 02:42:09 -0600

Or just set on every computer in you network (so you don't have to thing about addresses):

export ROS_IP=`hostname -I`

Or even, sometimes better, solution is to add this line in your .bashrc file.

edit flag offensive delete link more

Comments

4

Be warned - this only works if your computer only has one IP address. If you have two addresses, perhaps ethernet and WiFi, hostname -I will show multiple addresses and your ROS_IP will probably be invalid.

ahendrix gravatar image ahendrix  ( 2014-09-04 02:57:53 -0600 )edit

@ahendrix In the case of multiple addresses, what address do have to set ROS_IP to? I set it to the one which used for communication between host and the ROS PC but it did not work.

cellard0or gravatar image cellard0or  ( 2016-08-03 09:45:12 -0600 )edit
1

@cellard0or : that approach should work, but you've given very little information. Please ask a new question with details about your setup and the errors you're encountering.

ahendrix gravatar image ahendrix  ( 2016-08-03 11:24:32 -0600 )edit
2

as current ubuntu revisions seem to report more than just the ip when calling hostname -I I used

machine_ip=(`hostname -I`)
export ROS_IP=${machine_ip[0]}
blubbi321 gravatar image blubbi321  ( 2017-11-01 09:15:03 -0600 )edit
2

answered 2016-09-11 03:12:04 -0600

TifferPelode gravatar image

I found a way, change your /etc/hosts Such as:

vim /etc/hosts

then add your ip:

192.168.3.5   my_hostname
edit flag offensive delete link more

Comments

This was the only thing that worked for me after adding ROS_IP

kotoko gravatar image kotoko  ( 2018-08-06 06:08:41 -0600 )edit
1

answered 2016-01-13 16:47:14 -0600

Farid gravatar image

I would say the best answer... worked 100% for my robot and local computers. have a look... http://www.umiacs.umd.edu/~cteo/umd-e...

edit flag offensive delete link more
1

answered 2015-11-19 12:30:46 -0600

charles.fox gravatar image

If this is coming from a gazebo plugin -- it may be because gazebo is beignn run standalone rather than launched from ros as required.

edit flag offensive delete link more
0

answered 2016-12-14 06:52:47 -0600

yucelokan gravatar image

MultipleMachines

I had same problem while ı am trying the upper link. I resolved, resolve is here.

open the .bashrc files and add this code.

You'll see those things like that:

export ROS_MASTER_URI=http://localhost (or something like that which is not your ip):11311
export ROS_HOSTNAME=(your machine name)

and you must change it like that:

export ROS_MASTER_URI=http://30.10.21.46:11311
export ROS_HOSTNAME=30.10.21.46

change your ip adress.

edit flag offensive delete link more
0

answered 2015-11-20 05:15:24 -0600

Deluxe Version for Bash with multiple interfaces

function set_rosip
{
  RED="$(tput setb 4)"
  GREEN="$(tput setaf 0)$(tput setb 2)"
  BOLD=$(tput bold)
  NOCOLOR=$(tput sgr0)

  {
  ifconfig $1
  } &> /dev/null


  if [ $? -ne 0 ]; then
    echo -e "${RED}Interface ${BOLD}$1${NOCOLOR}${RED} not found! ${BOLD}ROS_IP not set!${NOCOLOR}"
    return 1
  fi

  ip_addr=`ifconfig $1 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}'`

  if [ -z "$ip_addr" ]; then
    if [ "$3" == "1" ]; then
      echo -e "${RED}Interface ${BOLD}$1${NOCOLOR}${RED} not connected, ${BOLD}ROS_IP not set!${NOCOLOR}"
    fi
    return 1
  fi

  if [ "$2" == "1" ]; then
    echo ${GREEN}ROS_IP set to $1 with IP $ip_addr${NOCOLOR}
  fi


  export ROS_IP=$ip_addr
}
#Tries to get setup ROS_IP in the specified order and stops on the first success ... 
set_rosip wlan0 1 0 || set_rosip eth0 1 1 \
# ||  set_rosip ${anotherinterface} ${printonsuccess} ${printonfail}

If you want only be notified if the last one fails:

set_rosip wlan0 0 0 || set_rosip eth0 0 1
edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2014-05-10 14:55:19 -0600

Seen: 62,232 times

Last updated: Sep 26 '17