0
$\begingroup$

Rosanswers logo

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


Originally posted by Patrickelectric on ROS Answers with karma: 1 on 2017-11-15

Post score: 0


Original comments

Comment by jayess on 2017-11-16:
Can you please update your question with the entire terminal output?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Ruben Alves with karma: 1038 on 2017-11-15

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Patrickelectric on 2017-11-16:
I do not have a ros:init and a node, check my launcher https://pastebin.com/mywwMrDY

Comment by Ruben Alves on 2017-11-20:
Then this is the problem, @Patrickelectric. You have to call ros::initon your freefloating_fluid plugin.

Comment by Patrickelectric on 2017-11-23:
But the plugin have it. https://github.com/freefloating-gazebo/freefloating_gazebo/blob/master/src/freefloating_pids_main.cpp

$\endgroup$

Your Answer

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