Skip to content

Commit 5504b6a

Browse files
authored
Improve list hardware components output and code for better readability. (backport #1060) (#1061)
1 parent fd26cf3 commit 5504b6a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ros2controlcli/ros2controlcli/verb/list_hardware_components.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,18 @@ def main(self, *, args):
3838
hardware_components = list_hardware_components(node, args.controller_manager)
3939

4040
for idx, component in enumerate(hardware_components.component):
41-
print(f'Hardware Component {idx}\n\tname: {component.name}\n\ttype: {component.type}')
41+
print(f'Hardware Component {idx+1}\n\tname: {component.name}\n\ttype: {component.type}')
4242
if hasattr(component, 'plugin_name'):
4343
plugin_name = component.plugin_name
44+
# Keep compatibility to the obsolete filed name in Humble
45+
elif hasattr(component, 'class_type'):
46+
plugin_name = component.class_type
4447
else:
4548
plugin_name = f'{bcolors.WARNING}plugin name missing!{bcolors.ENDC}'
4649

47-
print(f'\tplugin name: {plugin_name}\n\tstate: id={component.state.id} label={component.state.label}\n\tcommand interfaces')
50+
print(f'\tplugin name: {plugin_name}\n'
51+
f'\tstate: id={component.state.id} label={component.state.label}\n'
52+
f'\tcommand interfaces')
4853
for cmd_interface in component.command_interfaces:
4954

5055
if cmd_interface.is_available:

0 commit comments

Comments
 (0)