diff --git a/rcl/src/rcl/time.c b/rcl/src/rcl/time.c index 12dc87924..ef3d8a9fc 100644 --- a/rcl/src/rcl/time.c +++ b/rcl/src/rcl/time.c @@ -275,9 +275,9 @@ rcl_clock_call_callbacks( rcl_jump_callback_info_t * info = &(clock->jump_callbacks[cb_idx]); if ( (is_clock_change && info->threshold.on_clock_change) || - (time_jump->delta.nanoseconds < 0 && + (info->threshold.min_backward.nanoseconds < 0 && time_jump->delta.nanoseconds <= info->threshold.min_backward.nanoseconds) || - (time_jump->delta.nanoseconds > 0 && + (info->threshold.min_forward.nanoseconds > 0 && time_jump->delta.nanoseconds >= info->threshold.min_forward.nanoseconds)) { info->callback(time_jump, before_jump, info->user_data); diff --git a/rcl/test/rcl/test_time.cpp b/rcl/test/rcl/test_time.cpp index 3bba9428a..60e4b5671 100644 --- a/rcl/test/rcl/test_time.cpp +++ b/rcl/test/rcl/test_time.cpp @@ -549,6 +549,12 @@ TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_time_forward_jump_callbacks) { EXPECT_FALSE(pre_callback_called); EXPECT_FALSE(post_callback_called); + // Jump backwards, no jump callbacks + ret = rcl_set_ros_time_override(&ros_clock, set_point1); + EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; + EXPECT_FALSE(pre_callback_called); + EXPECT_FALSE(post_callback_called); + // disable no callbacks ret = rcl_disable_ros_time_override(&ros_clock); EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; @@ -606,6 +612,12 @@ TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_time_backward_jump_callbacks) EXPECT_FALSE(pre_callback_called); EXPECT_FALSE(post_callback_called); + // Jump forwards, no jump callbacks + ret = rcl_set_ros_time_override(&ros_clock, set_point2); + EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; + EXPECT_FALSE(pre_callback_called); + EXPECT_FALSE(post_callback_called); + // disable no callbacks ret = rcl_disable_ros_time_override(&ros_clock); EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str;