Robotics StackExchange | Archived questions

Could not contact service /controller_manager/load_controller on Foxy, but works of Galactic

Hi. Sorry for all mistakes, English is not my native language.

So I found on github an open repository in wich one briliant man created ackermann_controller for ros2. This controller only works on Galactic and, as far as I understand, Humble. The problem is that I need it to work of Foxy. I know that Foxy is not supported anymore, but I can't use any other distro right now because most of the migration from ROS1 is already finished and controller is all that left. Project itself is sucsesfully builded on Foxy, but launch files not working. I want to launch one specific launch file, this is it content:

import os

import launch

from launch.actions import DeclareLaunchArgument, ExecuteProcess, RegisterEventHandler
from launch.conditions import IfCondition, UnlessCondition
from launch.event_handlers import OnProcessExit
from launch.substitutions import Command, LaunchConfiguration
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare

def generate_launch_description():
    beetle_desc_dir = FindPackageShare(package='beetle_description').find('beetle_description')
    beetle_gazebo_dir = FindPackageShare(package='beetle_gazebo').find('beetle_gazebo')
    launch_dir = os.path.join(beetle_gazebo_dir, 'launch')
    default_controller_yaml_file = os.path.join(beetle_gazebo_dir, 'config/ackermann_controller.yaml')
    default_rviz_config_file = os.path.join(beetle_gazebo_dir, 'rviz/default_view.rviz')
    ctu_map_path = os.path.join( beetle_gazebo_dir, 'worlds/ctu_college_of_tech_workshop.world')

    # Create launch configuration variables
    headless = LaunchConfiguration('headless')
    use_sim_time = LaunchConfiguration('use_sim_time')
    use_rviz = LaunchConfiguration('use_rviz')
    params_file = LaunchConfiguration('params_file')
    world_file = LaunchConfiguration('world_file')
    rviz_config_file = LaunchConfiguration('rviz_config_file')
    api_key = LaunchConfiguration('api_key')
    log_level = LaunchConfiguration('log_level')

    robot_description = Command(['xacro ', os.path.join(beetle_desc_dir, 'urdf/beetle.urdf'),
                                ' beetle_controller_yaml_file:=', params_file])
    # default_world_file = Command([ 'xacro ', ctu_map_path, ' api_key:=', api_key])
    default_world_file = Command(['xacro ', os.path.join(beetle_gazebo_dir, 'worlds/empty.world')])

    # Define launch arguments
    headless = LaunchConfiguration('headless')
    declare_headless_cmd = DeclareLaunchArgument(
        'headless', default_value='True',
        description='Whether to start gzclient')
    declare_use_sim_time_cmd = DeclareLaunchArgument(
        'use_sim_time',
        default_value='True',
        description='Use simulation (Gazebo) clock if true')
    declare_use_rviz_cmd = DeclareLaunchArgument(
        'use_rviz', default_value='False',
        description='Start with RViz if true')
    declare_params_file_cmd = DeclareLaunchArgument(
        name='params_file', default_value=default_controller_yaml_file,
        description='Absolute path to controller yaml config file')
    declare_world_file_cmd = DeclareLaunchArgument(
        name='world_file', default_value=default_world_file,
        description='Absolute path to world file to launch with Gazebo')
    declare_rviz_config_file_cmd = DeclareLaunchArgument(
        name='rviz_config_file', default_value=default_rviz_config_file,
        description='Absolute path to rviz config file')
    declare_api_key_cmd = DeclareLaunchArgument(
        name='api_key', default_value='',
        description='Google API key to download map')
    declare_log_level_cmd = DeclareLaunchArgument(
        'log_level', default_value='info',
        description='log level')
    # pose = {'x': LaunchConfiguration('x_pose', default='-12.00'),
    #         'y': LaunchConfiguration('y_pose', default='10.00'),
    #         'z': LaunchConfiguration('z_pose', default='0.70'),
    #         'R': LaunchConfiguration('roll', default='0.00'),
    #         'P': LaunchConfiguration('pitch', default='0.00'),
    #         'Y': LaunchConfiguration('yaw', default='0.00')}
    pose = {'x': LaunchConfiguration('x_pose', default='0.00'),
            'y': LaunchConfiguration('y_pose', default='0.00'),
            'z': LaunchConfiguration('z_pose', default='0.70'),
            'R': LaunchConfiguration('roll', default='0.00'),
            'P': LaunchConfiguration('pitch', default='0.00'),
            'Y': LaunchConfiguration('yaw', default='0.00')}

    # Define actions
    start_gazebo_server = ExecuteProcess(
        cmd=['gzserver', '--verbose', '-s', 'libgazebo_ros_init.so',
            '-s', 'libgazebo_ros_factory.so', world_file],
        cwd=[launch_dir], output='screen')
    start_gazebo_client = ExecuteProcess(
        condition=UnlessCondition(headless),
        cmd=['gzclient'],
        cwd=[launch_dir], output='screen')
    start_gazebo_spawner = Node(
        package='gazebo_ros',
        executable='spawn_entity.py',
        arguments=['-entity', 'beetle',
                '-topic', 'robot_description',
                '-x', pose['x'], '-y', pose['y'], '-z', pose['z'],
                '-R', pose['R'], '-P', pose['P'], '-Y', pose['Y']],
        output='screen')
    start_joint_state_publisher = Node(
        package='joint_state_publisher',
        executable='joint_state_publisher',
        name='joint_state_publisher',
        parameters=[{'use_sim_time': use_sim_time}])
    start_robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        output='screen',
        parameters=[{'use_sim_time': use_sim_time,
                    'robot_description': robot_description}])
    start_rviz = Node(
        condition=IfCondition(use_rviz),
        package='rviz2',
        executable='rviz2',
        name='rviz2',
        output='screen',
        arguments=['-d', rviz_config_file],
        parameters=[{'use_sim_time': use_sim_time}])
    load_joint_state_controller = ExecuteProcess(
        cmd=['ros2', 'control', 'load_controller', '--set-state', 'start',
            'joint_state_broadcaster'],
        output='screen')
    load_ackermann_drive_base_controller = ExecuteProcess(
        cmd=['ros2', 'control', 'load_controller', '--set-state', 'start',
            'ackermann_drive_base_controller'],
        output='screen')

    # Declare event handlers

    load_ackermann_drive_base_ctrl_event = RegisterEventHandler(
    event_handler=OnProcessExit(
        target_action=start_gazebo_spawner,
        on_exit=[load_ackermann_drive_base_controller]))
    load_joint_state_ctrl_event = RegisterEventHandler(
        event_handler=OnProcessExit(
            target_action=load_joint_state_controller,
            on_exit=[load_joint_state_controller]))

    # Create launch description
    ld = launch.LaunchDescription()

    # Declare launch options
    ld.add_action(declare_headless_cmd)
    ld.add_action(declare_use_sim_time_cmd)
    ld.add_action(declare_use_rviz_cmd)
    ld.add_action(declare_params_file_cmd)
    ld.add_action(declare_world_file_cmd)
    ld.add_action(declare_rviz_config_file_cmd)
    ld.add_action(declare_api_key_cmd)
    ld.add_action(declare_log_level_cmd)

    # Register event handlers
    ld.add_action(load_ackermann_drive_base_ctrl_event)
    # ld.add_action(load_joint_state_ctrl_event)

    # Add actions
    ld.add_action(start_gazebo_server)
    ld.add_action(start_gazebo_client)
    ld.add_action(start_gazebo_spawner)
    ld.add_action(start_joint_state_publisher)
    ld.add_action(start_robot_state_publisher)
    ld.add_action(start_rviz)

    return ld

