From d2004083cc969ed14b0bde4011fa3172988c86b3 Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Tue, 27 Aug 2024 14:45:22 +0200 Subject: [PATCH] [ros2controlcli] fix list_controllers when no controllers are loaded (#1721) --- ros2controlcli/ros2controlcli/verb/list_controllers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ros2controlcli/ros2controlcli/verb/list_controllers.py b/ros2controlcli/ros2controlcli/verb/list_controllers.py index 3daf752b8c..b4ebff94cd 100644 --- a/ros2controlcli/ros2controlcli/verb/list_controllers.py +++ b/ros2controlcli/ros2controlcli/verb/list_controllers.py @@ -98,6 +98,10 @@ def main(self, *, args): with NodeStrategy(args) as node: response = list_controllers(node, args.controller_manager) + if not response.controller: + print("No controllers are currently loaded!") + return 0 + # Structure data as table for nicer output col_width_name = max(len(ctrl.name) for ctrl in response.controller) col_width_type = max(len(ctrl.type) for ctrl in response.controller)