Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timestamp to rmw_publish tracepoint #694

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions rmw_fastrtps_shared_cpp/src/rmw_publish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "fastcdr/Cdr.h"
#include "fastcdr/FastBuffer.h"

#include "fastdds/rtps/common/Time_t.h"

#include "rmw/allocators.h"
#include "rmw/error_handling.h"
#include "rmw/rmw.h"
Expand Down Expand Up @@ -57,8 +59,10 @@ __rmw_publish(
data.type = FASTRTPS_SERIALIZED_DATA_TYPE_ROS_MESSAGE;
data.data = const_cast<void *>(ros_message);
data.impl = info->type_support_impl_;
TRACETOOLS_TRACEPOINT(rmw_publish, ros_message);
if (!info->data_writer_->write(&data)) {
eprosima::fastrtps::Time_t stamp;
eprosima::fastrtps::Time_t::now(stamp);
TRACETOOLS_TRACEPOINT(rmw_publish, publisher, ros_message, stamp.to_ns());
if (!info->data_writer_->write_w_timestamp(&data, eprosima::fastdds::dds::HANDLE_NIL, stamp)) {
RMW_SET_ERROR_MSG("cannot publish data");
return RMW_RET_ERROR;
}
Expand Down Expand Up @@ -135,8 +139,13 @@ __rmw_publish_loaned_message(
RMW_CHECK_ARGUMENT_FOR_NULL(ros_message, RMW_RET_INVALID_ARGUMENT);

auto info = static_cast<CustomPublisherInfo *>(publisher->data);
TRACETOOLS_TRACEPOINT(rmw_publish, ros_message);
if (!info->data_writer_->write(const_cast<void *>(ros_message))) {
eprosima::fastrtps::Time_t stamp;
eprosima::fastrtps::Time_t::now(stamp);
TRACETOOLS_TRACEPOINT(rmw_publish, publisher, ros_message, stamp.to_ns());
if (!info->data_writer_->write_w_timestamp(
const_cast<void *>(ros_message),
eprosima::fastdds::dds::HANDLE_NIL, stamp))
{
RMW_SET_ERROR_MSG("cannot publish data");
return RMW_RET_ERROR;
}
Expand Down