Skip to content

Commit df56d4f

Browse files
committed
to fix the bug in switch_controller, modify the process to retry the check from the beginning whenever there is a change in the (de)activate request (but use goto)
1 parent a863277 commit df56d4f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

controller_manager/src/controller_manager.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)