From ab1f2c6228df9f012c73cfc3a8fb529fd4072a1b Mon Sep 17 00:00:00 2001 From: Kees van Teeffelen Date: Mon, 26 Feb 2024 15:41:17 +0100 Subject: [PATCH 1/3] Remove any '/' at start of tf_prefix and only add '/' at the end of tf_prefix when not there yet --- diff_drive_controller/src/diff_drive_controller.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/diff_drive_controller/src/diff_drive_controller.cpp b/diff_drive_controller/src/diff_drive_controller.cpp index 42b6cda8e1..13e7e6f3ed 100644 --- a/diff_drive_controller/src/diff_drive_controller.cpp +++ b/diff_drive_controller/src/diff_drive_controller.cpp @@ -378,7 +378,15 @@ controller_interface::CallbackReturn DiffDriveController::on_configure( } else { - tf_prefix = tf_prefix + "/"; + // 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 + "/"; + } } } From 30fb64e9d9eff2a1dbb7d88381ce67fb7768a838 Mon Sep 17 00:00:00 2001 From: Kees van Teeffelen Date: Tue, 27 Feb 2024 08:36:30 +0100 Subject: [PATCH 2/3] More efficient handling of namespace as tf_prefix after review --- .../src/diff_drive_controller.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/diff_drive_controller/src/diff_drive_controller.cpp b/diff_drive_controller/src/diff_drive_controller.cpp index 13e7e6f3ed..596b00d021 100644 --- a/diff_drive_controller/src/diff_drive_controller.cpp +++ b/diff_drive_controller/src/diff_drive_controller.cpp @@ -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); } } From 617f42101ee20dee13b0401de862d07a0cc9bd22 Mon Sep 17 00:00:00 2001 From: Kees van Teeffelen <107179662+kjvanteeffelen@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:19:30 +0200 Subject: [PATCH 3/3] Fix clang issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Christoph Fröhlich --- diff_drive_controller/src/diff_drive_controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff_drive_controller/src/diff_drive_controller.cpp b/diff_drive_controller/src/diff_drive_controller.cpp index 596b00d021..dca78626ad 100644 --- a/diff_drive_controller/src/diff_drive_controller.cpp +++ b/diff_drive_controller/src/diff_drive_controller.cpp @@ -379,7 +379,7 @@ controller_interface::CallbackReturn DiffDriveController::on_configure( } if (tf_prefix.front() == '/') { - tf_prefix.erase(0,1); + tf_prefix.erase(0, 1); } }