-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add namespaced controllers #1074
base: master
Are you sure you want to change the base?
Add namespaced controllers #1074
Conversation
Hello @ipa-cmh, Can you explain a bit on your current usecase? I would like to understand better which limitations you are planning to address. Thank you, |
We are working on systems that will have 10 - 100 devices to control. From simple IO devices and single servos to robot systems (the general machines you find in automation) and there will be mutiple devices of the same kind in one machine. We will also have machines with different variations of devices. Conseuqently, we want to standardise the interface to the different devices via namespaces. Currently, we have to options to do that. a) one controller manager per device and setting a namespace for the controller manager We want to avoid a) because it would lead to hundreds of unnecessary threads and have negatie performance impact. Therefore, c) seems to be a good solution. We can give controllers namespaces independent of the controller manager. We are able to freely define how many controller managers we run to manage hardware and controllers. To me, it simply makes sense, that the namespace of the controller should be independent of the namespace of the controller manager. I usually would choose the number of control loops (controller managers) depending on the available RT cores. However my application should not need to know on which controller manager the currently used controller runs, but rather which device it belongs to. This is what an example system would look like:
The operation_mode_manager is basically a more intelligent spawner that spawns and enables controllers for a specific device and also does some monitoring. The system_operation_mode_manager takes care of operation mode of the system (i.e. the mode of the different devices). For multiple devices otf the same type, we can just feed a namespace and the same configuration file to the operation mode manager (which will load the necessary parameters into the controller manager). It is certainly possible to implement this without namespacing support, but it would just be harder. Having namespacing available just gives everyone more freedom in designing their ROS 2 driver/controller interfaces. |
I'll add some tests in the next days. |
Okay, I have taken existing namespace test as base and created the following tests:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, I find the idea quite nice, but we have to clean up and clarify some more details in this PR.
@@ -68,6 +68,64 @@ bool controller_name_compare(const controller_manager::ControllerSpec & a, const | |||
return a.info.name == name; | |||
} | |||
|
|||
// Pass in full_name and the namespace of the manager node, receive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this sentence complete?
} | ||
|
||
RCLCPP_INFO( | ||
rclcpp::get_logger("split_namespace_and_name"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use controller manager's logger
rclcpp::get_logger("split_namespace_and_name"), | |
get_logger(), |
controller_manager/test/test_controller_manager_with_namespaced_controllers.cpp
Outdated
Show resolved
Hide resolved
controller_manager/test/test_controller_manager_with_namespaced_controllers.cpp
Outdated
Show resolved
Hide resolved
controller_manager/test/test_controller_manager_with_namespaced_controllers.cpp
Outdated
Show resolved
Hide resolved
controller_manager/test/test_controller_manager_with_namespaced_controllers.cpp
Outdated
Show resolved
Hide resolved
controller_manager/test/test_controller_manager_with_namespaced_controllers.cpp
Outdated
Show resolved
Hide resolved
Hello @ipa-cmh, Thank you for such a nice explanation. I think your use case is valid, and I like the idea of the namespacing to be able to solve this. It's so nice to see tests. ros2_control/controller_manager/src/controller_manager.cpp Lines 1202 to 1205 in 228373a
However, I see a possible issue that the ros2_control/controller_manager/src/controller_manager.cpp Lines 157 to 160 in 228373a
In the above case, the interfaces will have the controller name without the namespace, and then when comparing it will be compared with the total name. This might probably affect the name-spaced controller chaining. I think it would be nice to add a field called namespace in the ros2_control/hardware_interface/include/hardware_interface/controller_info.hpp Lines 27 to 37 in 228373a
What do you think? Best Regards, |
Sorry for the long radio silence some family things came in between. @saikishor @destogl |
Co-authored-by: Dr. Denis <[email protected]>
Co-authored-by: Dr. Denis <[email protected]>
Co-authored-by: Dr. Denis <[email protected]>
Co-authored-by: Dr. Denis <[email protected]>
Co-authored-by: Dr. Denis <[email protected]>
Co-authored-by: Dr. Denis <[email protected]>
Co-authored-by: Dr. Denis <[email protected]>
Co-authored-by: Dr. Denis <[email protected]>
This pull request is in conflict. Could you fix it @ipa-cmh? |
This pull request is in conflict. Could you fix it @hellantos? |
Enabling namespacing for controllers.
Currently, it is not possible to set a controller specific namespace. Controllers simply add the namespace of the controller manager if it has one. Having a bit more flexibility can be pretty handy in larger systems.
This PR enables setting the namespace when loading a controller by name, by the following naming conventions.
It should not have any effect on existing systems.
controller name starts with '/'
controller name starts without '/'
If the passed in name starts with a '/' it is assumed to be relative to the root namespace. In this case the parameter
is the full name with the initial '/' removed and all other '/' replaced with '.'.
To send us a pull request, please:
colcon test
andpre-commit run
(requires you to install pre-commit bypip3 install pre-commit
)