Ros2_control joint state broadcaster issue

Hello Everyone,

DISTRO: Humble
Gazebo: Fortress

I have been working with ros2_control extensively for past 5-6 months. But recently I have been facing a very weird issue. The same program that used to work before is not working anymore. Mainly the joint state broadcaster is not loading. I have attached the error and the launch file. This is for rosbot_xl. I would appreciate it if anyone can help regarding this.

#!/usr/bin/env python3

# Copyright 2020 ros2_control Development Team
# Copyright 2024 Husarion sp. z o.o.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, OpaqueFunction, RegisterEventHandler
from launch.conditions import UnlessCondition
from launch.event_handlers import OnProcessExit
from launch.substitutions import (
    Command,
    FindExecutable,
    LaunchConfiguration,
    PathJoinSubstitution,
    PythonExpression,
)
from launch_ros.actions import Node, SetParameter
from launch_ros.substitutions import FindPackageShare


def launch_setup(context, *args, **kwargs):
    namespace = LaunchConfiguration("namespace").perform(context)
    controller_manager_name = "controller_manager"
    if namespace != "":
        controller_manager_name = namespace + "/" + controller_manager_name

    joint_state_broadcaster_spawner = Node(
        package="controller_manager",
        executable="spawner",
        arguments=[
            "joint_state_broadcaster",
            "--controller-manager",
            controller_manager_name,
            "--controller-manager-timeout",
            "120",
            "--namespace",
            namespace,
        ],
    )

    robot_controller_spawner = Node(
        package="controller_manager",
        name=LaunchConfiguration(
            "robot_controller_spawner_name",
            default=[namespace, "_robot_controller_spawner"],
        ),
        executable="spawner",
        arguments=[
            "rosbot_xl_base_controller",
            "--controller-manager",
            controller_manager_name,
            "--controller-manager-timeout",
            "120",
            "--namespace",
            namespace,
        ],
    )

    delay_robot_controller_spawner_after_joint_state_broadcaster_spawner = RegisterEventHandler(
        event_handler=OnProcessExit(
            target_action=joint_state_broadcaster_spawner,
            on_exit=[robot_controller_spawner],
        )
    )

    imu_broadcaster_spawner = Node(
        package="controller_manager",
        name=LaunchConfiguration(
            "imu_spawner_name", default=[namespace, "_imu_broadcaster_spawner"]
        ),
        executable="spawner",
        arguments=[
            "imu_broadcaster",
            "--controller-manager",
            controller_manager_name,
            "--controller-manager-timeout",
            "120",
            "--namespace",
            namespace,
        ],
    )

    delay_imu_broadcaster_spawner_after_robot_controller_spawner = RegisterEventHandler(
        event_handler=OnProcessExit(
            target_action=robot_controller_spawner,
            on_exit=[imu_broadcaster_spawner],
        )
    )
    return [
        joint_state_broadcaster_spawner,
        delay_robot_controller_spawner_after_joint_state_broadcaster_spawner,
        delay_imu_broadcaster_spawner_after_robot_controller_spawner,
    ]


