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

Couldn't find an AF_INET address for []

asked 2017-11-15 05:53:36 -0500

Patrickelectric gravatar image

I have ROS lunar from source running in notebook, while running any simulation with gazebo 8 I have this error message:

SpawnModel script started
SpawnModel script started
[ INFO] [1510746273.283898971]: Loading freefloating_fluid plugin
[FATAL] [1510746273.284096302]: You must call ros::init() before creating the first NodeHandle
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []
[ERROR] [1510746273.287385416]: [registerPublisher] Failed to contact master at [:0].  Retrying...
[INFO] [1510746273.304076, 0.000000]: Loading model XML from ros parameter
[INFO] [1510746273.309921, 0.000000]: Waiting for service /gazebo/spawn_urdf_model
[INFO] [1510746273.330882, 0.000000]: Loading model XML from ros parameter
[INFO] [1510746273.333284, 0.000000]: Waiting for service /gazebo/spawn_sdf_model
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []

Any idea of how to solve it or how to debug it ?

I have /etc/hosts configured. And my env ros env are: export ROS_MASTER_URI=http://localhost:11311;export ROS_HOSTNAME=localhost

edit retag flag offensive close merge delete

Comments

Can you please update your question with the entire terminal output?

jayess gravatar image jayess  ( 2017-11-16 13:25:52 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2017-11-15 10:59:53 -0500

updated 2017-11-15 11:00:51 -0500

Hi @Patrickelectric ,

that happens because you have to call ros::init() BEFORE the instantiation of your ros::NodeHandle.

As an example, If you compile the code below (from Writing a Simple Publisher and Subscriber tutorial ), as is, it will work because ros::init is being called first. But if you uncomment the nodeBeforeRosInitWillFail node, you will see that this error happens since ros::init is called AFTER nodeBeforeRosInitWillFail.

#include "ros/ros.h"
#include "std_msgs/String.h"

#include <sstream>

int main(int argc, char **argv)
{

  /**
   * Definining a ros::NodeHandle before ros::init causes the error
   * To confirm that, just uncomment the  nodeBeforeRosInitWillFail node below
   */
  //ros::NodeHandle nodeBeforeRosInitWillFail;

  ros::init(argc, argv, "talker");

  ros::NodeHandle n;

  ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);

  ros::Rate loop_rate(10);

  int count = 0;
  while (ros::ok())
  {

    std_msgs::String msg;

    std::stringstream ss;
    ss << "hello world " << count;
    msg.data = ss.str();

    ROS_INFO("%s", msg.data.c_str());

    chatter_pub.publish(msg);

    ros::spinOnce();

    loop_rate.sleep();
    ++count;
  }
  return 0;
}

You can see this example in the following video ( https://youtu.be/UsuQwUkzNII ) if you prefer.

edit flag offensive delete link more

Comments

I do not have a ros:init and a node, check my launcher https://pastebin.com/mywwMrDY

Patrickelectric gravatar image Patrickelectric  ( 2017-11-16 12:05:48 -0500 )edit

Then this is the problem, @Patrickelectric. You have to call ros::initon your freefloating_fluid plugin.

Ruben Alves gravatar image Ruben Alves  ( 2017-11-20 05:50:04 -0500 )edit
Patrickelectric gravatar image Patrickelectric  ( 2017-11-23 16:32:27 -0500 )edit
0

answered 2017-11-15 10:09:35 -0500

jayess gravatar image

updated 2017-11-15 11:04:19 -0500

Like the error tells you,

[FATAL] [1510746273.284096302]: You must call ros::init() before creating the first NodeHandle

you need to call ros::init() before creating your first NodeHandle otherwise you'll get the error that you saw.

edit flag offensive delete link more

Comments

That's not possible.. Check my launcher.. https://pastebin.com/mywwMrDY

Patrickelectric gravatar image Patrickelectric  ( 2017-11-16 12:05:14 -0500 )edit

@Patrickelectric please update your question with this information. If (and when) the pastebin goes away then future users won't have this information.

jayess gravatar image jayess  ( 2017-11-16 12:34:11 -0500 )edit
0

answered 2017-11-15 09:13:37 -0500

bpinaya gravatar image

Hi there! Be sure of also configuring your IPs in the .bashrc with:

export ROS_IP=192.168.1.206

and in that IP put the one on your machine.

edit flag offensive delete link more

Comments

You only set one or the other:

The options are mutually exclusive, if both are set ROS_HOSTNAME will take precedence

from http://wiki.ros.org/ROS/EnvironmentVa... .

jayess gravatar image jayess  ( 2017-11-15 09:33:01 -0500 )edit

I can set ROS_IP, but the problem continue.. This can be related to gazebo 8 ? The problem do not appear in ubuntu 16.04 using packages from apt and running gazebo 7.

Patrickelectric gravatar image Patrickelectric  ( 2017-11-15 10:05:06 -0500 )edit

@Patrickelectric: Like I said, you only set one: either ROS_HOSTNAME or ROS_IP, not both.

jayess gravatar image jayess  ( 2017-11-15 10:08:13 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-11-15 05:53:36 -0500

Seen: 5,688 times

Last updated: Nov 15 '17