ros2_control_demos: Could not contact service /controller_manager/list_controllers

I’ve followed the demo for the RRBot and all works fine until I try to list the controllers. I get this message:

Could not contact service /controller_manager/list_controllers

I also get the same message when calling:

- ros2 control list_hardware_interfaces
- ros2 control list_controller_types
- ros2 control list_controllers

I haven’t tested the rest of the services but I’m guessing that the controller_manager isn’t online or not launched properly.

Furthermore I’ve also tried to run a ros2_control launch file for ODrive with a basic velocity controller (https://github.com/Factor-Robotics/odrive_ros2_control.git) and I also get a related error from the controller_manager. It is unable to contact the service.

ros2 launch odrive_bringup odrive.launch.py       
[INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2021-09-14-16-40-07-155005-ubuntu-2816
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [ros2_control_node-1]: process started with pid [2820]
[INFO] [robot_state_publisher-2]: process started with pid [2822]
[INFO] [spawner.py-3]: process started with pid [2824]
[INFO] [spawner.py-4]: process started with pid [2826]
[robot_state_publisher-2] Parsing robot urdf xml string.
[robot_state_publisher-2] Link link0 had 0 children
[robot_state_publisher-2] [INFO] [1631637608.196999177] [robot_state_publisher]: got segment link0
[robot_state_publisher-2] [INFO] [1631637608.197494333] [robot_state_publisher]: got segment world
[spawner.py-3] Traceback (most recent call last):
[spawner.py-3]   File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 186, in <module>
[spawner.py-3]     sys.exit(main())
[spawner.py-3]   File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 109, in main
[spawner.py-3]     if is_controller_loaded(node, controller_manager_name, controller_name):
[spawner.py-3]   File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 51, in is_controller_loaded
[spawner.py-3]     controllers = list_controllers(node, controller_manager).controller
[spawner.py-3]   File "/opt/ros/foxy/lib/python3.8/site-packages/controller_manager/controller_manager_services.py", line 49, in list_controllers
[spawner.py-3]     return service_caller(node, f'{controller_manager_name}/list_controllers',
[spawner.py-3]   File "/opt/ros/foxy/lib/python3.8/site-packages/controller_manager/controller_manager_services.py", line 29, in service_caller
[spawner.py-3]     raise RuntimeError(f'Could not contact service {service_name}')
[spawner.py-3] RuntimeError: Could not contact service /controller_manager/list_controllers
[spawner.py-4] Traceback (most recent call last):
[spawner.py-4]   File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 186, in <module>
[spawner.py-4]     sys.exit(main())
[spawner.py-4]   File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 109, in main
[spawner.py-4]     if is_controller_loaded(node, controller_manager_name, controller_name):
[spawner.py-4]   File "/opt/ros/foxy/lib/controller_manager/spawner.py", line 51, in is_controller_loaded
[spawner.py-4]     controllers = list_controllers(node, controller_manager).controller
[spawner.py-4]   File "/opt/ros/foxy/lib/python3.8/site-packages/controller_manager/controller_manager_services.py", line 49, in list_controllers
[spawner.py-4]     return service_caller(node, f'{controller_manager_name}/list_controllers',
[spawner.py-4]   File "/opt/ros/foxy/lib/python3.8/site-packages/controller_manager/controller_manager_services.py", line 29, in service_caller
[spawner.py-4]     raise RuntimeError(f'Could not contact service {service_name}')
[spawner.py-4] RuntimeError: Could not contact service /controller_manager/list_controllers
[ERROR] [spawner.py-3]: process has died [pid 2824, exit code 1, cmd '/opt/ros/foxy/lib/controller_manager/spawner.py joint_state_broadcaster --controller-manager /controller_manager --ros-args'].
[ERROR] [spawner.py-4]: process has died [pid 2826, exit code 1, cmd '/opt/ros/foxy/lib/controller_manager/spawner.py joint0_velocity_controller -c /controller_manager --ros-args'].

Looking at discussions about this error I found a discussion talking about the stability of the spawn.py of the controller_manager https://github.com/ros-controls/ros2_control/issues/475

They mention it could be because it’s running on a slower PC but I’m running the same code on raspberry pi and my laptop PC with powerful specs that shouldn’t be a problem and yet both platforms yield the same result.

I assume it’s a bug but have no clue how to debug this issue. Any help is deeply appreciated.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 24 (6 by maintainers)

Most upvoted comments

That however sir may be something we are able to assess very soon! @destogl here’s another example of why we need component lifecycles 😄

My issue was I had to add this

    ros2_controllers_path = os.path.join(
        get_package_share_directory("robot_moveit_config"),
        "config",
        "ros2_controllers.yaml",
    )

    ros2_control_node = Node(
        package="controller_manager",
        executable="ros2_control_node",
        parameters=[ros2_controllers_path],
        remappings=[
            ("/controller_manager/robot_description", "/robot_description"),
        ],
        output="log",
    )

in my launch file

Hello all, an update, I have resolved the issue. The main problems were incorrect use of the gazebo_ros2_control plug in, after I tried this everything clicked:

  <!-- ROS 2 Control -->
  <ros2_control name="elevator_hw" type="system">
    <hardware>
      <plugin>gazebo_ros2_control/GazeboSystem</plugin> 
    </hardware>
    <joint name="elevator_joint">
      <command_interface name="position"/>
      <state_interface name="position"/>
    </joint>
  </ros2_control>

 <!-- Gazebo Plugins -->
  <gazebo>
    <plugin name="gazebo_ros2_control" filename="libgazebo_ros2_control.so">
        <parameters>$(find my_bot)/config/elevator_controllers.yaml</parameters>
    </plugin>	
  </gazebo>

Not sure what you are running but I’d try removing the spawners from your main launch file and first letting the rest start up, then inspecting if the controller_manager services are available.

The spawner script has a timeout you could change but the default is 10s which I think is fairly generous…