def generate_launch_description():
    namespace = LaunchConfiguration("namespace")
    declare_namespace_arg = DeclareLaunchArgument(
        "namespace",
        default_value="",
        description="Namespace for all topics and tfs",
    )

    mecanum = LaunchConfiguration("mecanum")
    declare_mecanum_arg = DeclareLaunchArgument(
        "mecanum",
        default_value="False",
        description="Whether to use mecanum drive controller, otherwise use diff drive",
    )

    camera_model = LaunchConfiguration("camera_model")
    declare_camera_model_arg = DeclareLaunchArgument(
        "camera_model",
        default_value="None",
        description="Add camera model to the robot URDF",
        choices=[
            "None",
            "intel_realsense_d435",
            "orbbec_astra",
            "stereolabs_zed",
            "stereolabs_zedm",
            "stereolabs_zed2",
            "stereolabs_zed2i",
            "stereolabs_zedx",
            "stereolabs_zedxm",
        ],
    )

    lidar_model = LaunchConfiguration("lidar_model")
    declare_lidar_model_arg = DeclareLaunchArgument(
        "lidar_model",
        default_value="None",
        description="Add LiDAR model to the robot URDF",
        choices=[
            "None",
            "slamtec_rplidar_a2",
            "slamtec_rplidar_a3",
            "slamtec_rplidar_s1",
            "slamtec_rplidar_s2",
            "slamtec_rplidar_s3",
            "velodyne_puck",
        ],
    )

    include_camera_mount = LaunchConfiguration("include_camera_mount")
    declare_include_camera_mount_arg = DeclareLaunchArgument(
        "include_camera_mount",
        default_value="False",
        description="Whether to include camera mount to the robot URDF",
    )

    use_sim = LaunchConfiguration("use_sim")
    declare_use_sim_arg = DeclareLaunchArgument(
        "use_sim",
        default_value="False",
        description="Whether simulation is used",
    )

    simulation_engine = LaunchConfiguration("simulation_engine")
    declare_simulation_engine_arg = DeclareLaunchArgument(
        "simulation_engine",
        default_value="ignition-gazebo",
        description="Which simulation engine will be used",
    )

    controller_config_name = PythonExpression(
        [
            "'mecanum_drive_controller.yaml' if ",
            mecanum,
            " else 'diff_drive_controller.yaml'",
        ]
    )

    controller_config_path = PathJoinSubstitution(
        [
            FindPackageShare("rosbot_xl_controller"),
            "config",
            controller_config_name,
        ]
    )

    robot_description_content = Command(
        [
            PathJoinSubstitution([FindExecutable(name="xacro")]),
            " ",
            PathJoinSubstitution(
                [
                    FindPackageShare("rosbot_xl_description"),
                    "urdf",
                    "rosbot_xl.urdf.xacro",
                ]
            ),
            " controller_config_file:=",
            controller_config_path,
            " mecanum:=",
            mecanum,
            " lidar_model:=",
            lidar_model,
            " camera_model:=",
            camera_model,
            " include_camera_mount:=",
            include_camera_mount,
            " use_sim:=",
            use_sim,
            " simulation_engine:=",
            simulation_engine,
            " namespace:=",
            namespace,
        ]
    )
    robot_description = {"robot_description": robot_description_content}

    control_node = Node(
        package="controller_manager",
        executable="ros2_control_node",
        parameters=[
            robot_description,
            controller_config_path,
        ],
        remappings=[
            ("imu_sensor_node/imu", "/_imu/data_raw"),
            ("~/motors_cmd", "/_motors_cmd"),
            ("~/motors_response", "/_motors_response"),
            ("rosbot_xl_base_controller/cmd_vel_unstamped", "cmd_vel"),
            ("/tf", "tf"),
            ("/tf_static", "tf_static"),
        ],
        condition=UnlessCondition(use_sim),
        namespace=namespace,
    )

    robot_state_pub_node = Node(
        package="robot_state_publisher",
        executable="robot_state_publisher",
        output="both",
        parameters=[robot_description],
        remappings=[("/tf", "tf"), ("/tf_static", "tf_static")],
        namespace=namespace,
    )

    return LaunchDescription(
        [
            declare_namespace_arg,
            declare_mecanum_arg,
            declare_lidar_model_arg,
            declare_camera_model_arg,
            declare_include_camera_mount_arg,
            declare_use_sim_arg,
            declare_simulation_engine_arg,
            SetParameter(name="use_sim_time", value=use_sim),
            control_node,
            robot_state_pub_node,
            OpaqueFunction(function=launch_setup),
        ]
    )

Hi @ritwikrohan7b40210eed0d34a2d ,

I have two questions:

  1. Did you try running starting the joint_state_broadcaster without the additional arguments? If you did what was the result? Did the process die the exact same way?
  2. Can you also post your controller configuration yaml file?

