From 4659d58066e51b47c568c9270a57368443dd13d0 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 30 Aug 2024 16:53:00 +0100 Subject: [PATCH] [ros2controlcli] fix list_controllers when no controllers are loaded (#1721) (#1722) --- 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 a26a1168a1..8367900cd5 100644 --- a/ros2controlcli/ros2controlcli/verb/list_controllers.py +++ b/ros2controlcli/ros2controlcli/verb/list_controllers.py @@ -99,6 +99,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)