diff --git a/rclcpp/include/rclcpp/clock.hpp b/rclcpp/include/rclcpp/clock.hpp index bb3c0eb28a..02c6167fd0 100644 --- a/rclcpp/include/rclcpp/clock.hpp +++ b/rclcpp/include/rclcpp/clock.hpp @@ -123,16 +123,6 @@ class Clock JumpHandler::post_callback_t post_callback, const rcl_jump_threshold_t & threshold); - /// Get current time from the time source specified by Clock::get_clock_type() const noexcept. - /** - * \param now A pointer to time point value, which will be - * set to the current time according to the underlying clock. - * \return RCUTILS_RET_OK if time was successfully retrieved - */ - RCLCPP_PUBLIC - rcutils_ret_t - get_now_as_rcutils_time_point(rcutils_time_point_value_t * now); - private: // Invoke time jump callback RCLCPP_PUBLIC diff --git a/rclcpp/resource/logging.hpp.em b/rclcpp/resource/logging.hpp.em index ac272c41ee..06751d6974 100644 --- a/rclcpp/resource/logging.hpp.em +++ b/rclcpp/resource/logging.hpp.em @@ -106,8 +106,14 @@ def is_supported_feature_combination(feature_combination): ::std::is_same::type>::type, \ typename ::rclcpp::Logger>::value, \ "First argument to logging macros must be an rclcpp::Logger"); \ +@[ if 'throttle' in feature_combination]@ \ + std::function get_time_point = [&clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \ + *time_point = clock.now().nanoseconds(); \ + return RCUTILS_RET_OK; \ + }; \ +@[ end if] \ RCUTILS_LOG_@(severity)@(suffix)_NAMED( \ -@{params = ['clock.get_now_as_rcutils_time_point' if p == 'clock' and 'throttle' in feature_combination else p for p in params]}@ +@{params = ['get_time_point' if p == 'clock' and 'throttle' in feature_combination else p for p in params]}@ @[ if params]@ @(''.join([' ' + p + ', \\\n' for p in params]))@ @[ end if]@ diff --git a/rclcpp/src/rclcpp/clock.cpp b/rclcpp/src/rclcpp/clock.cpp index 9fd0d5abe6..a0e02cc362 100644 --- a/rclcpp/src/rclcpp/clock.cpp +++ b/rclcpp/src/rclcpp/clock.cpp @@ -52,7 +52,7 @@ Clock::now() { Time now(0, 0, rcl_clock_.type); - auto ret = get_now_as_rcutils_time_point(&now.rcl_time_.nanoseconds); + auto ret = rcl_clock_get_now(&rcl_clock_, &now.rcl_time_.nanoseconds); if (ret != RCL_RET_OK) { exceptions::throw_from_rcl_error(ret, "could not get current time stamp"); } @@ -141,11 +141,4 @@ Clock::create_jump_callback( // *INDENT-ON* } -rcutils_ret_t -Clock::get_now_as_rcutils_time_point( - rcutils_time_point_value_t * now) -{ - return rcl_clock_get_now(&rcl_clock_, now); -} - } // namespace rclcpp