From 18f8ff5690a45244af09e7ac0dffe5496eb0964d Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Mon, 7 Oct 2024 20:32:32 +0200 Subject: [PATCH 1/3] [CM] Throw an exception when the components initially fail to be in the required state (#1729) (cherry picked from commit 1c7a5d1cd0f4ae0da26c62459a4bf0611e3c95a7) # Conflicts: # controller_manager/src/controller_manager.cpp --- controller_manager/src/controller_manager.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index 85aee476a8..0f99c878e4 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -395,7 +395,14 @@ 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 initial state of the component : " + component + " to " + + state.label()); + } components_to_activate.erase(component); } } @@ -446,6 +453,7 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript "'hardware_components_initial_state' parameter structure."); rclcpp_lifecycle::State active_state( State::PRIMARY_STATE_ACTIVE, hardware_interface::lifecycle_state_names::ACTIVE); +<<<<<<< HEAD for (const auto & component : activate_components_on_start) { resource_manager_->set_component_state(component, active_state); @@ -460,6 +468,15 @@ 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 initial state of the component : " + component + " to " + + active_state.label()); +>>>>>>> 1c7a5d1 ([CM] Throw an exception when the components initially fail to be in the required state (#1729)) } } } From 53ebb0525d66c5b6831c93c03a2339fe9ad382f9 Mon Sep 17 00:00:00 2001 From: Bence Magyar Date: Wed, 9 Oct 2024 16:04:23 +0100 Subject: [PATCH 2/3] fix conflict --- controller_manager/src/controller_manager.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index 0f99c878e4..e8e2ff1770 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -453,7 +453,6 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript "'hardware_components_initial_state' parameter structure."); rclcpp_lifecycle::State active_state( State::PRIMARY_STATE_ACTIVE, hardware_interface::lifecycle_state_names::ACTIVE); -<<<<<<< HEAD for (const auto & component : activate_components_on_start) { resource_manager_->set_component_state(component, active_state); @@ -467,16 +466,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 initial state of the component : " + component + " to " + - active_state.label()); ->>>>>>> 1c7a5d1 ([CM] Throw an exception when the components initially fail to be in the required state (#1729)) + if ( + resource_manager_->set_component_state(component, active_state) == + hardware_interface::return_type::ERROR) + { + throw std::runtime_error( + "Failed to set the initial state of the component : " + component + " to " + + active_state.label()); } } } From 57d0ebddda8df0d21c853529ec98072b2cb1c2eb Mon Sep 17 00:00:00 2001 From: Bence Magyar Date: Wed, 9 Oct 2024 16:07:37 +0100 Subject: [PATCH 3/3] } --- controller_manager/src/controller_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index e8e2ff1770..ab89c8760c 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -473,6 +473,7 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript throw std::runtime_error( "Failed to set the initial state of the component : " + component + " to " + active_state.label()); + } } } }