Skip to content

Commit

Permalink
Serialized Messages with Topic Statistics (#2274)
Browse files Browse the repository at this point in the history
Signed-off-by: CursedRock17 <[email protected]>
  • Loading branch information
CursedRock17 authored Nov 3, 2023
1 parent 4691063 commit 5049c45
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion rclcpp/include/rclcpp/subscription.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,20 @@ class Subscription : public SubscriptionBase
const std::shared_ptr<rclcpp::SerializedMessage> & serialized_message,
const rclcpp::MessageInfo & message_info) override
{
// TODO(wjwwood): enable topic statistics for serialized messages
std::chrono::time_point<std::chrono::system_clock> now;
if (subscription_topic_statistics_) {
// get current time before executing callback to
// exclude callback duration from topic statistics result.
now = std::chrono::system_clock::now();
}

any_callback_.dispatch(serialized_message, message_info);

if (subscription_topic_statistics_) {
const auto nanos = std::chrono::time_point_cast<std::chrono::nanoseconds>(now);
const auto time = rclcpp::Time(nanos.time_since_epoch().count());
subscription_topic_statistics_->handle_message(message_info.get_rmw_message_info(), time);
}
}

void
Expand Down

0 comments on commit 5049c45

Please sign in to comment.