joshnewans / articubot_one

249 stars 219 forks source link

Controller Manager Services Not Available in ROS2 Humble #30

Closed joeDonuts closed 1 month ago

joeDonuts commented 2 months ago

I am experiencing an issue where the controller_manager services are not available, which prevents any interaction with hardware interfaces. Despite installing all necessary dependencies, reinstalling them, and ensuring that the ros2_control_node is activated first in the launch file, the problem persists. I have tested this on both my custom workspace and the publicly available articubot_one repository.

Steps to Reproduce:

Set up the environment with ROS2 Humble on Ubuntu 22.04.4 LTS.
Install all necessary dependencies for controller_manager.
Attempt to start the controller_manager via a launch file where ros2_control_node is prioritized.
Use the command ros2 control list_hardware_interfaces.

Expected Outcome: The controller_manager services should be available, and the command ros2 control list_hardware_interfaces should list the available hardware interfaces.

Actual Outcome: The command ros2 control list_hardware_interfaces fails with an error: "Could not contact service /controller_manager/list_hardware_interfaces."

Both the custom workspace and the articubot_one repository exhibit the same issue under the same conditions. Here is the content of my launch file for reference import os from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node

def generate_launch_description(): package_name = 'firebot'

# Declare launch argument for simulation time
use_sim_time = DeclareLaunchArgument(
    'use_sim_time', default_value='true',
    description='Use simulation (Gazebo) clock if true')

# Include the robot_state_publisher launch file, force sim time to be enabled
rsp = IncludeLaunchDescription(
    PythonLaunchDescriptionSource(
        os.path.join(get_package_share_directory(package_name), 'launch', 'display.launch.py')
    ),
    launch_arguments={'use_sim_time': LaunchConfiguration('use_sim_time'), 'use_ros2_control': 'true'}.items()
)

# Include the Gazebo launch file
gazebo = IncludeLaunchDescription(
    PythonLaunchDescriptionSource(
        os.path.join(get_package_share_directory('gazebo_ros'), 'launch', 'gazebo.launch.py')
    )
)

# Node to spawn the robot in Gazebo
spawn_entity = Node(
    package='gazebo_ros', executable='spawn_entity.py',
    arguments=['-topic', 'robot_description', '-entity', 'firebot'],
    output='screen'
)

# Node for ros2 control
ros2_control_node = Node(
    package="controller_manager",
    executable="ros2_control_node",
    parameters=[
        os.path.join(get_package_share_directory(package_name), 'src','description', 'firebot_description.urdf.xacro'),
        os.path.join(get_package_share_directory(package_name), 'config', 'my_controllers.yaml')
    ],
    output='screen'
)

# Node for differential drive spawner
diff_drive_spawner = Node(
    package="controller_manager",
    executable="spawner",
    arguments=["diff_cont"],
    output='screen'
)

# Node for joint broadcaster spawner
joint_broad_spawner = Node(
    package="controller_manager",
    executable="spawner",
    arguments=["joint_broad"],
    output='screen'
)

# Combine all components into a LaunchDescription
return LaunchDescription([
    use_sim_time,
    rsp,
    gazebo,
    spawn_entity,
    ros2_control_node,
    diff_drive_spawner,
    joint_broad_spawner
])

Error: [spawner-6] [INFO] [1714997730.121901418] [spawner_diff_cont]: Waiting for '/controller_manager' services to be available [spawner-7] [INFO] [1714997730.152824682] [spawner_joint_broad]: Waiting for '/controller_manager' services to be available [spawner-6] [INFO] [1714997732.141807404] [spawner_diff_cont]: Waiting for '/controller_manager' services to be available [spawner-7] [INFO] [1714997732.176311279] [spawner_joint_broad]: Waiting for '/controller_manager' services to be available [spawner-6] [INFO] [1714997734.166914743] [spawner_diff_cont]: Waiting for '/controller_manager' services to be available [spawner-7] [INFO] [1714997734.205966275] [spawner_joint_broad]: Waiting for '/controller_manager' services to be available [spawner-6] [INFO] [1714997736.189367049] [spawner_diff_cont]: Waiting for '/controller_manager' services to be available [spawner-7] [INFO] [1714997736.224687879] [spawner_joint_broad]: Waiting for '/controller_manager' services to be available [spawner-6] [ERROR] [1714997738.214785799] [spawner_diff_cont]: Controller manager not available [spawner-7] [ERROR] [1714997738.257940291] [spawner_joint_broad]: Controller manager not available [ERROR] [spawner-6]: process has died [pid 15294, exit code 1, cmd '/opt/ros/humble/lib/controller_manager/spawner diff_cont --ros-args']. [ERROR] [spawner-7]: process has died [pid 15296, exit code 1, cmd '/opt/ros/humble/lib/controller_manager/spawner joint_broad --ros-args'].

Could anyone please help identify what might be causing this issue or suggest further debugging steps?

joeDonuts commented 1 month ago

It turns out I encountered a problem in my CMakeLists.txt file due to discrepancies between two different sources I was following: the Articulated Robotics guide and the official ROS 2 documentation. Each source provided different codes and setups, which led to conflicts in my configuration.

For those of you experiencing similar issues, here is the CMakeLists.txt code that resolved my problem. I'll be closing this issue now, but feel free to reference the code below if you're following a similar path. CMakeLists.txt

Shuke-rrrw commented 1 month ago

Hi, I have the same issue,but I don't understand how can I solve it,could you please tell me more details about your solution?

AnhHazz commented 1 month ago

Hi, I have the same issue,but I don't understand how can I solve it,could you please tell me more details about your solution?

I see that his solution is add dependencies to CMakeList.txt file like this: find_package(rclcpp REQUIRED) find_package(hardware_interface REQUIRED) find_package(rclcpp_lifecycle REQUIRED) And add config to share folder install( DIRECTORY src launch rviz config # Add config here DESTINATION share/${PROJECT_NAME}) try that and see whether it solves yours