Skip to content

Commit

Permalink
Prevent controller manager from crashing when controller's plugin has…
Browse files Browse the repository at this point in the history
… error during loading. (ros-controls#881)
  • Loading branch information
destogl authored Dec 20, 2022
1 parent dbb6268 commit 57d45c9
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,23 @@ controller_interface::ControllerInterfaceBaseSharedPtr ControllerManager::load_c

controller_interface::ControllerInterfaceBaseSharedPtr controller;

if (loader_->isClassAvailable(controller_type))
try
{
controller = loader_->createSharedInstance(controller_type);
if (loader_->isClassAvailable(controller_type))
{
controller = loader_->createSharedInstance(controller_type);
}
if (chainable_loader_->isClassAvailable(controller_type))
{
controller = chainable_loader_->createSharedInstance(controller_type);
}
}
if (chainable_loader_->isClassAvailable(controller_type))
catch (const pluginlib::CreateClassException e)
{
controller = chainable_loader_->createSharedInstance(controller_type);
RCLCPP_ERROR(
get_logger(), "Error happened during creation of controller '%s' with type '%s':\n%s",
controller_name.c_str(), controller_type.c_str(), e.what());
return nullptr;
}

ControllerSpec controller_spec;
Expand Down

0 comments on commit 57d45c9

Please sign in to comment.