Skip to content

Commit 0c06c93

Browse files
committed
move request initialization to the constructor
Signed-off-by: Daisuke Sato <[email protected]>
1 parent 29ea9f4 commit 0c06c93

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

nav2_behavior_tree/include/nav2_behavior_tree/bt_service_node.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class BtServiceNode : public BT::SyncActionNode
4545
getInput("service_name", service_name_);
4646
service_client_ = node_->create_client<ServiceT>(service_name_);
4747

48+
// Make a request for the service without parameter
49+
request_ = std::make_shared<typename ServiceT::Request>();
50+
4851
// Make sure the server is actually there before continuing
4952
RCLCPP_INFO(
5053
node_->get_logger(), "Waiting for \"%s\" service",
@@ -83,7 +86,6 @@ class BtServiceNode : public BT::SyncActionNode
8386
// The main override required by a BT service
8487
BT::NodeStatus tick() override
8588
{
86-
request_ = std::make_shared<typename ServiceT::Request>();
8789
on_tick();
8890
auto future_result = service_client_->async_send_request(request_);
8991
return check_future(future_result);

0 commit comments

Comments
 (0)