File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed
behaviortree_ros2/include/behaviortree_ros2 Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff 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
175176private:
176177
@@ -199,7 +200,8 @@ template<class T> inline
199200 const RosNodeParams ¶ms):
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." ,
Original file line number Diff line number Diff 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
147148private:
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." ,
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments