Skip to content

Commit

Permalink
Modify the BtServiceNode to include an on_success call. (#2481)
Browse files Browse the repository at this point in the history
* Modify the BtServiceNode to include an on_success call.

* PR: Fix linter error by removing trailing whitespaces.

* PR: Rename on_success() to on_completion() to improve understandability.
  • Loading branch information
philison authored Aug 4, 2021
1 parent 3bba684 commit 792893a
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ class BtServiceNode : public BT::ActionNodeBase
{
}

/**
* @brief Function to perform some user-defined operation upon successful
* completion of the service. Could put a value on the blackboard.
* @return BT::NodeStatus Returns SUCCESS by default, user may override to return another value
*/
virtual BT::NodeStatus on_completion()
{
return BT::NodeStatus::SUCCESS;
}

/**
* @brief Check the future and decide the status of BT
* @return BT::NodeStatus SUCCESS if future complete before timeout, FAILURE otherwise
Expand All @@ -158,7 +168,8 @@ class BtServiceNode : public BT::ActionNodeBase
rc = callback_group_executor_.spin_until_future_complete(future_result_, server_timeout_);
if (rc == rclcpp::FutureReturnCode::SUCCESS) {
request_sent_ = false;
return BT::NodeStatus::SUCCESS;
BT::NodeStatus status = on_completion();
return status;
}

if (rc == rclcpp::FutureReturnCode::TIMEOUT) {
Expand Down

0 comments on commit 792893a

Please sign in to comment.