ros-controls / ros2_control

Generic and simple controls framework for ROS 2
https://control.ros.org
Apache License 2.0
504 stars 300 forks source link

Naming controller_manager causes multiple controller_manager to spawn and spawner node fail #1684

Closed Combinacijus closed 2 months ago

Combinacijus commented 2 months ago

Description

There seems to be an issue when explicitly naming the ros2_control_node (controller_manager) node in a launch file. This issue leads to multiple instances of controller_manager being spawned, causing controller configuration to fail with an error:

[spawner-3] [INFO] [1723768805.754605949] [spawner_forward_position_controller]: Loaded forward_position_controller
[ros2_control_node-1] [INFO] [1723768805.756219195] [controller_manager]: Configuring controller 'forward_position_controller'
[ros2_control_node-1] [ERROR] [1723768805.756338859] [controller_manager]: 'joints' parameter was empty
[ros2_control_node-1] [WARN] [1723768805.756353356] [controller_manager]: Error occurred while doing error handling.
[ros2_control_node-1] [ERROR] [1723768805.756366772] [controller_manager]: After configuring, controller 'forward_position_controller' is in state 'unconfigured' , expected inactive.
[spawner-3] [ERROR] [1723768805.757000131] [spawner_forward_position_controller]: Failed to configure controller
ros2 node list
WARNING: Be aware that are nodes in the graph that share an exact name, this can have unintended side effects.
/controller_manager
/controller_manager
/controller_manager

image

Steps to Reproduce

Download and checkout correct branch

git clone https://github.com/ros-controls/ros2_control_demos.git
git checkout humble
colcon build

Launch (should work without problems)

source install/setup.bash
ros2 launch ros2_control_demo_example_1 rrbot.launch.py

Edit launch file and add name="controller_manager",

control_node = Node(
    package="controller_manager",
    executable="ros2_control_node",
    parameters=[robot_controllers],
    name="controller_manager",
    output="both",
    remappings=[
        ("~/robot_description", "/robot_description"),
    ],

Launch again

ros2 launch ros2_control_demo_example_1 rrbot.launch.py

Now Failed to configure controller error in red should be present on launch (but it's scrolled up due to verbose output) image

Discussion

It seems strange that giving a name to any node would break it, especially when given name is exact same as default one. Moreover there's no error saying that it can't be named so it's very hard to debug as error points to other unrelated stuff.

christophfroehlich commented 2 months ago

The problem here is that the name is used for all controllers, which are created as node by the controller_manager (which is instantiated from the ros2_control_node). It does not make sense to set the name here, but I agree that this has strange effects. Not sure if the rclcpp API supports overriding the name remapping from the our side