From f3a8da058cce74823ba252d0425801d35d83db8a Mon Sep 17 00:00:00 2001 From: suchetanrs <79915569+suchetanrs@users.noreply.github.com> Date: Mon, 13 Nov 2023 10:37:03 +0100 Subject: [PATCH 1/2] Added tf_prefix to the left_wheel_names and right_wheel_names. The tf prefix is added to the odom_frame_id and the base_frame_id. However, it is not done to the left_wheel_names and right_wheel_names. The differential drive controller is often used as a gazebo plugin like below. ``` ${robot_namespace} robot_description robot_state_publisher package://robot_description/config/robot_control.yaml ``` Since this is defined inside a xacro, the Rewritten yaml cannot be used to add namespaces to joints. Adding the namespace in the cpp file bypasses this issue. In the PR, the convention is followed. That is, "robot_namespace/left_wheel_name". Please let me know if I need to change it in any other place. The modified changes solves my issue and seems to run correctly on the Gazebo simulator. --- diff_drive_controller/src/diff_drive_controller.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/diff_drive_controller/src/diff_drive_controller.cpp b/diff_drive_controller/src/diff_drive_controller.cpp index ea08aef89b..0379c5f084 100644 --- a/diff_drive_controller/src/diff_drive_controller.cpp +++ b/diff_drive_controller/src/diff_drive_controller.cpp @@ -391,6 +391,15 @@ controller_interface::CallbackReturn DiffDriveController::on_configure( const auto odom_frame_id = tf_prefix + params_.odom_frame_id; const auto base_frame_id = tf_prefix + params_.base_frame_id; + for (auto & joint_name : params_.left_wheel_names) + { + joint_name = tf_prefix + joint_name; + } + for (auto & joint_name : params_.right_wheel_names) + { + joint_name = tf_prefix + joint_name; + } + auto & odometry_message = realtime_odometry_publisher_->msg_; odometry_message.header.frame_id = odom_frame_id; odometry_message.child_frame_id = base_frame_id; From 9078dd08489addfe16f564cea7c97e3b92f0c5ff Mon Sep 17 00:00:00 2001 From: suchetanrs Date: Sat, 24 Feb 2024 12:05:51 +0530 Subject: [PATCH 2/2] Fixed whitespace format issue --- 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 2df0eebf2a..296e00ff0a 100644 --- a/diff_drive_controller/src/diff_drive_controller.cpp +++ b/diff_drive_controller/src/diff_drive_controller.cpp @@ -393,7 +393,7 @@ controller_interface::CallbackReturn DiffDriveController::on_configure( { joint_name = tf_prefix + joint_name; } - + auto & odometry_message = realtime_odometry_publisher_->msg_; odometry_message.header.frame_id = odom_frame_id; odometry_message.child_frame_id = base_frame_id;