Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions nav2_behavior_tree/include/nav2_behavior_tree/bt_service_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,19 @@ class BtServiceNode : public BT::SyncActionNode
{
on_tick();
auto future_result = service_client_->async_send_request(request_);
return check_future(future_result);
}

// Fill in service request with information if necessary
virtual void on_tick()
{
request_ = std::make_shared<typename ServiceT::Request>();
}

// Check the future and decide the status of Behaviortree
virtual BT::NodeStatus check_future(
std::shared_future<typename ServiceT::Response::SharedPtr> future_result)
{
rclcpp::executor::FutureReturnCode rc;
rc = rclcpp::spin_until_future_complete(
node_,
Expand All @@ -101,12 +113,6 @@ class BtServiceNode : public BT::SyncActionNode
return BT::NodeStatus::FAILURE;
}

// Fill in service request with information if necessary
virtual void on_tick()
{
request_ = std::make_shared<typename ServiceT::Request>();
}

// An opportunity to do something after
// a timeout waiting for a result that hasn't been received yet
virtual void on_wait_for_result()
Expand Down