diff --git a/rclcpp/include/rclcpp/publisher.hpp b/rclcpp/include/rclcpp/publisher.hpp index c4abacc82a..b757649cdd 100644 --- a/rclcpp/include/rclcpp/publisher.hpp +++ b/rclcpp/include/rclcpp/publisher.hpp @@ -405,10 +405,6 @@ class Publisher : public PublisherBase if (!loaned_msg.is_valid()) { throw std::runtime_error("loaned message is not valid"); } - if (intra_process_is_enabled_) { - // TODO(Karsten1987): support loaned message passed by intraprocess - throw std::runtime_error("storing loaned messages in intra process is not supported yet"); - } // verify that publisher supports loaned messages // TODO(Karsten1987): This case separation has to be done in rclcpp @@ -422,7 +418,7 @@ class Publisher : public PublisherBase } else { // we don't release the ownership, let the middleware copy the ros message // and thus the destructor of rclcpp::LoanedMessage cleans up the memory. - this->do_inter_process_publish(loaned_msg.get()); + this->publish(loaned_msg.get()); } } diff --git a/rclcpp/src/rclcpp/publisher_base.cpp b/rclcpp/src/rclcpp/publisher_base.cpp index 723d56e0d5..db67fbf713 100644 --- a/rclcpp/src/rclcpp/publisher_base.cpp +++ b/rclcpp/src/rclcpp/publisher_base.cpp @@ -233,7 +233,7 @@ PublisherBase::assert_liveliness() const bool PublisherBase::can_loan_messages() const { - return rcl_publisher_can_loan_messages(publisher_handle_.get()); + return !intra_process_is_enabled_ && rcl_publisher_can_loan_messages(publisher_handle_.get()); } bool diff --git a/rclcpp/test/rclcpp/test_publisher.cpp b/rclcpp/test/rclcpp/test_publisher.cpp index 1679ca76f0..1dabd0e3d6 100644 --- a/rclcpp/test/rclcpp/test_publisher.cpp +++ b/rclcpp/test/rclcpp/test_publisher.cpp @@ -406,9 +406,7 @@ TEST_F(TestPublisher, intra_process_publish_failures) { std::allocator allocator; { rclcpp::LoanedMessage loaned_msg(*publisher, allocator); - RCLCPP_EXPECT_THROW_EQ( - publisher->publish(std::move(loaned_msg)), - std::runtime_error("storing loaned messages in intra process is not supported yet")); + EXPECT_NO_THROW(publisher->publish(std::move(loaned_msg))); } {