Skip to content

Commit

Permalink
reset the async variables upon activation to work post exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Nov 6, 2024
1 parent d714e8b commit d7efc8c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion controller_interface/src/controller_interface_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ return_type ControllerInterfaceBase::init(
});

node_->register_on_activate(
std::bind(&ControllerInterfaceBase::on_activate, this, std::placeholders::_1));
[this](const rclcpp_lifecycle::State & previous_state) -> CallbackReturn
{
if (is_async() && async_handler_ && async_handler_->is_running())
{
// This is needed if it is disabled due to a thrown exception in the async callback thread
async_handler_->reset_variables();
}
return on_activate(previous_state);
});

node_->register_on_deactivate(
std::bind(&ControllerInterfaceBase::on_deactivate, this, std::placeholders::_1));
Expand Down

0 comments on commit d7efc8c

Please sign in to comment.