From b96f8af360ec273c2b80d5566161ba11405e260d Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Fri, 16 Aug 2024 17:04:17 -0500 Subject: [PATCH 1/2] Revert behavior change introduced in #2452 PR #2452 changed the loading order of plugins attached to worlds and models. While the change is desirable, it changed the behavior of functions like `topicFromScopedName`. This reverts the behavior and the changes in associated tests. Signed-off-by: Addisu Z. Taddese --- src/SdfEntityCreator.cc | 8 ++------ .../LogicalAudioSensorPlugin.cc | 4 ++-- src/systems/pose_publisher/PosePublisher.cc | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/SdfEntityCreator.cc b/src/SdfEntityCreator.cc index afe266c5cd..501414782e 100644 --- a/src/SdfEntityCreator.cc +++ b/src/SdfEntityCreator.cc @@ -337,7 +337,7 @@ void SdfEntityCreator::CreateEntities(const sdf::World *_world, levelEntityNames.find(model->Name()) != levelEntityNames.end()) { - Entity modelEntity = this->CreateEntities(model, false); + Entity modelEntity = this->CreateEntities(model); this->SetParent(modelEntity, _worldEntity); } @@ -387,7 +387,7 @@ void SdfEntityCreator::CreateEntities(const sdf::World *_world, if (_world->ModelNameExists(_ref->Data())) { const sdf::Model *model = _world->ModelByName(_ref->Data()); - Entity modelEntity = this->CreateEntities(model, false); + Entity modelEntity = this->CreateEntities(model); this->SetParent(modelEntity, _worldEntity); this->SetParent(_entity, modelEntity); } @@ -450,7 +450,6 @@ void SdfEntityCreator::CreateEntities(const sdf::World *_world, this->dataPtr->ecm->CreateComponent( _worldEntity, components::WorldSdf(*_world)); - // Load world plugins first. this->dataPtr->eventManager->Emit(_worldEntity, _world->Plugins()); @@ -458,9 +457,6 @@ void SdfEntityCreator::CreateEntities(const sdf::World *_world, this->dataPtr->eventManager->Emit(_worldEntity, _world->ToElement()); GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION - - // Load model plugins after the world plugin. - this->LoadModelPlugins(); } ////////////////////////////////////////////////// diff --git a/src/systems/logical_audio_sensor_plugin/LogicalAudioSensorPlugin.cc b/src/systems/logical_audio_sensor_plugin/LogicalAudioSensorPlugin.cc index fab58be000..c0836401dd 100644 --- a/src/systems/logical_audio_sensor_plugin/LogicalAudioSensorPlugin.cc +++ b/src/systems/logical_audio_sensor_plugin/LogicalAudioSensorPlugin.cc @@ -405,7 +405,7 @@ void LogicalAudioSensorPluginPrivate::CreateAudioSource( }; // create services for this source - const auto validName = topicFromScopedName(entity, _ecm, true); + const auto validName = topicFromScopedName(entity, _ecm, false); if (validName.empty()) { gzerr << "Failed to create valid topics with entity scoped name [" @@ -503,7 +503,7 @@ void LogicalAudioSensorPluginPrivate::CreateMicrophone( // create the detection publisher for this microphone auto pub = this->node.Advertise( - topicFromScopedName(entity, _ecm, true) + "/detection"); + topicFromScopedName(entity, _ecm, false) + "/detection"); if (!pub) { gzerr << "Error creating a detection publisher for microphone " diff --git a/src/systems/pose_publisher/PosePublisher.cc b/src/systems/pose_publisher/PosePublisher.cc index d4c9bc0d39..fd167a882e 100644 --- a/src/systems/pose_publisher/PosePublisher.cc +++ b/src/systems/pose_publisher/PosePublisher.cc @@ -250,7 +250,7 @@ void PosePublisher::Configure(const Entity &_entity, this->dataPtr->usePoseV = _sdf->Get("use_pose_vector_msg", this->dataPtr->usePoseV).first; - std::string poseTopic = topicFromScopedName(_entity, _ecm, true) + "/pose"; + std::string poseTopic = topicFromScopedName(_entity, _ecm, false) + "/pose"; if (poseTopic.empty()) { poseTopic = "/pose"; From 7d96623745b7916329fe07fbab56d5431b16cefb Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Fri, 16 Aug 2024 19:33:21 -0500 Subject: [PATCH 2/2] Load world plugins first The issue was not that world plugins are loaded after model plugins, but that previously, model plugins were called before the model's parent entity was set. Signed-off-by: Addisu Z. Taddese --- src/SdfEntityCreator.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/SdfEntityCreator.cc b/src/SdfEntityCreator.cc index 501414782e..8640682f10 100644 --- a/src/SdfEntityCreator.cc +++ b/src/SdfEntityCreator.cc @@ -328,6 +328,14 @@ void SdfEntityCreator::CreateEntities(const sdf::World *_world, components::SphericalCoordinates(*_world->SphericalCoordinates())); } + this->dataPtr->eventManager->Emit(_worldEntity, + _world->Plugins()); + + GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION + this->dataPtr->eventManager->Emit(_worldEntity, + _world->ToElement()); + GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION + // Models for (uint64_t modelIndex = 0; modelIndex < _world->ModelCount(); ++modelIndex) @@ -449,14 +457,6 @@ void SdfEntityCreator::CreateEntities(const sdf::World *_world, // Store the world's SDF DOM to be used when saving the world to file this->dataPtr->ecm->CreateComponent( _worldEntity, components::WorldSdf(*_world)); - - this->dataPtr->eventManager->Emit(_worldEntity, - _world->Plugins()); - - GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION - this->dataPtr->eventManager->Emit(_worldEntity, - _world->ToElement()); - GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION } //////////////////////////////////////////////////