Skip to content

Commit

Permalink
More efficient handling of namespace as tf_prefix after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Kees van Teeffelen committed Feb 27, 2024
1 parent ab1f2c6 commit 30fb64e
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions diff_drive_controller/src/diff_drive_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,21 +372,14 @@ controller_interface::CallbackReturn DiffDriveController::on_configure(
tf_prefix = std::string(get_node()->get_namespace());
}

if (tf_prefix == "/")
// Make sure prefix does not start with '/' and always ends with '/'
if (tf_prefix.back() != '/')
{
tf_prefix = "";
tf_prefix = tf_prefix + "/";
}
else
if (tf_prefix.front() == '/')
{
// Make sure prefix does not start with '/' and always ends with '/'
if (tf_prefix.front() == '/')
{
tf_prefix.erase(0,1);
}
if (tf_prefix.back() != '/')
{
tf_prefix = tf_prefix + "/";
}
tf_prefix.erase(0,1);
}
}

Expand Down

0 comments on commit 30fb64e

Please sign in to comment.