File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -325,8 +325,20 @@ class Subscription : public SubscriptionBase
325325 const std::shared_ptr<rclcpp::SerializedMessage> & serialized_message,
326326 const rclcpp::MessageInfo & message_info) override
327327 {
328- // TODO(wjwwood): enable topic statistics for serialized messages
328+ std::chrono::time_point<std::chrono::system_clock> now;
329+ if (subscription_topic_statistics_) {
330+ // get current time before executing callback to
331+ // exclude callback duration from topic statistics result.
332+ now = std::chrono::system_clock::now ();
333+ }
334+
329335 any_callback_.dispatch (serialized_message, message_info);
336+
337+ if (subscription_topic_statistics_) {
338+ const auto nanos = std::chrono::time_point_cast<std::chrono::nanoseconds>(now);
339+ const auto time = rclcpp::Time (nanos.time_since_epoch ().count ());
340+ subscription_topic_statistics_->handle_message (message_info.get_rmw_message_info (), time);
341+ }
330342 }
331343
332344 void
You can’t perform that action at this time.
0 commit comments