From ed5cd0b7fc8acf88085481492d14c838428c34a1 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 | 9 ++++---- include/gz/sim/ServerConfig.hh | 6 ++--- src/LevelManager.cc | 4 +++- src/SdfEntityCreator.cc | 10 ++++++++ src/ServerConfig.cc | 24 +++----------------- src/Server_TEST.cc | 8 +++---- 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 +++---- 13 files changed, 47 insertions(+), 48 deletions(-) diff --git a/include/gz/sim/Events.hh b/include/gz/sim/Events.hh index 859061d5c53..b1b656a004e 100644 --- a/include/gz/sim/Events.hh +++ b/include/gz/sim/Events.hh @@ -55,16 +55,15 @@ 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. + using LoadPlugins GZ_DEPRECATED(7) = + 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 db844d4039a..e002deb84a3 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 dc62f375f0b..09e8be6bc2f 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 8e0ee669a0f..0bd17a65171 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 56eb835c476..9a726ccb4f4 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/Server_TEST.cc b/src/Server_TEST.cc index 21943c25d16..bda6f494d5d 100644 --- a/src/Server_TEST.cc +++ b/src/Server_TEST.cc @@ -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()); @@ -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()); @@ -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()); @@ -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()); diff --git a/test/integration/battery_plugin.cc b/test/integration/battery_plugin.cc index 2d0e5ed1a81..798c62c4f07 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 94f293f2cbb..d06bbfda9b9 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 f630229e980..6b3f4d3f927 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 d160331d97f..4eb35ec92fa 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 17921990860..c8c4eb69ce7 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 e151439c825..8bb7d9567ca 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 9ecdc80d718..98925fdc7e8 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">