Proposal: extract ros2 interfaces from controller manager into a helper file
extract ros2 pub/sub/services into a ros2_communication helper files.
Motivation:
In a project, we're wrapping controller_manager in a custom scheduler task, essentially re-writing the ros2_control_node
-
Conceptual ambiguity:
ros2_control_nodeis not a node, but an executable specific to the OS scheduler responsible for instantiating and running thecontroller_manager, which IS the node. -
Code Maintainability:
controller_manager.cppfile is hitting 4k LoC, mixes core logic and ROS2 communicaiton (services, publishers, subscribers)
Proposed changes
We propose a simple refactoring with two main objectives:
-
Extract all ROS 2 interfaces and their callback implementations into a helper file
ros2_communication.cpp/hppwhich currentcontroller_manager.hppwould include. -
Rename the current
ros2_control_nodetoros2_control_executableto accurately reflect its function as a system entry point rather than a Node
Notes:
naming is are for discussion, of course
Food for thought, outside of scope of this suggestion:
We could push it a step further and make ControllerManager not inherit from Node at all, and place all ROS-related stuff into ControllerManagerNode class.
Then, as we do with ResourceManager, we'd pass in the necessary node interfaces to it:
- executor (already passed)
- parameters
- logger
- clock
Then the ControlNode would be responsible for ros2 communication, controller manager for controllers and resource manager for hardware.