stuck in transport::init()
i was testing the example listener.cc according to the tutorials. I first ran gazebo and then ran listener. I found that the listener stuck at the function transport::init().
The output of listener is
Msg Waiting for master........
Msg Connected to gazebo master @ http://127.0.0.1:11345
Here is my code:
#include <transport/transport.hh>
#include <gazebo/msgs/msgs.hh>
#include <gazebo/gazebo.hh>
#include "transport/Node.hh"
#include "transport/Publisher.hh"
#include "transport/Subscriber.hh"
#include "transport/ConnectionManager.hh"
#include "transport/Transport.hh"
#include "msgs/msgs.hh"
#include "common/Events.hh"
#include "transport/TopicManager.hh"
#include "gazebo_config.h"
#include <iostream>
using namespace gazebo;
/////////////////////////////////////////////////
// Function is called everytime a message is received.
void cb(ConstWorldStatisticsPtr &_msg)
{
// Dump the message contents to stdout.
std::cout << _msg->DebugString();
}
/////////////////////////////////////////////////
int main(int _argc, char **_argv)
{
printf("transport init...\n");
std::string host = "localhost";
unsigned int port = 11345;
transport::TopicManager::Instance()->Init();
printf("topic manager init ok...\n");
//transport::ConnectionManager()::Instance()->stop = false;
if (!transport::ConnectionManager::Instance()->Init(host, port))
printf("return false\n");
printf("return true\n");
// Create our node for communication
gazebo::transport::NodePtr node(new gazebo::transport::Node());
node->Init();
// Listen to Gazebo world_stats topic
gazebo::transport::SubscriberPtr sub = node->Subscribe("~/world_stats", cb);
gazebo::transport::run();
// Busy wait loop...replace with your own code as needed.
while (true)
gazebo::common::Time::MSleep(10);
// Make sure to shut everything down.
gazebo::transport::fini();
}
And i found that it got stuck in the code
if (!transport::ConnectionManager::Instance()->Init(host, port))
printf("return false\n");
Can you help me? Thank you!