gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.15k stars 478 forks source link

The compilation passed, and the code could not run. It was stuck in the while loop of a function. #3240

Open xwq112132 opened 1 year ago

xwq112132 commented 1 year ago

I have compiled the source code, but the runtime is stuck in the loop of a function.

This function is : bool transport::waitForNamespaces(const gazebo::common::Time &_maxWait); And this function is defined in this file: gazebo-gazebo11/gazebo/transport/TransportIface.cc

In addition, I have also started the gzserver program. Who can help me make gazebo really work?

` bool transport::waitForNamespaces(const gazebo::common::Time &_maxWait) { // If the ConnectionManager has not been initialized, then there is no point // in waiting for namespaces. if (!ConnectionManager::Instance()->IsInitialized()) { gzerr << "ConnectionManager has not been initialized!\n"; return false; }

std::list<std::string> namespaces;
gazebo::common::Time startTime = gazebo::common::Time::GetWallTime();

gazebo::common::Time waitTime = std::min(
            gazebo::common::Time(0, 100000000), _maxWait / 10);

gazebo::transport::TopicManager::Instance()->GetTopicNamespaces(
            namespaces);

while (namespaces.empty() &&
       gazebo::common::Time::GetWallTime() - startTime < _maxWait)
{
    gazebo::transport::TopicManager::Instance()->GetTopicNamespaces(
                namespaces);
    gazebo::common::Time::Sleep(waitTime);
}

return !namespaces.empty();

}`

xwq112132 commented 1 year ago

I can't get out of here all the time: while (namespaces.empty() && gazebo::common::Time::GetWallTime() - startTime < _maxWait)

xwq112132 commented 1 year ago

My problem has been solved. After compiling with qtcreator, I found a setup in the makefile directory SH's shell script, I tried to execute it but failed, and then I tried to execute it: sudo make install, then punch in gzclient and it succeeded, although I don't know why..

First punch in gzserver, and then execute gzclient with qtcreator, so you can debug captrue .