Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes a segfault during exit of SubT simulation #427

Merged
merged 1 commit into from
May 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions subt_ign/src/GameLogicPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <ignition/gazebo/components/World.hh>
#include <ignition/gazebo/Conversions.hh>
#include <ignition/gazebo/EntityComponentManager.hh>
#include <ignition/gazebo/Events.hh>
#include <ignition/gazebo/Util.hh>

#include <ignition/common/Console.hh>
Expand Down Expand Up @@ -292,6 +293,9 @@ class subt::GameLogicPluginPrivate
{subt::ArtifactType::TYPE_VENT,
ignition::math::Vector3d(0, 0, 0.138369)}
};

/// \brief Event manager for pausing simulation
public: EventManager *eventManager;
};

//////////////////////////////////////////////////
Expand All @@ -313,8 +317,10 @@ GameLogicPlugin::~GameLogicPlugin()
void GameLogicPlugin::Configure(const ignition::gazebo::Entity & /*_entity*/,
const std::shared_ptr<const sdf::Element> &_sdf,
ignition::gazebo::EntityComponentManager & /*_ecm*/,
ignition::gazebo::EventManager & /*_eventMgr*/)
ignition::gazebo::EventManager & _eventMgr)
{
this->dataPtr->eventManager = &_eventMgr;

// Check if the game logic plugin has a <logging> element.
// The <logging> element can contain a <filename_prefix> child element.
// The <filename_prefix> is used to specify the log filename prefix. For
Expand Down Expand Up @@ -967,11 +973,7 @@ void GameLogicPluginPrivate::Finish()
{
// Pause simulation when finished. Always send this request, just to be
// safe.
ignition::msgs::WorldControl req;
req.set_pause(true);
this->node.Request<ignition::msgs::WorldControl, ignition::msgs::Boolean>(
std::string("/world/") + this->worldName + "/control", req,
[](const ignition::msgs::Boolean &, const bool) { });
this->eventManager->Emit<events::Pause>(true);

if (this->finished)
return;
Expand Down