Regards,
Girish

Hi Girish,
Thanks for the prompt reply,

  1. Yes I just tried after removing the arguements and I am getting the same results.

  2. below:

  3. Also this is the controllers status

---
/**/controller_manager:
  ros__parameters:
    use_sim_time: false
    update_rate: 25 # Hz

    joint_state_broadcaster:
      type: joint_state_broadcaster/JointStateBroadcaster
    rosbot_xl_base_controller:
      type: mecanum_drive_controller/MecanumDriveController
    imu_broadcaster:
      type: imu_sensor_broadcaster/IMUSensorBroadcaster

/**/imu_broadcaster:
  ros__parameters:
    tf_frame_prefix_enable: false
    use_namespace_as_sensor_name_prefix: true

    sensor_name: imu
    frame_id: imu_link
    static_covariance_orientation: [1.9e-3, 0.0, 0.0, 0.0, 1.9e-3, 0.0, 0.0, 0.0, 1.9e-3] # Values taken from datasheet
    static_covariance_angular_velocity: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0e-3] # Values based on diff_drive
    static_covariance_linear_acceleration: [6.4e-2, 0.0, 0.0, 2.2e-2, 0.0, 0.0, 0.0, 0.0, 0.0] # Values based on diff_drive

/**/rosbot_xl_base_controller:
  ros__parameters:
    tf_frame_prefix_enable: false
    front_left_wheel_name: fl_wheel_joint
    front_right_wheel_name: fr_wheel_joint
    rear_left_wheel_name: rl_wheel_joint
    rear_right_wheel_name: rr_wheel_joint

    wheel_separation_x: 0.170
    wheel_separation_y: 0.270
    wheel_radius: 0.05

    wheel_separation_multiplier_x: 1.0
    wheel_separation_multiplier_y: 1.0

    wheel_radius_multiplier: 1.0

    # Feedback from motors is published at around 20 Hz
    publish_rate: 25.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: [3.3e-5, 3.3e-5, 0.0, 0.0, 0.0, 2.8e-3] # Values based on diff_drive

    # Whether to use feedback or commands for odometry calculations
    open_loop: false

    # Update odometry from velocity
    # in sensor fusion only velocity is used and with this setting it is more accurate
    position_feedback: false
    # velocity computation filtering
    velocity_rolling_window_size: 1

    enable_odom_tf: false

    cmd_vel_timeout: 0.5
    #publish_limited_velocity: true
    use_stamped_vel: false

    # Velocity and acceleration limits
    # Whenever a min_* is unspecified, default to -max_*
    # Limits from manual https://husarion.com/manuals/rosbot-xl/#hardware-guide
    linear:
      x:
        has_velocity_limits: true
        has_acceleration_limits: true
        has_jerk_limits: false
        # top speed is around 0.8m/s
        max_velocity: 0.8 # m/s
        # min_velocity -  When unspecified, -max_velocity is used
        max_acceleration: 1.0 # m/s^2
        # min_acceleration - When unspecified, -max_acceleration is used.
        max_jerk: 0.0 # m/s^3
      y:
        has_velocity_limits: true
        has_acceleration_limits: true
        has_jerk_limits: false
        # top speed is around 0.8m/s
        max_velocity: 0.8 # m/s
        # min_velocity -  When unspecified, -max_velocity is used
        max_acceleration: 1.0 # m/s^2
        # min_acceleration - When unspecified, -max_acceleration is used.
        max_jerk: 0.0 # m/s^3

    angular:
      z:
        has_velocity_limits: true
        has_acceleration_limits: true
        has_jerk_limits: false
        max_velocity: 3.14 # rad/s
        # min_velocity -  When unspecified, -max_velocity is used
        max_acceleration: 4.0 # rad/s^2
        # min_acceleration - When unspecified, -max_acceleration is used.
        max_jerk: 0.0 # rad/s^3


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.