From c11a84a8a95c9f6182f72e923d77dcc7ad6ed039 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 13 Dec 2018 11:27:05 -0800 Subject: [PATCH] Set rmw_wait timeout using ros timers too --- rcl/src/rcl/wait.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/rcl/src/rcl/wait.c b/rcl/src/rcl/wait.c index 8bac519c5..f351bd469 100644 --- a/rcl/src/rcl/wait.c +++ b/rcl/src/rcl/wait.c @@ -506,17 +506,17 @@ rcl_wait(rcl_wait_set_t * wait_set, int64_t timeout) rmw_gcs->guard_conditions[rmw_gcs->guard_condition_count] = rmw_gcs->guard_conditions[gc_idx]; ++(rmw_gcs->guard_condition_count); - } else { - // No guard condition, instead use to set the rmw_wait timeout - int64_t timer_timeout = INT64_MAX; - rcl_ret_t ret = rcl_timer_get_time_until_next_call(wait_set->timers[i], &timer_timeout); - if (ret != RCL_RET_OK) { - return ret; // The rcl error state should already be set. - } - if (timer_timeout < min_timeout) { - is_timer_timeout = true; - min_timeout = timer_timeout; - } + } + // use timer time to to set the rmw_wait timeout + // TODO(sloretz) fix spurious wake-ups on ROS_TIME timers with ROS_TIME enabled + int64_t timer_timeout = INT64_MAX; + ret = rcl_timer_get_time_until_next_call(wait_set->timers[i], &timer_timeout); + if (ret != RCL_RET_OK) { + return ret; // The rcl error state should already be set. + } + if (timer_timeout < min_timeout) { + is_timer_timeout = true; + min_timeout = timer_timeout; } } }