Controller Yaml File

The final thing to do is to specify which controller is required for your application.

A ros2_control_node in the controller_manager package is given a controller.yaml file which specifies the controllers that you will be using. For the drivetrain, a joint_state_broadcaster as well as a differential_drivetrain_controller (diff_drive_controller — ROS2_Control: Rolling Nov 2024 documentation ) are desired.

Thus, the config yaml file passed to the ros2_control_node looks as follows (differential_drive_train explained below).

controller_manager: ros__parameters: update_rate: 100 # Hz joint_state_broadcaster: type: joint_state_broadcaster/JointStateBroadcaster differential_drivetrain_controller: type: diff_drive_controller/DiffDriveController differential_drivetrain_controller: ros__parameters: left_wheel_names: [ "left_front_wheel_joint", "left_middle_wheel_joint", "left_back_wheel_joint" ] right_wheel_names: [ "right_front_wheel_joint", "right_middle_wheel_joint", "right_back_wheel_joint" ] # Should match values defined in uwrt_mars_rover_drivetrain_description's generated urdf wheel_separation: 0.997 # wheelbase_length = chassis_width + wheel_width wheels_per_side: 3 wheel_radius: 0.15 wheel_separation_multiplier: 1.0 left_wheel_radius_multiplier: 1.0 right_wheel_radius_multiplier: 1.0 odom_frame_id: odom base_frame_id: base_link pose_covariance_diagonal: [ 0.001, 0.001, 0.001, 0.001, 0.001, 0.01 ] twist_covariance_diagonal: [ 0.001, 0.001, 0.001, 0.001, 0.001, 0.01 ] publish_rate: 50.0 enable_odom_tf: true open_loop: false # If true, integrates vel_cmd to estimate odom, else uses wheel feedback to compute odom position_feedback: true # If true, uses position state_interface for odom calculations, else use velocity state interface # TODO: this setting doesnt really make sense to me to tie both odom pose and twist calculations to either use position or # velocity. It makes most sense to optimally use position for the pose calculation and velocity for the twist calculation... # as done in https://github.com/clearpathrobotics/ros_controllers/pull/18 # Relevant Discussion: https://github.com/ros-controls/ros2_controllers/pull/260/files/a45fd434abe90c1a377d57a54da86c6d1650240d#r776837336 cmd_vel_timeout: 0.2 # seconds. min cmd_vel publish rate is 5Hz publish_limited_velocity: true use_stamped_vel: false # FIXME (npalmar): chaneg back to true velocity_rolling_window_size: 10 # Velocity and acceleration limits # Whenever a min_* is unspecified, default to -max_* linear: x: has_velocity_limits: false has_acceleration_limits: false has_jerk_limits: false # max_velocity: 1.0 # max_acceleration: 1.0 # max_jerk: 0.0 angular: z: has_velocity_limits: false has_acceleration_limits: false has_jerk_limits: false # max_velocity: 1.0 # max_acceleration: 1.0 # max_jerk: 0.0

The differential drive train controller config specifies the names of the joints that are required by the controller, the actual size of the drivetrain (wheel radius, wheel separation, etc). A more detailed explanation on params can be found here: https://github.com/ros-controls/ros2_controllers/blob/master/diff_drive_controller/src/diff_drive_controller_parameter.yaml .