Added support for timeouts
This commit is contained in:
parent
4b290d66e8
commit
3e0621a1ff
1 changed files with 7 additions and 2 deletions
|
@ -44,12 +44,17 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::shared_ptr<typename ServiceT::Response>
|
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());
|
::ros_middleware_interface::send_request(client_handle_, req.get());
|
||||||
|
|
||||||
std::shared_ptr<typename ServiceT::Response> res = std::make_shared<typename ServiceT::Response>();
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue