@@ -94,7 +94,9 @@ class RosServiceNode : public BT::ActionNodeBase
9494  static  PortsList providedBasicPorts (PortsList addition)
9595  {
9696    PortsList basic = {
97-       InputPort<std::string>(" service_name"  , " __default__placeholder__"  , " Service name"  )
97+       InputPort<std::string>(" service_name"  , " __default__placeholder__"  , " Service name"  ),
98+       InputPort<int >(" server_timeout"  , " Service server goal timeout (mSec)"  ),
99+       InputPort<int >(" wait_for_server_timeout"  , " Service server discovery timeout (mSec)"  )
98100    };
99101    basic.insert (addition.begin (), addition.end ());
100102    return  basic;
@@ -133,7 +135,7 @@ class RosServiceNode : public BT::ActionNodeBase
133135   * It must return either SUCCESS or FAILURE. 
134136   */  
135137  virtual  BT::NodeStatus onFailure (ServiceNodeErrorCode /* error*/  )
136-   {  
138+   {
137139    return  NodeStatus::FAILURE;
138140  }
139141
@@ -142,8 +144,8 @@ class RosServiceNode : public BT::ActionNodeBase
142144  std::shared_ptr<rclcpp::Node> node_;
143145  std::string prev_service_name_;
144146  bool  service_name_may_change_ = false ;
145-   const   std::chrono::milliseconds service_timeout_;
146-   const   std::chrono::milliseconds wait_for_service_timeout_;
147+   std::chrono::milliseconds service_timeout_;
148+   std::chrono::milliseconds wait_for_service_timeout_;
147149
148150private: 
149151
@@ -174,8 +176,37 @@ template<class T> inline
174176  service_timeout_(params.server_timeout),
175177  wait_for_service_timeout_(params.wait_for_server_timeout)
176178{
179+   //  update service_timeout_ if set throuh port and greater than 0
180+   auto  portIt = config ().input_ports .find (" server_timeout"  );
181+   if (portIt != config ().input_ports .end ())
182+   {
183+     int  timeout = 0 ;
184+     getInput (" server_timeout"  , timeout);
185+     if (timeout > 0 ) {
186+       service_timeout_ = std::chrono::milliseconds (timeout);
187+     }
188+     else  {
189+       RCLCPP_WARN (node_->get_logger (), " %s: Port `server_timeout` is not greater than zero. " 
190+                   " Defaulting to %d mSec."  , name ().c_str (), static_cast <int >(service_timeout_.count ()));
191+     }
192+   }
193+   //  update wait_for_service_timeout_ if set throuh port and greater than 0
194+   portIt = config ().input_ports .find (" wait_for_server_timeout"  );
195+   if (portIt != config ().input_ports .end ())
196+   {
197+     int  timeout = 0 ;
198+     getInput (" wait_for_server_timeout"  , timeout);
199+     if (timeout > 0 ) {
200+       wait_for_service_timeout_ = std::chrono::milliseconds (timeout);
201+     }
202+     else  {
203+       RCLCPP_WARN (node_->get_logger (), " %s: Port `wait_for_server_timeout` is not greater than zero. " 
204+                   " Defaulting to %d mSec."  , name ().c_str (), static_cast <int >(wait_for_service_timeout_.count ()));
205+     }
206+   }
207+ 
177208  //  check port remapping
178-   auto   portIt = config ().input_ports .find (" service_name"  );
209+   portIt = config ().input_ports .find (" service_name"  );
179210  if (portIt != config ().input_ports .end ())
180211  {
181212    const  std::string& bb_service_name = portIt->second ;
0 commit comments