Skip to content

Commit

Permalink
Deprecations, ign -> gz (#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 ed5cd0b
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 48 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
6 changes: 3 additions & 3 deletions include/gz/sim/ServerConfig.hh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ namespace gz
/// \brief Get the plugin library filename.
/// \return Plugin library filename.
/// \deprecated Use `sdf::Plugin` interface.
public: const std::string & GZ_DEPRECATED(7) Filename() const;
public: const std::string GZ_DEPRECATED(7) & Filename() const;

/// \brief Set the type of the entity which should receive this
/// plugin. The type is used in conjuction with EntityName to
Expand All @@ -155,7 +155,7 @@ namespace gz
/// to load.
/// \return Interface name.
/// \deprecated Use `sdf::Plugin` interface.
public: const std::string & GZ_DEPRECATED(7) Name() const;
public: const std::string GZ_DEPRECATED(7) & Name() const;

/// \brief Set the name of the interface within the plugin library
/// to load.
Expand All @@ -166,7 +166,7 @@ namespace gz
/// \brief Plugin XML elements associated with this plugin.
/// \return SDF pointer.
/// \deprecated Use `sdf::Plugin` interface.
public: const sdf::ElementPtr & GZ_DEPRECATED(7) Sdf() const;
public: const sdf::ElementPtr GZ_DEPRECATED(7) & Sdf() const;

/// \brief Set the plugin XML elements associated with this plugin.
/// \param[in] _sdf SDF pointer, it will be cloned.
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
24 changes: 3 additions & 21 deletions src/ServerConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ class gz::sim::ServerConfig::PluginInfoPrivate
const std::unique_ptr<ServerConfig::PluginInfoPrivate> &_info)
: entityName(_info->entityName),
entityType(_info->entityType),
plugin(_info->plugin),
filename(_info->filename),
name(_info->name)
plugin(_info->plugin)
{
this->sdf = plugin.Element();
}
Expand All @@ -66,8 +64,6 @@ class gz::sim::ServerConfig::PluginInfoPrivate
: entityName(std::move(_entityName)),
entityType(std::move(_entityType)),
plugin(std::move(_plugin)),
filename(plugin.Filename()),
name(plugin.Name()),
sdf(plugin.Element())
{
}
Expand All @@ -81,14 +77,6 @@ class gz::sim::ServerConfig::PluginInfoPrivate
/// \brief SDF plugin information.
public: sdf::Plugin plugin;

/// \brief _filename The plugin library.
// Remove this in Garden, and rely solely on the plugin variable.
// Requires: https://github.com/gazebosim/sdformat/pull/1055
public: std::string filename = "";

/// \brief Name of the plugin implementation.
public: std::string name = "";

/// \brief XML elements associated with this plugin
public: sdf::ElementPtr sdf = nullptr;
};
Expand Down Expand Up @@ -117,8 +105,6 @@ ServerConfig::PluginInfo::PluginInfo(const std::string &_entityName,
}
this->dataPtr->plugin.SetName(_name);
this->dataPtr->plugin.SetFilename(_filename);
this->dataPtr->filename = _filename;
this->dataPtr->name = _name;
this->dataPtr->entityName = _entityName;
this->dataPtr->entityType = _entityType;
}
Expand Down Expand Up @@ -174,27 +160,25 @@ void ServerConfig::PluginInfo::SetEntityType(const std::string &_entityType)
//////////////////////////////////////////////////
const std::string &ServerConfig::PluginInfo::Filename() const
{
return this->dataPtr->filename;
return this->dataPtr->plugin.Filename();
}

//////////////////////////////////////////////////
void ServerConfig::PluginInfo::SetFilename(const std::string &_filename)
{
this->dataPtr->plugin.SetFilename(_filename);
this->dataPtr->filename = _filename;
}

//////////////////////////////////////////////////
const std::string &ServerConfig::PluginInfo::Name() const
{
return this->dataPtr->name;
return this->dataPtr->plugin.Name();
}

//////////////////////////////////////////////////
void ServerConfig::PluginInfo::SetName(const std::string &_name)
{
this->dataPtr->plugin.SetName(_name);
this->dataPtr->name = _name;
}

//////////////////////////////////////////////////
Expand Down Expand Up @@ -231,8 +215,6 @@ sdf::Plugin &ServerConfig::PluginInfo::Plugin()
void ServerConfig::PluginInfo::SetPlugin(const sdf::Plugin &_plugin) const
{
this->dataPtr->plugin = _plugin;
this->dataPtr->filename = _plugin.Filename();
this->dataPtr->name = _plugin.Name();
}

/// \brief Private data for ServerConfig.
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
2 changes: 1 addition & 1 deletion test/integration/scene_broadcaster_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ TEST_P(SceneBroadcasterTest,
// Start server
gz::sim::ServerConfig serverConfig;
serverConfig.SetSdfFile(std::string(PROJECT_SOURCE_PATH) +
common::joinPaths("/", "test", "worlds", "particle_emitter2.sdf"));
common::joinPaths("/", "test", "worlds", "particle_emitter.sdf"));

sim::Server server(serverConfig);
EXPECT_FALSE(server.Running());
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
4 changes: 2 additions & 2 deletions test/worlds/diff_drive_no_plugin.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<real_time_factor>0</real_time_factor>
</physics>
<plugin
filename="ignition-gazebo-physics-system"
name="ignition::gazebo::systems::Physics">
filename="gz-sim-physics-system"
name="gz::sim::systems::Physics">
</plugin>

<light type="directional" name="sun">
Expand Down
4 changes: 4 additions & 0 deletions test/worlds/particle_emitter.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
filename="gz-sim-particle-emitter-system"
name="gz::sim::systems::ParticleEmitter">
</plugin>
<plugin
filename="ignition-gazebo-scene-broadcaster-system"
name="ignition::gazebo::systems::SceneBroadcaster">
</plugin>

<light type="directional" name="sun">
<cast_shadows>true</cast_shadows>
Expand Down
8 changes: 4 additions & 4 deletions test/worlds/reset_detachable_joint.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<sdf version="1.9">
<world name="default">
<plugin
filename="ignition-gazebo-physics-system"
name="ignition::gazebo::systems::Physics">
filename="gz-sim-physics-system"
name="gz::sim::systems::Physics">
</plugin>
<plugin
filename="ignition-gazebo-scene-broadcaster-system"
name="ignition::gazebo::systems::SceneBroadcaster">
filename="gz-sim-scene-broadcaster-system"
name="gz::sim::systems::SceneBroadcaster">
</plugin>

<light type="directional" name="sun">
Expand Down

0 comments on commit ed5cd0b

Please sign in to comment.