Skip to content

Commit

Permalink
Adds check for empty topic string to avoid unecessary invalid topic e…
Browse files Browse the repository at this point in the history
…rror

Signed-off-by: Jasmeet Singh <jasmeet0915@gmail.com>
  • Loading branch information
jasmeet0915 committed Oct 1, 2021
1 parent 0b92777 commit 5105afb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/systems/joint_state_publisher/JointStatePublisher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,13 @@ void JointStatePublisher::PostUpdate(const UpdateInfo &_info,
worldName = _ecm.Component<components::Name>(
parentEntity->Data())->Data();

// if topic not set it will be empty, hence invalid
// if topic not set it will be empty
std::vector<std::string> topics;
topics.push_back(this->topic);
// this helps avoid unecesarry invalid topic error
if (!this->topic.empty())
{
topics.push_back(this->topic);
}
topics.push_back(std::string("/world/") + worldName + "/model/"
+ this->model.Name(_ecm) + "/joint_state");
this->topic = validTopic(topics);
Expand Down

0 comments on commit 5105afb

Please sign in to comment.