Skip to content

Commit

Permalink
Deprecations in favor of sdf::Plugin (#1631)
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina committed Aug 5, 2022
1 parent f8733fa commit ba879d3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 17 deletions.
9 changes: 4 additions & 5 deletions include/gz/sim/Events.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,15 @@ namespace gz
using Stop = gz::common::EventT<void(void), struct StopTag>;

/// \brief Please use the LoadSdfPlugins event. The LoadPlugins event
/// will be deprecrated in Gazebo 7 (Garden). Also make sure to
/// is deprecrated in Gazebo 7 (Garden). Also make sure to
/// connect to only LoadSdfPlugins or LoadPlugins, and not both events.
///
/// Event used to load plugins for an entity into simulation.
/// Pass in the entity which will own the plugins, and an SDF element for
/// the entity, which may contain multiple `<plugin>` tags.
/// \note This will be deprecated in Gazebo 7 (Garden), please the use
/// sdf::Plugin interface.
using LoadPlugins = common::EventT<void(Entity, sdf::ElementPtr),
struct LoadPluginsTag>;
/// \deprecated Use the `sdf::Plugins` interface.
using LoadPlugins GZ_DEPRECATED(7) =
common::EventT<void(Entity, sdf::ElementPtr), struct LoadPluginsTag>;

/// \brief Event used to load plugins for an entity into simulation.
/// Pass in the entity which will own the plugins, and an SDF element for
Expand Down
4 changes: 3 additions & 1 deletion src/LevelManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,11 @@ void LevelManager::ReadLevelPerformerInfo()
// Load world plugins.
this->runner->EventMgr().Emit<events::LoadSdfPlugins>(this->worldEntity,
this->runner->sdfWorld->Plugins());
// Deprecate this in Garden

GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
this->runner->EventMgr().Emit<events::LoadPlugins>(this->worldEntity,
this->runner->sdfWorld->Element());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION

// Store the world's SDF DOM to be used when saving the world to file
this->runner->entityCompMgr.CreateComponent(
Expand Down
10 changes: 10 additions & 0 deletions src/SdfEntityCreator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ Entity SdfEntityCreator::CreateEntities(const sdf::World *_world)
_world->Plugins());
for (const sdf::Plugin &p : _world->Plugins())
{
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
this->dataPtr->eventManager->Emit<events::LoadPlugins>(worldEntity,
p.ToElement());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
}

// Store the world's SDF DOM to be used when saving the world to file
Expand All @@ -352,8 +354,10 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Model *_model)
this->dataPtr->eventManager->Emit<events::LoadSdfPlugins>(entity, plugins);
for (const sdf::Plugin &p : plugins)
{
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
this->dataPtr->eventManager->Emit<events::LoadPlugins>(entity,
p.ToElement());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
}
}
this->dataPtr->newModels.clear();
Expand All @@ -364,8 +368,10 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Model *_model)
this->dataPtr->eventManager->Emit<events::LoadSdfPlugins>(entity, plugins);
for (const sdf::Plugin &p : plugins)
{
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
this->dataPtr->eventManager->Emit<events::LoadPlugins>(entity,
p.ToElement());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
}
}
this->dataPtr->newSensors.clear();
Expand All @@ -376,8 +382,10 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Model *_model)
this->dataPtr->eventManager->Emit<events::LoadSdfPlugins>(entity, plugins);
for (const sdf::Plugin &p : plugins)
{
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
this->dataPtr->eventManager->Emit<events::LoadPlugins>(entity,
p.ToElement());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
}
}
this->dataPtr->newVisuals.clear();
Expand Down Expand Up @@ -514,8 +522,10 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Actor *_actor)
_actor->Plugins());
for (const sdf::Plugin &p : _actor->Plugins())
{
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
this->dataPtr->eventManager->Emit<events::LoadPlugins>(actorEntity,
p.ToElement());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
}

