diff --git a/rclcpp/include/rclcpp/client.hpp b/rclcpp/include/rclcpp/client.hpp index 6bda230..89609b6 100644 --- a/rclcpp/include/rclcpp/client.hpp +++ b/rclcpp/include/rclcpp/client.hpp @@ -44,12 +44,17 @@ public: {} std::shared_ptr - send_request(std::shared_ptr &req) + send_request(std::shared_ptr &req, long timeout=10) { ::ros_middleware_interface::send_request(client_handle_, req.get()); std::shared_ptr res = std::make_shared(); - ::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; }