Skip to content

Commit

Permalink
control reference interface availability based on the controller state
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Aug 23, 2023
1 parent 2e98a91 commit 9191939
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,11 @@ void ControllerManager::deactivate_controllers(
{
const auto new_state = controller->get_node()->deactivate();
controller->release_interfaces();
// if it is a chainable controller, make the reference interfaces unavailable on deactivation
if (controller->is_chainable())
{
resource_manager_->make_controller_reference_interfaces_unavailable(request);
}
if (new_state.id() != lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE)
{
RCLCPP_ERROR(
Expand Down Expand Up @@ -1405,18 +1410,10 @@ void ControllerManager::switch_chained_mode(
auto controller = found_it->c;
if (!is_controller_active(*controller))
{
if (controller->set_chained_mode(to_chained_mode))
{
if (to_chained_mode)
{
resource_manager_->make_controller_reference_interfaces_available(request);
}
else
{
resource_manager_->make_controller_reference_interfaces_unavailable(request);
}
}
else
// if it is a chainable controller, make the reference interfaces available on preactivation
// (This is needed when you activate a couple of chainable controller altogether)
resource_manager_->make_controller_reference_interfaces_available(request);
if (!controller->set_chained_mode(to_chained_mode))
{
RCLCPP_ERROR(
get_logger(),
Expand Down Expand Up @@ -1550,6 +1547,12 @@ void ControllerManager::activate_controllers(
lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE);
}

// if it is a chainable controller, make the reference interfaces available on activation
if (controller->is_chainable())
{
resource_manager_->make_controller_reference_interfaces_available(request);
}

if (controller->is_async())
{
async_controller_threads_.at(controller_name)->activate();
Expand Down

0 comments on commit 9191939

Please sign in to comment.