Skip to content

Commit

Permalink
Add more informative message if the requested controller to activate …
Browse files Browse the repository at this point in the history
…is not in the desired state
  • Loading branch information
saikishor committed Mar 4, 2025
1 parent a47fd6e commit 650c818
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,11 +1277,25 @@ controller_interface::return_type ControllerManager::switch_controller_cb(
controller_interface::return_type status = controller_interface::return_type::OK;

// if controller is not inactive then do not do any following-controllers checks
if (!is_controller_inactive(controller_it->c))
if (is_controller_unconfigured(*controller_it->c))
{
message = "Controller with name '" + controller_it->info.name +
"' is not inactive so its following controllers do not have to be checked, because "
"it cannot be activated.";
"' is in 'unconfigured' state. The controller needs to be configured to be in "
"'inactive' state before it can be checked and activated.";
RCLCPP_WARN(get_logger(), "%s", message.c_str());
status = controller_interface::return_type::ERROR;
}
else if (is_controller_active(controller_it->c))
{
message = "Controller with name '" + controller_it->info.name + "' is already active.";
RCLCPP_WARN(get_logger(), "%s", message.c_str());
status = controller_interface::return_type::ERROR;
}
else if (!is_controller_inactive(controller_it->c))
{
message = "Controller with name '" + controller_it->info.name +
"' is not in 'inactive' state. The controller needs to be in 'inactive' state "
"before it can be checked and activated.";
RCLCPP_WARN(get_logger(), "%s", message.c_str());
status = controller_interface::return_type::ERROR;
}
Expand Down

0 comments on commit 650c818

Please sign in to comment.