Skip to content

Commit

Permalink
Fix loading worlds from CLI (#1627)
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <louise@openrobotics.org>
  • Loading branch information
chapulina authored Aug 4, 2022
1 parent 2edbf56 commit 1cf75f3
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/gui/Gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,30 @@ std::unique_ptr<ignition::gui::Application> createGui(
{
std::string configInUse = configFromCli ? _guiConfig : defaultConfig;
startingWorld = launchQuickStart(_argc, _argv, defaultConfig, configInUse);
}
else if (hasSdfFile)
{
startingWorld = _sdfFile;
}

if (sigKilled)
{
igndbg << "Received kill signal. Not starting main window." << std::endl;
return nullptr;
}

// Publish starting world even if it's empty. The server is blocking waiting
// for it.
if (_waitGui)
{
std::string topic{"/gazebo/starting_world"};
auto startingWorldPub = node.Advertise<msgs::StringMsg>(topic);
msgs::StringMsg msg;
msg.set_data(startingWorld);

// Wait for the server to be listening, so we're sure it receives the
// message.
igndbg << "Waiting for subscribers to [" << topic << "]..." << std::endl;
for (int sleep = 0; sleep < 100 && !startingWorldPub.HasConnections();
++sleep)
{
Expand All @@ -237,16 +255,6 @@ std::unique_ptr<ignition::gui::Application> createGui(
}
startingWorldPub.Publish(msg);
}
else if (hasSdfFile)
{
startingWorld = _sdfFile;
}

if (sigKilled)
{
igndbg << "Received kill signal. Not starting main window." << std::endl;
return nullptr;
}

// Launch main window
auto app = std::make_unique<ignition::gui::Application>(
Expand Down

0 comments on commit 1cf75f3

Please sign in to comment.