From ed1fbaff900e602810a6b6155f53b711acaede1c Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Wed, 28 Aug 2024 18:31:55 +0200 Subject: [PATCH 1/3] throw an exception when the components aare initially failed to configure or activate --- controller_manager/src/controller_manager.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index b4f18dd90e..cbe7cc256c 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -346,7 +346,13 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript RCLCPP_INFO( get_logger(), "Setting component '%s' to '%s' state.", component.c_str(), state.label().c_str()); - resource_manager_->set_component_state(component, state); + if ( + resource_manager_->set_component_state(component, state) == + hardware_interface::return_type::ERROR) + { + throw std::runtime_error( + "Failed to set the state of the component : " + component + " to " + state.label()); + } components_to_activate.erase(component); } } @@ -370,7 +376,13 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript { rclcpp_lifecycle::State active_state( State::PRIMARY_STATE_ACTIVE, hardware_interface::lifecycle_state_names::ACTIVE); - resource_manager_->set_component_state(component, active_state); + if ( + resource_manager_->set_component_state(component, active_state) == + hardware_interface::return_type::ERROR) + { + throw std::runtime_error( + "Failed to set the state of the component : " + component + " to " + active_state.label()); + } } robot_description_notification_timer_->cancel(); } From 0a7a5df158ceb7261c8e72d388eb32efbffb7a4e Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Fri, 30 Aug 2024 17:53:26 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Bence Magyar --- controller_manager/src/controller_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index cbe7cc256c..37ade5404a 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -351,7 +351,7 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript hardware_interface::return_type::ERROR) { throw std::runtime_error( - "Failed to set the state of the component : " + component + " to " + state.label()); + "Failed to set the initial state of the component : " + component + " to " + state.label()); } components_to_activate.erase(component); } @@ -381,7 +381,7 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript hardware_interface::return_type::ERROR) { throw std::runtime_error( - "Failed to set the state of the component : " + component + " to " + active_state.label()); + "Failed to set the initial state of the component : " + component + " to " + active_state.label()); } } robot_description_notification_timer_->cancel(); From 51372f81b1081e19927e7989d964971c421bd5b5 Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Fri, 30 Aug 2024 18:37:24 +0200 Subject: [PATCH 3/3] Apply formatting changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Christoph Fröhlich --- controller_manager/src/controller_manager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index 37ade5404a..cdf6677713 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -351,7 +351,8 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript hardware_interface::return_type::ERROR) { throw std::runtime_error( - "Failed to set the initial state of the component : " + component + " to " + state.label()); + "Failed to set the initial state of the component : " + component + " to " + + state.label()); } components_to_activate.erase(component); } @@ -381,7 +382,8 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript hardware_interface::return_type::ERROR) { throw std::runtime_error( - "Failed to set the initial state of the component : " + component + " to " + active_state.label()); + "Failed to set the initial state of the component : " + component + " to " + + active_state.label()); } } robot_description_notification_timer_->cancel();