@@ -1980,7 +1980,7 @@ controller_interface::return_type ControllerManager::switch_controller_cb(
19801980
19811981 if (
19821982 check_for_interfaces_availability_to_activate (
1983- controllers, switch_params_.activate_request , message) !=
1983+ controllers, switch_params_.activate_request , strictness, message) !=
19841984 controller_interface::return_type::OK)
19851985 {
19861986 clear_requests ();
@@ -2456,7 +2456,7 @@ void ControllerManager::activate_controllers(
24562456 }
24572457 // Now prepare and perform the stop interface switching as this is needed for exclusive
24582458 // interfaces
2459- if (
2459+ else if (
24602460 !failed_controllers_command_interfaces.empty () &&
24612461 (!resource_manager_->prepare_command_mode_switch ({}, failed_controllers_command_interfaces) ||
24622462 !resource_manager_->perform_command_mode_switch ({}, failed_controllers_command_interfaces)))
@@ -2963,6 +2963,8 @@ void ControllerManager::manage_switch()
29632963 switch_params_.deactivate_command_interface_request ))
29642964 {
29652965 RCLCPP_ERROR (get_logger (), " Error while performing mode switch." );
2966+ // If the hardware switching fails, there is no point in continuing to switch controllers
2967+ return ;
29662968 }
29672969 execution_time_.switch_perform_mode_time =
29682970 std::chrono::duration<double , std::micro>(std::chrono::steady_clock::now () - start_time)
@@ -3926,7 +3928,7 @@ void ControllerManager::publish_activity()
39263928
39273929controller_interface::return_type ControllerManager::check_for_interfaces_availability_to_activate (
39283930 const std::vector<ControllerSpec> & controllers, const std::vector<std::string> activation_list,
3929- std::string & message)
3931+ int strictness, std::string & message)
39303932{
39313933 std::vector<std::string> future_unavailable_cmd_interfaces = {};
39323934 for (const auto & controller_name : activation_list)
@@ -3960,7 +3962,9 @@ controller_interface::return_type ControllerManager::check_for_interfaces_availa
39603962 RCLCPP_WARN (get_logger (), " %s" , message.c_str ());
39613963 return controller_interface::return_type::ERROR;
39623964 }
3963- if (ros2_control::has_item (future_unavailable_cmd_interfaces, cmd_itf))
3965+ if (
3966+ ros2_control::has_item (future_unavailable_cmd_interfaces, cmd_itf) &&
3967+ strictness == controller_manager_msgs::srv::SwitchController::Request::STRICT)
39643968 {
39653969 message = fmt::format (
39663970 FMT_COMPILE (
0 commit comments