Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate valid topics depending on world name #163

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/plugins/world_control/WorldControl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem)

this->dataPtr->controlService = "/world/" + worldName + "/control";
}
this->dataPtr->controlService = transport::TopicUtils::AsValidTopic(
this->dataPtr->controlService);

if (this->dataPtr->controlService.empty())
{
ignerr << "Failed to create valid control service for world [" << worldName
<< "]" << std::endl;
}

ignmsg << "Using world control service [" << this->dataPtr->controlService
<< "]" << std::endl;
Expand Down Expand Up @@ -185,6 +193,7 @@ void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem)
statsTopic = "/world/" + worldName + "/stats";
}

statsTopic = transport::TopicUtils::AsValidTopic(statsTopic);
if (!statsTopic.empty())
{
// Subscribe to world_stats
Expand All @@ -198,6 +207,11 @@ void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem)
ignmsg << "Listening to stats on [" << statsTopic << "]" << std::endl;
}
}
else
{
ignerr << "Failed to create valid topic for world [" << worldName << "]"
<< std::endl;
}
}

/////////////////////////////////////////////////
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/world_stats/WorldStats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ void WorldStats::LoadConfig(const tinyxml2::XMLElement *_pluginElem)
topic = "/world/" + worldName + "/stats";
}

topic = transport::TopicUtils::AsValidTopic(topic);
if (topic.empty())
{
ignerr << "Failed to create valid topic for world [" << worldName << "]"
<< std::endl;
return;
}

if (!this->dataPtr->node.Subscribe(topic, &WorldStats::OnWorldStatsMsg,
this))
{
Expand Down