From 650c818e28701aebc6e65bdcd7a8eed5a52ee22c Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Tue, 4 Mar 2025 17:09:20 +0100 Subject: [PATCH] Add more informative message if the requested controller to activate is not in the desired state --- controller_manager/src/controller_manager.cpp | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index 4e5ff1ca0c..989906210d 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -1277,11 +1277,25 @@ controller_interface::return_type ControllerManager::switch_controller_cb( controller_interface::return_type status = controller_interface::return_type::OK; // if controller is not inactive then do not do any following-controllers checks - if (!is_controller_inactive(controller_it->c)) + if (is_controller_unconfigured(*controller_it->c)) { message = "Controller with name '" + controller_it->info.name + - "' is not inactive so its following controllers do not have to be checked, because " - "it cannot be activated."; + "' is in 'unconfigured' state. The controller needs to be configured to be in " + "'inactive' state before it can be checked and activated."; + RCLCPP_WARN(get_logger(), "%s", message.c_str()); + status = controller_interface::return_type::ERROR; + } + else if (is_controller_active(controller_it->c)) + { + message = "Controller with name '" + controller_it->info.name + "' is already active."; + RCLCPP_WARN(get_logger(), "%s", message.c_str()); + status = controller_interface::return_type::ERROR; + } + else if (!is_controller_inactive(controller_it->c)) + { + message = "Controller with name '" + controller_it->info.name + + "' is not in 'inactive' state. The controller needs to be in 'inactive' state " + "before it can be checked and activated."; RCLCPP_WARN(get_logger(), "%s", message.c_str()); status = controller_interface::return_type::ERROR; }