Skip to content

Commit

Permalink
Added tf_prefix to the left_wheel_names and right_wheel_names.
Browse files Browse the repository at this point in the history
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. 
```
    <gazebo>
      <plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control">
        <namespace>${robot_namespace}</namespace>
        <robot_param>robot_description</robot_param>
        <robot_param_node>robot_state_publisher</robot_param_node>
        <parameters>package://robot_description/config/robot_control.yaml</parameters>
      </plugin>
    </gazebo>
```

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.
  • Loading branch information
suchetanrs authored Nov 13, 2023
1 parent 0196eeb commit f3a8da0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions diff_drive_controller/src/diff_drive_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f3a8da0

Please sign in to comment.