Skip to content

Commit 07710f4

Browse files
Merge pull request BehaviorTree#32 from umdlife/feat/expose-timeout
Expose parameter to control timeout on wait_for call
2 parents b8ee381 + 7f14ed4 commit 07710f4

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

behaviortree_ros2/include/behaviortree_ros2/bt_action_node.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ class RosActionNode : public BT::ActionNodeBase
171171
std::string prev_action_name_;
172172
bool action_name_may_change_ = false;
173173
const std::chrono::milliseconds server_timeout_;
174+
const std::chrono::milliseconds wait_for_server_timeout_;
174175

175176
private:
176177

@@ -199,7 +200,8 @@ template<class T> inline
199200
const RosNodeParams &params):
200201
BT::ActionNodeBase(instance_name, conf),
201202
node_(params.nh),
202-
server_timeout_(params.server_timeout)
203+
server_timeout_(params.server_timeout),
204+
wait_for_server_timeout_(params.wait_for_server_timeout)
203205
{
204206
// Three cases:
205207
// - we use the default action_name in RosNodeParams when port is empty
@@ -260,7 +262,7 @@ template<class T> inline
260262

261263
prev_action_name_ = action_name;
262264

263-
bool found = action_client_->wait_for_action_server(server_timeout_);
265+
bool found = action_client_->wait_for_action_server(wait_for_server_timeout_);
264266
if(!found)
265267
{
266268
RCLCPP_ERROR(node_->get_logger(), "%s: Action server with name '%s' is not reachable.",

behaviortree_ros2/include/behaviortree_ros2/bt_service_node.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class RosServiceNode : public BT::ActionNodeBase
143143
std::string prev_service_name_;
144144
bool service_name_may_change_ = false;
145145
const std::chrono::milliseconds service_timeout_;
146+
const std::chrono::milliseconds wait_for_service_timeout_;
146147

147148
private:
148149

@@ -170,7 +171,8 @@ template<class T> inline
170171
const RosNodeParams& params):
171172
BT::ActionNodeBase(instance_name, conf),
172173
node_(params.nh),
173-
service_timeout_(params.server_timeout)
174+
service_timeout_(params.server_timeout),
175+
wait_for_service_timeout_(params.wait_for_server_timeout)
174176
{
175177
// check port remapping
176178
auto portIt = config().input_ports.find("service_name");
@@ -225,7 +227,7 @@ template<class T> inline
225227
service_client_ = node_->create_client<T>(service_name, rmw_qos_profile_services_default, callback_group_);
226228
prev_service_name_ = service_name;
227229

228-
bool found = service_client_->wait_for_service(service_timeout_);
230+
bool found = service_client_->wait_for_service(wait_for_service_timeout_);
229231
if(!found)
230232
{
231233
RCLCPP_ERROR(node_->get_logger(), "%s: Service with name '%s' is not reachable.",

behaviortree_ros2/include/behaviortree_ros2/ros_node_params.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ struct RosNodeParams
3434
// - RosTopicSubNode: name of the topic to subscribe to
3535
std::string default_port_value;
3636

37-
// parameter used only by service client and action clients
37+
// parameters used only by service client and action clients
3838
std::chrono::milliseconds server_timeout = std::chrono::milliseconds(1000);
39+
std::chrono::milliseconds wait_for_server_timeout = std::chrono::milliseconds(500);
3940
};
4041

4142
}

0 commit comments

Comments
 (0)