From c0927797f80ae649c1f9f36a894503917e734b36 Mon Sep 17 00:00:00 2001 From: Christopher Wecht Date: Thu, 28 Feb 2019 17:29:56 +0100 Subject: [PATCH] roscpp/service: use WallTime/WallDuration for waiting --- clients/roscpp/src/libros/service.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/clients/roscpp/src/libros/service.cpp b/clients/roscpp/src/libros/service.cpp index c1efc4e510..495e49235d 100644 --- a/clients/roscpp/src/libros/service.cpp +++ b/clients/roscpp/src/libros/service.cpp @@ -88,7 +88,8 @@ bool service::waitForService(const std::string& service_name, ros::Duration time { std::string mapped_name = names::resolve(service_name); - Time start_time = Time::now(); + const WallTime start_time = WallTime::now(); + const WallDuration wall_timeout{timeout.toSec()}; bool printed = false; bool result = false; @@ -103,17 +104,17 @@ bool service::waitForService(const std::string& service_name, ros::Duration time { printed = true; - if (timeout >= Duration(0)) + if (wall_timeout >= WallDuration(0)) { - Time current_time = Time::now(); + const WallTime current_time = WallTime::now(); - if ((current_time - start_time) >= timeout) + if ((current_time - start_time) >= wall_timeout) { return false; } } - Duration(0.02).sleep(); + WallDuration(0.02).sleep(); } }