From a3a60b23073917fcdec79cf8eee12077954b4b0a Mon Sep 17 00:00:00 2001 From: Michael Orlov Date: Thu, 9 May 2024 04:58:20 -0700 Subject: [PATCH] Set received_timestamp to system_clock::now() in message_info (#491) * Set received_timestamp to steady_clock::now() in message_info * Use 'system_clock' instead of 'steady_clock' * Also update receive_timestamp for services. Signed-off-by: Michael Orlov Signed-off-by: Chris Lalancette (cherry picked from commit 76c9d8f38a03d160b258902af6d1d06f6ed9391e) --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 7f47a2d7..240a4d98 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -3278,8 +3278,9 @@ static void message_info_from_sample_info( message_info->publisher_gid.data, &info.publication_handle, sizeof(info.publication_handle)); message_info->source_timestamp = info.source_timestamp; - // TODO(iluetkeb) add received timestamp, when implemented by Cyclone - message_info->received_timestamp = 0; + // TODO(iluetkeb) get received_timestamp from Cyclone when implemented there + message_info->received_timestamp = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()).count(); message_info->publication_sequence_number = RMW_MESSAGE_INFO_SEQUENCE_NUMBER_UNSUPPORTED; message_info->reception_sequence_number = RMW_MESSAGE_INFO_SEQUENCE_NUMBER_UNSUPPORTED; } @@ -4631,8 +4632,9 @@ static rmw_ret_t rmw_take_response_request( static_cast(&info.publication_handle), sizeof(info.publication_handle)); request_header->request_id.sequence_number = wrap.header.seq; request_header->source_timestamp = info.source_timestamp; - // TODO(iluetkeb) replace with real received timestamp when available in cyclone - request_header->received_timestamp = 0; + // TODO(iluetkeb) get received_timestamp from Cyclone when implemented there + request_header->received_timestamp = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()).count(); if (source_timestamp) { *source_timestamp = info.source_timestamp; }