From ab1f2c6228df9f012c73cfc3a8fb529fd4072a1b Mon Sep 17 00:00:00 2001 From: Kees van Teeffelen Date: Mon, 26 Feb 2024 15:41:17 +0100 Subject: [PATCH] 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 + "/"; + } } }