Skip to content

Commit

Permalink
Fixed invalid service names
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
  • Loading branch information
ahcorde committed Sep 7, 2023
1 parent 58a0c0b commit f050411
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/SimulationRunner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include "gz/sim/Events.hh"
#include "gz/sim/SdfEntityCreator.hh"
#include "gz/sim/Util.hh"

#include "gz/transport/TopicUtils.hh"
#include "network/NetworkManagerPrimary.hh"
#include "SdfGenerator.hh"

Expand Down Expand Up @@ -100,7 +100,14 @@ SimulationRunner::SimulationRunner(const sdf::World *_world,
}

// Keep world name
this->worldName = _world->Name();
this->worldName = transport::TopicUtils::AsValidTopic(_world->Name());

auto validWorldName = transport::TopicUtils::AsValidTopic(worldName);
if (this->worldName.empty())
{
gzerr << "Can't start simulation runner with this world name [" << worldName << "]." << std::endl;
return;
}

this->parametersRegistry = std::make_unique<
gz::transport::parameters::ParametersRegistry>(
Expand Down
4 changes: 2 additions & 2 deletions src/systems/user_commands/UserCommands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ void UserCommands::Configure(const Entity &_entity,

// Pose vector service
std::string poseVectorService{
"/world/" + worldName + "/set_pose_vector"};
"/world/" + validWorldName + "/set_pose_vector"};
this->dataPtr->node.Advertise(poseVectorService,
&UserCommandsPrivate::PoseVectorService, this->dataPtr.get());

Expand Down Expand Up @@ -702,7 +702,7 @@ void UserCommands::Configure(const Entity &_entity,

// Visual service
std::string visualService
{"/world/" + worldName + "/visual_config"};
{"/world/" + validWorldName + "/visual_config"};
this->dataPtr->node.Advertise(visualService,
&UserCommandsPrivate::VisualService, this->dataPtr.get());

Expand Down

0 comments on commit f050411

Please sign in to comment.