@@ -963,6 +963,16 @@ controller_interface::return_type ControllerManager::switch_controller(
963963
964964 const std::vector<ControllerSpec> & controllers = rt_controllers_wrapper_.get_updated_list (guard);
965965
966+ LABEL_CHECK_REQUEST:
967+ // Set these interfaces as unavailable when clearing requests to avoid leaving them in available
968+ // state without the controller being in active state
969+ for (const auto & controller_name : to_chained_mode_request_)
970+ {
971+ resource_manager_->make_controller_reference_interfaces_unavailable (controller_name);
972+ }
973+ to_chained_mode_request_.clear ();
974+ from_chained_mode_request_.clear ();
975+
966976 // if a preceding controller is deactivated, all first-level controllers should be switched 'from'
967977 // chained mode
968978 propagate_deactivation_of_chained_mode (controllers);
@@ -1006,7 +1016,7 @@ controller_interface::return_type ControllerManager::switch_controller(
10061016 // remove controller that can not be activated from the activation request and step-back
10071017 // iterator to correctly step to the next element in the list in the loop
10081018 activate_request_.erase (ctrl_it);
1009- --ctrl_it ;
1019+ goto LABEL_CHECK_REQUEST ;
10101020 }
10111021 if (strictness == controller_manager_msgs::srv::SwitchController::Request::STRICT)
10121022 {
@@ -1052,7 +1062,7 @@ controller_interface::return_type ControllerManager::switch_controller(
10521062 // remove controller that can not be activated from the activation request and step-back
10531063 // iterator to correctly step to the next element in the list in the loop
10541064 deactivate_request_.erase (ctrl_it);
1055- --ctrl_it ;
1065+ goto LABEL_CHECK_REQUEST ;
10561066 }
10571067 if (strictness == controller_manager_msgs::srv::SwitchController::Request::STRICT)
10581068 {
0 commit comments