return actorEntity;
Expand Down
8 changes: 4 additions & 4 deletions src/Server_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ TEST_P(ServerFixture, GZ_UTILS_TEST_DISABLED_ON_WIN32(RunOnceUnpaused))
sim::SystemLoader systemLoader;
sdf::Plugin sdfPlugin;
sdfPlugin.SetName("gz::sim::MockSystem");
sdfPlugin.SetFilename("libMockSystem.so");
sdfPlugin.SetFilename("MockSystem");
auto mockSystemPlugin = systemLoader.LoadPlugin(sdfPlugin);
ASSERT_TRUE(mockSystemPlugin.has_value());

Expand Down Expand Up @@ -671,7 +671,7 @@ TEST_P(ServerFixture, GZ_UTILS_TEST_DISABLED_ON_WIN32(RunOncePaused))
sim::SystemLoader systemLoader;
sdf::Plugin sdfPlugin;
sdfPlugin.SetName("gz::sim::MockSystem");
sdfPlugin.SetFilename("libMockSystem.so");
sdfPlugin.SetFilename("MockSystem");
auto mockSystemPlugin = systemLoader.LoadPlugin(sdfPlugin);
ASSERT_TRUE(mockSystemPlugin.has_value());

Expand Down Expand Up @@ -836,7 +836,7 @@ TEST_P(ServerFixture, GZ_UTILS_TEST_DISABLED_ON_WIN32(AddSystemWhileRunning))
sim::SystemLoader systemLoader;
sdf::Plugin sdfPlugin;
sdfPlugin.SetName("gz::sim::MockSystem");
sdfPlugin.SetFilename("libMockSystem.so");
sdfPlugin.SetFilename("MockSystem");
auto mockSystemPlugin = systemLoader.LoadPlugin(sdfPlugin);
ASSERT_TRUE(mockSystemPlugin.has_value());

Expand Down Expand Up @@ -875,7 +875,7 @@ TEST_P(ServerFixture, GZ_UTILS_TEST_DISABLED_ON_WIN32(AddSystemAfterLoad))
sim::SystemLoader systemLoader;
sdf::Plugin sdfPlugin;
sdfPlugin.SetName("gz::sim::MockSystem");
sdfPlugin.SetFilename("libMockSystem.so");
sdfPlugin.SetFilename("MockSystem");
auto mockSystemPlugin = systemLoader.LoadPlugin(sdfPlugin);
ASSERT_TRUE(mockSystemPlugin.has_value());

Expand Down
2 changes: 1 addition & 1 deletion test/integration/battery_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BatteryPluginTest : public InternalFixture<::testing::Test>

sdf::Plugin sdfPlugin;
sdfPlugin.SetName("gz::sim::MockSystem");
sdfPlugin.SetFilename("libMockSystem.so");
sdfPlugin.SetFilename("MockSystem");
auto plugin = sm.LoadPlugin(sdfPlugin);
EXPECT_TRUE(plugin.has_value());
this->systemPtr = plugin.value();
Expand Down
7 changes: 4 additions & 3 deletions test/integration/reset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ class ResetFixture: public InternalFixture<::testing::Test>
{
InternalFixture::SetUp();

auto plugin = sm.LoadPlugin("libMockSystem.so",
"gz::sim::MockSystem",
nullptr);
sdf::Plugin sdfPlugin;
sdfPlugin.SetName("gz::sim::MockSystem");
sdfPlugin.SetFilename("MockSystem");
auto plugin = sm.LoadPlugin(sdfPlugin);
EXPECT_TRUE(plugin.has_value());
this->systemPtr = plugin.value();
this->mockSystem = static_cast<sim::MockSystem *>(
Expand Down
7 changes: 4 additions & 3 deletions test/integration/sensors_system_battery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ class SensorsFixture : public InternalFixture<InternalFixture<::testing::Test>>
{
InternalFixture::SetUp();

auto plugin = sm.LoadPlugin("libMockSystem.so",
"gz::sim::MockSystem",
nullptr);
sdf::Plugin sdfPlugin;
sdfPlugin.SetName("gz::sim::MockSystem");
sdfPlugin.SetFilename("MockSystem");
auto plugin = sm.LoadPlugin(sdfPlugin);
EXPECT_TRUE(plugin.has_value());
this->systemPtr = plugin.value();
this->mockSystem = static_cast<sim::MockSystem *>(
Expand Down

0 comments on commit ba879d3

Please sign in to comment.