And this is launching result on Foxy:

[INFO] [launch]: All log files can be found below /home/mikita/.ros/log/2023-05-12-07-20-59-565635-ubuntu-16039
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [gzserver-1]: process started with pid [16043]
[INFO] [spawn_entity.py-2]: process started with pid [16045]
[INFO] [joint_state_publisher-3]: process started with pid [16047]
[INFO] [robot_state_publisher-4]: process started with pid [16049]
[robot_state_publisher-4] Parsing robot urdf xml string.
[robot_state_publisher-4] The root link base_link has an inertia specified in the URDF, but KDL does not support a root link with an inertia.  As a workaround, you can add an extra dummy link to your URDF.
[robot_state_publisher-4] Link base_footprint had 0 children
[robot_state_publisher-4] Link gps_link had 0 children
[robot_state_publisher-4] Link imu_link had 0 children
[robot_state_publisher-4] Link left_steering_link had 1 children
[robot_state_publisher-4] Link front_left_wheel_link had 2 children
[robot_state_publisher-4] Link front_left_wheel_inner_rim_link had 0 children
[robot_state_publisher-4] Link front_left_wheel_outer_rim_link had 0 children
[robot_state_publisher-4] Link rear_left_wheel_link had 2 children
[robot_state_publisher-4] Link rear_left_wheel_inner_rim_link had 0 children
[robot_state_publisher-4] Link rear_left_wheel_outer_rim_link had 0 children
[robot_state_publisher-4] Link rear_right_wheel_link had 2 children
[robot_state_publisher-4] Link rear_right_wheel_inner_rim_link had 0 children
[robot_state_publisher-4] Link rear_right_wheel_outer_rim_link had 0 children
[robot_state_publisher-4] Link right_steering_link had 1 children
[robot_state_publisher-4] Link front_right_wheel_link had 2 children
[robot_state_publisher-4] Link front_right_wheel_inner_rim_link had 0 children
[robot_state_publisher-4] Link front_right_wheel_outer_rim_link had 0 children
[robot_state_publisher-4] [INFO] [1683901260.021002158] [robot_state_publisher]: got segment base_footprint
[robot_state_publisher-4] [INFO] [1683901260.021204613] [robot_state_publisher]: got segment base_link
[robot_state_publisher-4] [INFO] [1683901260.021231923] [robot_state_publisher]: got segment front_left_wheel_inner_rim_link
[robot_state_publisher-4] [INFO] [1683901260.021245573] [robot_state_publisher]: got segment front_left_wheel_link
[robot_state_publisher-4] [INFO] [1683901260.021257578] [robot_state_publisher]: got segment front_left_wheel_outer_rim_link
[robot_state_publisher-4] [INFO] [1683901260.021268670] [robot_state_publisher]: got segment front_right_wheel_inner_rim_link
[robot_state_publisher-4] [INFO] [1683901260.021280557] [robot_state_publisher]: got segment front_right_wheel_link
[robot_state_publisher-4] [INFO] [1683901260.021293706] [robot_state_publisher]: got segment front_right_wheel_outer_rim_link
[robot_state_publisher-4] [INFO] [1683901260.021304987] [robot_state_publisher]: got segment gps_link
[robot_state_publisher-4] [INFO] [1683901260.021316472] [robot_state_publisher]: got segment imu_link
[robot_state_publisher-4] [INFO] [1683901260.021328221] [robot_state_publisher]: got segment left_steering_link
[robot_state_publisher-4] [INFO] [1683901260.021339534] [robot_state_publisher]: got segment rear_left_wheel_inner_rim_link
[robot_state_publisher-4] [INFO] [1683901260.021351590] [robot_state_publisher]: got segment rear_left_wheel_link
[robot_state_publisher-4] [INFO] [1683901260.021365118] [robot_state_publisher]: got segment rear_left_wheel_outer_rim_link
[robot_state_publisher-4] [INFO] [1683901260.021377828] [robot_state_publisher]: got segment rear_right_wheel_inner_rim_link
[robot_state_publisher-4] [INFO] [1683901260.021389677] [robot_state_publisher]: got segment rear_right_wheel_link
[robot_state_publisher-4] [INFO] [1683901260.021401528] [robot_state_publisher]: got segment rear_right_wheel_outer_rim_link
[robot_state_publisher-4] [INFO] [1683901260.021413134] [robot_state_publisher]: got segment right_steering_link
[gzserver-1] Gazebo multi-robot simulator, version 11.11.0
[gzserver-1] Copyright (C) 2012 Open Source Robotics Foundation.
[gzserver-1] Released under the Apache 2 License.
[gzserver-1] http://gazebosim.org
[gzserver-1] 
[spawn_entity.py-2] [INFO] [1683901260.606154411] [spawn_entity]: Spawn Entity started
[spawn_entity.py-2] [INFO] [1683901260.606798929] [spawn_entity]: Loading entity published on topic robot_description
[spawn_entity.py-2] [INFO] [1683901260.609504903] [spawn_entity]: Waiting for entity xml on robot_description
[spawn_entity.py-2] [INFO] [1683901260.762457403] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30
[spawn_entity.py-2] [INFO] [1683901260.763118314] [spawn_entity]: Waiting for service /spawn_entity
[joint_state_publisher-3] [INFO] [1683901260.768495310] [joint_state_publisher]: Waiting for robot_description to be published on the robot_description topic...
[gzserver-1] [Msg] Waiting for master.
[gzserver-1] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
[gzserver-1] [Wrn] [Server.cc:381] Falling back on worlds/empty.world
[spawn_entity.py-2] [INFO] [1683901262.021507050] [spawn_entity]: Calling service /spawn_entity
[spawn_entity.py-2] [INFO] [1683901262.743477978] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [beetle]
[INFO] [spawn_entity.py-2]: process has finished cleanly [pid 16045]
[INFO] [ros2-5]: process started with pid [16129]
[gzserver-1] [INFO] [1683901262.881483522] [gazebo_ros2_control]: Loading gazebo_ros2_control plugin
[gzserver-1] [INFO] [1683901262.902165697] [gazebo_ros2_control]: Starting gazebo_ros2_control plugin in namespace: /
[gzserver-1] [INFO] [1683901262.902715017] [gazebo_ros2_control]: Starting gazebo_ros2_control plugin in ros 2 node: gazebo_ros2_control
[gzserver-1] [INFO] [1683901262.902820724] [gazebo_ros2_control]: Loading parameter files /home/mikita/ros2_ws/install/beetle_gazebo/share/beetle_gazebo/config/ackermann_controller.yaml
[gzserver-1] [INFO] [1683901262.917438243] [gazebo_ros2_control]: connected to service!! robot_state_publisher
[gzserver-1] [INFO] [1683901262.921204565] [gazebo_ros2_control]: Recieved urdf from param server, parsing...
[gzserver-1] [INFO] [1683901262.945487922] [gazebo_ros2_control]: Loading joint: rear_left_wheel_joint
[gzserver-1] [INFO] [1683901262.945661619] [gazebo_ros2_control]:   State:
[gzserver-1] [INFO] [1683901262.945705133] [gazebo_ros2_control]:        position
[gzserver-1] [INFO] [1683901262.945761806] [gazebo_ros2_control]:        velocity
[gzserver-1] [INFO] [1683901262.945795100] [gazebo_ros2_control]:   Command:
[gzserver-1] [INFO] [1683901262.945808738] [gazebo_ros2_control]:        velocity
[gzserver-1] [INFO] [1683901262.945845927] [gazebo_ros2_control]: Loading joint: rear_right_wheel_joint
[gzserver-1] [INFO] [1683901262.945861040] [gazebo_ros2_control]:   State:
[gzserver-1] [INFO] [1683901262.945870666] [gazebo_ros2_control]:        position
[gzserver-1] [INFO] [1683901262.945880992] [gazebo_ros2_control]:        velocity
[gzserver-1] [INFO] [1683901262.945890231] [gazebo_ros2_control]:   Command:
[gzserver-1] [INFO] [1683901262.945898851] [gazebo_ros2_control]:        velocity
[gzserver-1] [INFO] [1683901262.945996708] [gazebo_ros2_control]: Loading joint: left_steering_joint
[gzserver-1] [INFO] [1683901262.946013661] [gazebo_ros2_control]:   State:
[gzserver-1] [INFO] [1683901262.946023308] [gazebo_ros2_control]:        position
[gzserver-1] [INFO] [1683901262.946033208] [gazebo_ros2_control]:        velocity
[gzserver-1] [INFO] [1683901262.946042425] [gazebo_ros2_control]:   Command:
[gzserver-1] [INFO] [1683901262.946051392] [gazebo_ros2_control]:        position
[gzserver-1] [INFO] [1683901262.946063304] [gazebo_ros2_control]: Loading joint: right_steering_joint
[gzserver-1] [INFO] [1683901262.946072936] [gazebo_ros2_control]:   State:
[gzserver-1] [INFO] [1683901262.946082293] [gazebo_ros2_control]:        position
[gzserver-1] [INFO] [1683901262.946091204] [gazebo_ros2_control]:        velocity
[gzserver-1] [INFO] [1683901262.946100363] [gazebo_ros2_control]:   Command:
[gzserver-1] [INFO] [1683901262.946109042] [gazebo_ros2_control]:        position
[ERROR] [gzserver-1]: process has died [pid 16043, exit code -11, cmd 'gzserver --verbose -s libgazebo_ros_init.so -s libgazebo_ros_factory.so <?xml version="1.0" ?>
[gzserver-1] 
[ros2-5] Could not contact service /controller_manager/load_controller
[ERROR] [ros2-5]: process has died [pid 16129, exit code 1, cmd 'ros2 control load_controller --set-state configure ackermann_drive_base_controller'].

Appreciate any help.

Asked by Edvard on 2023-05-12 06:24:35 UTC

Comments

Answers