From ee48126a518f5ac42546e5402b66d3ecbaa7d574 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Fri, 5 Aug 2022 09:44:19 -0700 Subject: [PATCH] Deprecations, ign -> gz (#1631) Signed-off-by: Louise Poubel --- include/gz/sim/Events.hh | 13 ++++---- include/gz/sim/ServerConfig.hh | 6 ++-- src/LevelManager.cc | 4 ++- src/SdfEntityCreator.cc | 10 +++++++ src/ServerConfig.cc | 24 ++------------- src/ServerConfig_TEST.cc | 15 ---------- src/Server_TEST.cc | 31 ++++++++++++-------- test/integration/battery_plugin.cc | 2 +- test/integration/reset.cc | 7 +++-- test/integration/scene_broadcaster_system.cc | 2 +- test/integration/sensors_system_battery.cc | 7 +++-- test/worlds/diff_drive_no_plugin.sdf | 4 +-- test/worlds/particle_emitter.sdf | 4 +++ test/worlds/reset_detachable_joint.sdf | 8 ++--- 14 files changed, 65 insertions(+), 72 deletions(-) diff --git a/include/gz/sim/Events.hh b/include/gz/sim/Events.hh index 859061d5c5..4a516a110d 100644 --- a/include/gz/sim/Events.hh +++ b/include/gz/sim/Events.hh @@ -55,16 +55,19 @@ namespace gz using Stop = gz::common::EventT; /// \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 `` tags. - /// \note This will be deprecated in Gazebo 7 (Garden), please the use - /// sdf::Plugin interface. - using LoadPlugins = common::EventT; + /// \deprecated Use the `sdf::Plugins` interface. +#ifdef _WIN32 + using LoadPlugins = +#else + using LoadPlugins GZ_DEPRECATED(7) = +#endif + common::EventT; /// \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 diff --git a/include/gz/sim/ServerConfig.hh b/include/gz/sim/ServerConfig.hh index db844d4039..e002deb84a 100644 --- a/include/gz/sim/ServerConfig.hh +++ b/include/gz/sim/ServerConfig.hh @@ -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 @@ -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. @@ -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. diff --git a/src/LevelManager.cc b/src/LevelManager.cc index dc62f375f0..09e8be6bc2 100644 --- a/src/LevelManager.cc +++ b/src/LevelManager.cc @@ -231,9 +231,11 @@ void LevelManager::ReadLevelPerformerInfo() // Load world plugins. this->runner->EventMgr().Emit(this->worldEntity, this->runner->sdfWorld->Plugins()); - // Deprecate this in Garden + + GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION this->runner->EventMgr().Emit(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( diff --git a/src/SdfEntityCreator.cc b/src/SdfEntityCreator.cc index 8e0ee669a0..0bd17a6517 100644 --- a/src/SdfEntityCreator.cc +++ b/src/SdfEntityCreator.cc @@ -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(worldEntity, p.ToElement()); + GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION } // Store the world's SDF DOM to be used when saving the world to file @@ -352,8 +354,10 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Model *_model) this->dataPtr->eventManager->Emit(entity, plugins); for (const sdf::Plugin &p : plugins) { + GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION this->dataPtr->eventManager->Emit(entity, p.ToElement()); + GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION } } this->dataPtr->newModels.clear(); @@ -364,8 +368,10 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Model *_model) this->dataPtr->eventManager->Emit(entity, plugins); for (const sdf::Plugin &p : plugins) { + GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION this->dataPtr->eventManager->Emit(entity, p.ToElement()); + GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION } } this->dataPtr->newSensors.clear(); @@ -376,8 +382,10 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Model *_model) this->dataPtr->eventManager->Emit(entity, plugins); for (const sdf::Plugin &p : plugins) { + GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION this->dataPtr->eventManager->Emit(entity, p.ToElement()); + GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION } } this->dataPtr->newVisuals.clear(); @@ -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(actorEntity, p.ToElement()); + GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION } return actorEntity; diff --git a/src/ServerConfig.cc b/src/ServerConfig.cc index 56eb835c47..9a726ccb4f 100644 --- a/src/ServerConfig.cc +++ b/src/ServerConfig.cc @@ -42,9 +42,7 @@ class gz::sim::ServerConfig::PluginInfoPrivate const std::unique_ptr &_info) : entityName(_info->entityName), entityType(_info->entityType), - plugin(_info->plugin), - filename(_info->filename), - name(_info->name) + plugin(_info->plugin) { this->sdf = plugin.Element(); } @@ -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()) { } @@ -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; }; @@ -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; } @@ -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; } ////////////////////////////////////////////////// @@ -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. diff --git a/src/ServerConfig_TEST.cc b/src/ServerConfig_TEST.cc index 42312830a2..29ce6b3703 100644 --- a/src/ServerConfig_TEST.cc +++ b/src/ServerConfig_TEST.cc @@ -62,27 +62,21 @@ TEST(ParsePluginsFromString, Valid) EXPECT_EQ("default", plugin->EntityName()); EXPECT_EQ("world", plugin->EntityType()); - EXPECT_EQ("TestWorldSystem", plugin->Filename()); EXPECT_EQ("TestWorldSystem", plugin->Plugin().Filename()); - EXPECT_EQ("gz::sim::TestWorldSystem", plugin->Name()); EXPECT_EQ("gz::sim::TestWorldSystem", plugin->Plugin().Name()); plugin = std::next(plugin, 1); EXPECT_EQ("box", plugin->EntityName()); EXPECT_EQ("model", plugin->EntityType()); - EXPECT_EQ("TestModelSystem", plugin->Filename()); EXPECT_EQ("TestModelSystem", plugin->Plugin().Filename()); - EXPECT_EQ("gz::sim::TestModelSystem", plugin->Name()); EXPECT_EQ("gz::sim::TestModelSystem", plugin->Plugin().Name()); plugin = std::next(plugin, 1); EXPECT_EQ("default::box::link_1::camera", plugin->EntityName()); EXPECT_EQ("sensor", plugin->EntityType()); - EXPECT_EQ("TestSensorSystem", plugin->Filename()); EXPECT_EQ("TestSensorSystem", plugin->Plugin().Filename()); - EXPECT_EQ("gz::sim::TestSensorSystem", plugin->Name()); EXPECT_EQ("gz::sim::TestSensorSystem", plugin->Plugin().Name()); } @@ -120,27 +114,21 @@ TEST(ParsePluginsFromFile, Valid) EXPECT_EQ("default", plugin->EntityName()); EXPECT_EQ("world", plugin->EntityType()); - EXPECT_EQ("TestWorldSystem", plugin->Filename()); EXPECT_EQ("TestWorldSystem", plugin->Plugin().Filename()); - EXPECT_EQ("gz::sim::TestWorldSystem", plugin->Name()); EXPECT_EQ("gz::sim::TestWorldSystem", plugin->Plugin().Name()); plugin = std::next(plugin, 1); EXPECT_EQ("box", plugin->EntityName()); EXPECT_EQ("model", plugin->EntityType()); - EXPECT_EQ("TestModelSystem", plugin->Filename()); EXPECT_EQ("TestModelSystem", plugin->Plugin().Filename()); - EXPECT_EQ("gz::sim::TestModelSystem", plugin->Name()); EXPECT_EQ("gz::sim::TestModelSystem", plugin->Plugin().Name()); plugin = std::next(plugin, 1); EXPECT_EQ("default::box::link_1::camera", plugin->EntityName()); EXPECT_EQ("sensor", plugin->EntityType()); - EXPECT_EQ("TestSensorSystem", plugin->Filename()); EXPECT_EQ("TestSensorSystem", plugin->Plugin().Filename()); - EXPECT_EQ("gz::sim::TestSensorSystem", plugin->Name()); EXPECT_EQ("gz::sim::TestSensorSystem", plugin->Plugin().Name()); } @@ -213,9 +201,7 @@ TEST(LoadPluginInfo, FromValidEnv) EXPECT_EQ("*", plugin->EntityName()); EXPECT_EQ("world", plugin->EntityType()); - EXPECT_EQ("TestWorldSystem", plugin->Filename()); EXPECT_EQ("TestWorldSystem", plugin->Plugin().Filename()); - EXPECT_EQ("gz::sim::TestWorldSystem", plugin->Name()); EXPECT_EQ("gz::sim::TestWorldSystem", plugin->Plugin().Name()); plugin = std::next(plugin, 1); @@ -223,7 +209,6 @@ TEST(LoadPluginInfo, FromValidEnv) EXPECT_EQ("box", plugin->EntityName()); EXPECT_EQ("model", plugin->EntityType()); EXPECT_EQ("TestModelSystem", plugin->Plugin().Filename()); - EXPECT_EQ("gz::sim::TestModelSystem", plugin->Name()); EXPECT_EQ("gz::sim::TestModelSystem", plugin->Plugin().Name()); EXPECT_TRUE(common::unsetenv(sim::kServerConfigPathEnv)); diff --git a/src/Server_TEST.cc b/src/Server_TEST.cc index 21943c25d1..48559728cc 100644 --- a/src/Server_TEST.cc +++ b/src/Server_TEST.cc @@ -120,9 +120,11 @@ TEST_P(ServerFixture, ServerConfigPluginInfo) EXPECT_EQ("an_entity", plugins.front().EntityName()); EXPECT_EQ("model", plugins.front().EntityType()); + GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION EXPECT_EQ("filename", plugins.front().Filename()); EXPECT_EQ("interface", plugins.front().Name()); EXPECT_EQ(nullptr, plugins.front().Sdf()); + GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION // Test operator= { @@ -131,9 +133,9 @@ TEST_P(ServerFixture, ServerConfigPluginInfo) EXPECT_EQ(info.EntityName(), plugins.front().EntityName()); EXPECT_EQ(info.EntityType(), plugins.front().EntityType()); - EXPECT_EQ(info.Filename(), plugins.front().Filename()); - EXPECT_EQ(info.Name(), plugins.front().Name()); - EXPECT_EQ(info.Sdf(), plugins.front().Sdf()); + EXPECT_EQ(info.Plugin().Name(), plugins.front().Plugin().Name()); + EXPECT_EQ(info.Plugin().Filename(), plugins.front().Plugin().Filename()); + EXPECT_EQ(info.Plugin().Element(), plugins.front().Plugin().Element()); } // Test copy constructor @@ -142,9 +144,9 @@ TEST_P(ServerFixture, ServerConfigPluginInfo) EXPECT_EQ(info.EntityName(), plugins.front().EntityName()); EXPECT_EQ(info.EntityType(), plugins.front().EntityType()); - EXPECT_EQ(info.Filename(), plugins.front().Filename()); - EXPECT_EQ(info.Name(), plugins.front().Name()); - EXPECT_EQ(info.Sdf(), plugins.front().Sdf()); + EXPECT_EQ(info.Plugin().Name(), plugins.front().Plugin().Name()); + EXPECT_EQ(info.Plugin().Filename(), plugins.front().Plugin().Filename()); + EXPECT_EQ(info.Plugin().Element(), plugins.front().Plugin().Element()); } // Test server config copy constructor @@ -155,9 +157,12 @@ TEST_P(ServerFixture, ServerConfigPluginInfo) EXPECT_EQ(cfgPlugins.front().EntityName(), plugins.front().EntityName()); EXPECT_EQ(cfgPlugins.front().EntityType(), plugins.front().EntityType()); - EXPECT_EQ(cfgPlugins.front().Filename(), plugins.front().Filename()); - EXPECT_EQ(cfgPlugins.front().Name(), plugins.front().Name()); - EXPECT_EQ(cfgPlugins.front().Sdf(), plugins.front().Sdf()); + EXPECT_EQ(cfgPlugins.front().Plugin().Filename(), + plugins.front().Plugin().Filename()); + EXPECT_EQ(cfgPlugins.front().Plugin().Name(), + plugins.front().Plugin().Name()); + EXPECT_EQ(cfgPlugins.front().Plugin().Element(), + plugins.front().Plugin().Element()); } } @@ -622,7 +627,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()); @@ -671,7 +676,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()); @@ -836,7 +841,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()); @@ -875,7 +880,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()); diff --git a/test/integration/battery_plugin.cc b/test/integration/battery_plugin.cc index 2d0e5ed1a8..798c62c4f0 100644 --- a/test/integration/battery_plugin.cc +++ b/test/integration/battery_plugin.cc @@ -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(); diff --git a/test/integration/reset.cc b/test/integration/reset.cc index 94f293f2cb..d06bbfda9b 100644 --- a/test/integration/reset.cc +++ b/test/integration/reset.cc @@ -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( diff --git a/test/integration/scene_broadcaster_system.cc b/test/integration/scene_broadcaster_system.cc index f630229e98..6b3f4d3f92 100644 --- a/test/integration/scene_broadcaster_system.cc +++ b/test/integration/scene_broadcaster_system.cc @@ -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()); diff --git a/test/integration/sensors_system_battery.cc b/test/integration/sensors_system_battery.cc index d160331d97..4eb35ec92f 100644 --- a/test/integration/sensors_system_battery.cc +++ b/test/integration/sensors_system_battery.cc @@ -65,9 +65,10 @@ class SensorsFixture : public InternalFixture> { 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( diff --git a/test/worlds/diff_drive_no_plugin.sdf b/test/worlds/diff_drive_no_plugin.sdf index 1792199086..c8c4eb69ce 100644 --- a/test/worlds/diff_drive_no_plugin.sdf +++ b/test/worlds/diff_drive_no_plugin.sdf @@ -7,8 +7,8 @@ 0 + filename="gz-sim-physics-system" + name="gz::sim::systems::Physics"> diff --git a/test/worlds/particle_emitter.sdf b/test/worlds/particle_emitter.sdf index e151439c82..73fb923177 100644 --- a/test/worlds/particle_emitter.sdf +++ b/test/worlds/particle_emitter.sdf @@ -11,6 +11,10 @@ filename="gz-sim-particle-emitter-system" name="gz::sim::systems::ParticleEmitter"> + + true diff --git a/test/worlds/reset_detachable_joint.sdf b/test/worlds/reset_detachable_joint.sdf index 9ecdc80d71..98925fdc7e 100644 --- a/test/worlds/reset_detachable_joint.sdf +++ b/test/worlds/reset_detachable_joint.sdf @@ -2,12 +2,12 @@ + filename="gz-sim-physics-system" + name="gz::sim::systems::Physics"> + filename="gz-sim-scene-broadcaster-system" + name="gz::sim::systems::SceneBroadcaster">