Added support for timeouts

This commit is contained in:
Esteve Fernandez 2015-01-08 14:49:47 -08:00
parent 4b290d66e8
commit 3e0621a1ff

View file

@ -44,12 +44,17 @@ public:
{}
std::shared_ptr<typename ServiceT::Response>
send_request(std::shared_ptr<typename ServiceT::Request> &req)
send_request(std::shared_ptr<typename ServiceT::Request> &req, long timeout=10)
{
::ros_middleware_interface::send_request(client_handle_, req.get());
std::shared_ptr<typename ServiceT::Response> res = std::make_shared<typename ServiceT::Response>();
::ros_middleware_interface::receive_response(client_handle_, res.get());
bool received = ::ros_middleware_interface::receive_response(client_handle_, res.get(), timeout);
if(!received)
{
// TODO: use custom exception
throw std::runtime_error("Timed out while waiting for response");
}
return res;
}