Skip to content

Commit

Permalink
Always publish inter-process on TRANSIENT_LOCAL pubs (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauro Passerino committed Aug 23, 2024
1 parent c2acb19 commit 9435bee
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions rclcpp/include/rclcpp/publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,11 @@ class Publisher : public PublisherBase
bool inter_process_publish_needed =
get_subscription_count() > get_intra_process_subscription_count();

if (inter_process_publish_needed) {
// If the publisher is configured with transient local durability, we must publish
// inter-process. This ensures that the RMW stores the messages for late joiner subscriptions.
// This has the consequence of subscriptions experiencing the double-delivery issue
// mentioned in https://github.com/ros2/rclcpp/issues/1750
if (inter_process_publish_needed || buffer_) {
auto ros_msg_ptr = std::make_shared<ROSMessageType>();
// TODO(clalancette): This is unnecessarily doing an additional conversion
// that may have already been done in do_intra_process_publish_and_return_shared().
Expand All @@ -363,11 +367,6 @@ class Publisher : public PublisherBase
buffer_->add_shared(ros_msg_ptr);
}
} else {
if (buffer_) {
auto ros_msg_ptr = std::make_shared<ROSMessageType>();
rclcpp::TypeAdapter<MessageT>::convert_to_ros_message(*msg, *ros_msg_ptr);
buffer_->add_shared(ros_msg_ptr);
}
this->do_intra_process_publish(std::move(msg));
}
}
Expand Down

0 comments on commit 9435bee

Please sign in to comment.