From 5504b6af9d9911f2869407e6fc364e4f81ac7ce7 Mon Sep 17 00:00:00 2001 From: "Dr. Denis" Date: Tue, 20 Jun 2023 22:17:33 +0200 Subject: [PATCH] Improve list hardware components output and code for better readability. (backport #1060) (#1061) --- .../ros2controlcli/verb/list_hardware_components.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ros2controlcli/ros2controlcli/verb/list_hardware_components.py b/ros2controlcli/ros2controlcli/verb/list_hardware_components.py index a319a09b1b..abce8bfb04 100644 --- a/ros2controlcli/ros2controlcli/verb/list_hardware_components.py +++ b/ros2controlcli/ros2controlcli/verb/list_hardware_components.py @@ -38,13 +38,18 @@ def main(self, *, args): hardware_components = list_hardware_components(node, args.controller_manager) for idx, component in enumerate(hardware_components.component): - print(f'Hardware Component {idx}\n\tname: {component.name}\n\ttype: {component.type}') + print(f'Hardware Component {idx+1}\n\tname: {component.name}\n\ttype: {component.type}') if hasattr(component, 'plugin_name'): plugin_name = component.plugin_name + # Keep compatibility to the obsolete filed name in Humble + elif hasattr(component, 'class_type'): + plugin_name = component.class_type else: plugin_name = f'{bcolors.WARNING}plugin name missing!{bcolors.ENDC}' - print(f'\tplugin name: {plugin_name}\n\tstate: id={component.state.id} label={component.state.label}\n\tcommand interfaces') + print(f'\tplugin name: {plugin_name}\n' + f'\tstate: id={component.state.id} label={component.state.label}\n' + f'\tcommand interfaces') for cmd_interface in component.command_interfaces: if cmd_interface.is_available: