Commit 206e0fd 1 parent 4fc3791 commit 206e0fd Copy full SHA for 206e0fd
File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -295,11 +295,31 @@ class Subscription : public SubscriptionBase
295
295
void * loaned_message,
296
296
const rclcpp::MessageInfo & message_info) override
297
297
{
298
+ if (matches_any_intra_process_publishers (&message_info.get_rmw_message_info ().publisher_gid )) {
299
+ // In this case, the message will be delivered via intra process and
300
+ // we should ignore this copy of the message.
301
+ return ;
302
+ }
303
+
298
304
auto typed_message = static_cast <CallbackMessageT *>(loaned_message);
299
305
// message is loaned, so we have to make sure that the deleter does not deallocate the message
300
306
auto sptr = std::shared_ptr<CallbackMessageT>(
301
307
typed_message, [](CallbackMessageT * msg) {(void ) msg;});
308
+
309
+ std::chrono::time_point<std::chrono::system_clock> now;
310
+ if (subscription_topic_statistics_) {
311
+ // get current time before executing callback to
312
+ // exclude callback duration from topic statistics result.
313
+ now = std::chrono::system_clock::now ();
314
+ }
315
+
302
316
any_callback_.dispatch (sptr, message_info);
317
+
318
+ if (subscription_topic_statistics_) {
319
+ const auto nanos = std::chrono::time_point_cast<std::chrono::nanoseconds>(now);
320
+ const auto time = rclcpp::Time (nanos.time_since_epoch ().count ());
321
+ subscription_topic_statistics_->handle_message (*typed_message, time );
322
+ }
303
323
}
304
324
305
325
// / Return the borrowed message.
You can’t perform that action at this time.
0 commit comments