From d722b72c84eb762842bfe3341e7c8b007e31cd00 Mon Sep 17 00:00:00 2001 From: methylDragon Date: Tue, 6 Dec 2022 11:19:40 -0800 Subject: [PATCH 1/2] Remove templating on to_rcl_subscription_options (#2056) --- rclcpp/include/rclcpp/generic_subscription.hpp | 2 +- rclcpp/include/rclcpp/subscription.hpp | 2 +- rclcpp/include/rclcpp/subscription_options.hpp | 1 - rclcpp/test/rclcpp/node_interfaces/test_node_topics.cpp | 4 ++-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/rclcpp/include/rclcpp/generic_subscription.hpp b/rclcpp/include/rclcpp/generic_subscription.hpp index 673712eedb..16c8fe6fbf 100644 --- a/rclcpp/include/rclcpp/generic_subscription.hpp +++ b/rclcpp/include/rclcpp/generic_subscription.hpp @@ -81,7 +81,7 @@ class GenericSubscription : public rclcpp::SubscriptionBase node_base, *rclcpp::get_typesupport_handle(topic_type, "rosidl_typesupport_cpp", *ts_lib), topic_name, - options.template to_rcl_subscription_options(qos), + options.to_rcl_subscription_options(qos), true), callback_(callback), ts_lib_(ts_lib) diff --git a/rclcpp/include/rclcpp/subscription.hpp b/rclcpp/include/rclcpp/subscription.hpp index 6f02e59c05..32075603f6 100644 --- a/rclcpp/include/rclcpp/subscription.hpp +++ b/rclcpp/include/rclcpp/subscription.hpp @@ -140,7 +140,7 @@ class Subscription : public SubscriptionBase node_base, type_support_handle, topic_name, - options.template to_rcl_subscription_options(qos), + options.to_rcl_subscription_options(qos), callback.is_serialized_message_callback()), any_callback_(callback), options_(options), diff --git a/rclcpp/include/rclcpp/subscription_options.hpp b/rclcpp/include/rclcpp/subscription_options.hpp index 2b819da399..c5c3e21eb1 100644 --- a/rclcpp/include/rclcpp/subscription_options.hpp +++ b/rclcpp/include/rclcpp/subscription_options.hpp @@ -110,7 +110,6 @@ struct SubscriptionOptionsWithAllocator : public SubscriptionOptionsBase * \param qos QoS profile for subcription. * \return rcl_subscription_options_t structure based on the rclcpp::QoS */ - template rcl_subscription_options_t to_rcl_subscription_options(const rclcpp::QoS & qos) const { diff --git a/rclcpp/test/rclcpp/node_interfaces/test_node_topics.cpp b/rclcpp/test/rclcpp/node_interfaces/test_node_topics.cpp index a99633bec6..264577a739 100644 --- a/rclcpp/test/rclcpp/node_interfaces/test_node_topics.cpp +++ b/rclcpp/test/rclcpp/node_interfaces/test_node_topics.cpp @@ -44,8 +44,8 @@ const rcl_publisher_options_t PublisherOptions() const rcl_subscription_options_t SubscriptionOptions() { - return rclcpp::SubscriptionOptionsWithAllocator>().template - to_rcl_subscription_options(rclcpp::QoS(10)); + return rclcpp::SubscriptionOptionsWithAllocator>() + .to_rcl_subscription_options(rclcpp::QoS(10)); } } // namespace From be2a2cc4343e308830038bf919d27d2531d055bc Mon Sep 17 00:00:00 2001 From: methylDragon Date: Mon, 19 Dec 2022 18:21:40 -0800 Subject: [PATCH 2/2] Move event callback binding to PublisherBase and SubscriptionBase (#2066) --- rclcpp/include/rclcpp/generic_publisher.hpp | 36 +++------------- .../include/rclcpp/generic_subscription.hpp | 38 ++-------------- rclcpp/include/rclcpp/publisher.hpp | 32 ++------------ rclcpp/include/rclcpp/publisher_base.hpp | 11 ++++- rclcpp/include/rclcpp/subscription.hpp | 35 ++------------- rclcpp/include/rclcpp/subscription_base.hpp | 10 +++++ rclcpp/src/rclcpp/publisher_base.cpp | 41 +++++++++++++++++- rclcpp/src/rclcpp/subscription_base.cpp | 43 ++++++++++++++++++- .../node_interfaces/test_node_topics.cpp | 18 ++++---- rclcpp/test/rclcpp/test_publisher.cpp | 9 ++-- rclcpp/test/rclcpp/test_type_support.cpp | 17 +++++--- 11 files changed, 141 insertions(+), 149 deletions(-) diff --git a/rclcpp/include/rclcpp/generic_publisher.hpp b/rclcpp/include/rclcpp/generic_publisher.hpp index e1b46002bc..7cd2d8bc39 100644 --- a/rclcpp/include/rclcpp/generic_publisher.hpp +++ b/rclcpp/include/rclcpp/generic_publisher.hpp @@ -78,38 +78,12 @@ class GenericPublisher : public rclcpp::PublisherBase node_base, topic_name, *rclcpp::get_typesupport_handle(topic_type, "rosidl_typesupport_cpp", *ts_lib), - options.template to_rcl_publisher_options(qos)), + options.template to_rcl_publisher_options(qos), + // NOTE(methylDragon): Passing these args separately is necessary for event binding + options.event_callbacks, + options.use_default_callbacks), ts_lib_(ts_lib) - { - // This is unfortunately duplicated with the code in publisher.hpp. - // TODO(nnmm): Deduplicate by moving this into PublisherBase. - if (options.event_callbacks.deadline_callback) { - this->add_event_handler( - options.event_callbacks.deadline_callback, - RCL_PUBLISHER_OFFERED_DEADLINE_MISSED); - } - if (options.event_callbacks.liveliness_callback) { - this->add_event_handler( - options.event_callbacks.liveliness_callback, - RCL_PUBLISHER_LIVELINESS_LOST); - } - if (options.event_callbacks.incompatible_qos_callback) { - this->add_event_handler( - options.event_callbacks.incompatible_qos_callback, - RCL_PUBLISHER_OFFERED_INCOMPATIBLE_QOS); - } else if (options.use_default_callbacks) { - // Register default callback when not specified - try { - this->add_event_handler( - [this](QOSOfferedIncompatibleQoSInfo & info) { - this->default_incompatible_qos_callback(info); - }, - RCL_PUBLISHER_OFFERED_INCOMPATIBLE_QOS); - } catch (UnsupportedEventTypeException & /*exc*/) { - // pass - } - } - } + {} RCLCPP_PUBLIC virtual ~GenericPublisher() = default; diff --git a/rclcpp/include/rclcpp/generic_subscription.hpp b/rclcpp/include/rclcpp/generic_subscription.hpp index 16c8fe6fbf..12a1c79f8f 100644 --- a/rclcpp/include/rclcpp/generic_subscription.hpp +++ b/rclcpp/include/rclcpp/generic_subscription.hpp @@ -82,44 +82,12 @@ class GenericSubscription : public rclcpp::SubscriptionBase *rclcpp::get_typesupport_handle(topic_type, "rosidl_typesupport_cpp", *ts_lib), topic_name, options.to_rcl_subscription_options(qos), + options.event_callbacks, + options.use_default_callbacks, true), callback_(callback), ts_lib_(ts_lib) - { - // This is unfortunately duplicated with the code in subscription.hpp. - // TODO(nnmm): Deduplicate by moving this into SubscriptionBase. - if (options.event_callbacks.deadline_callback) { - this->add_event_handler( - options.event_callbacks.deadline_callback, - RCL_SUBSCRIPTION_REQUESTED_DEADLINE_MISSED); - } - if (options.event_callbacks.liveliness_callback) { - this->add_event_handler( - options.event_callbacks.liveliness_callback, - RCL_SUBSCRIPTION_LIVELINESS_CHANGED); - } - if (options.event_callbacks.incompatible_qos_callback) { - this->add_event_handler( - options.event_callbacks.incompatible_qos_callback, - RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS); - } else if (options.use_default_callbacks) { - // Register default callback when not specified - try { - this->add_event_handler( - [this](QOSRequestedIncompatibleQoSInfo & info) { - this->default_incompatible_qos_callback(info); - }, - RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS); - } catch (UnsupportedEventTypeException & /*exc*/) { - // pass - } - } - if (options.event_callbacks.message_lost_callback) { - this->add_event_handler( - options.event_callbacks.message_lost_callback, - RCL_SUBSCRIPTION_MESSAGE_LOST); - } - } + {} RCLCPP_PUBLIC virtual ~GenericSubscription() = default; diff --git a/rclcpp/include/rclcpp/publisher.hpp b/rclcpp/include/rclcpp/publisher.hpp index b757649cdd..bdc0391043 100644 --- a/rclcpp/include/rclcpp/publisher.hpp +++ b/rclcpp/include/rclcpp/publisher.hpp @@ -131,40 +131,16 @@ class Publisher : public PublisherBase node_base, topic, rclcpp::get_message_type_support_handle(), - options.template to_rcl_publisher_options(qos)), + options.template to_rcl_publisher_options(qos), + // NOTE(methylDragon): Passing these args separately is necessary for event binding + options.event_callbacks, + options.use_default_callbacks), options_(options), published_type_allocator_(*options.get_allocator()), ros_message_type_allocator_(*options.get_allocator()) { allocator::set_allocator_for_deleter(&published_type_deleter_, &published_type_allocator_); allocator::set_allocator_for_deleter(&ros_message_type_deleter_, &ros_message_type_allocator_); - - if (options_.event_callbacks.deadline_callback) { - this->add_event_handler( - options_.event_callbacks.deadline_callback, - RCL_PUBLISHER_OFFERED_DEADLINE_MISSED); - } - if (options_.event_callbacks.liveliness_callback) { - this->add_event_handler( - options_.event_callbacks.liveliness_callback, - RCL_PUBLISHER_LIVELINESS_LOST); - } - if (options_.event_callbacks.incompatible_qos_callback) { - this->add_event_handler( - options_.event_callbacks.incompatible_qos_callback, - RCL_PUBLISHER_OFFERED_INCOMPATIBLE_QOS); - } else if (options_.use_default_callbacks) { - // Register default callback when not specified - try { - this->add_event_handler( - [this](QOSOfferedIncompatibleQoSInfo & info) { - this->default_incompatible_qos_callback(info); - }, - RCL_PUBLISHER_OFFERED_INCOMPATIBLE_QOS); - } catch (UnsupportedEventTypeException & /*exc*/) { - // pass - } - } // Setup continues in the post construction method, post_init_setup(). } diff --git a/rclcpp/include/rclcpp/publisher_base.hpp b/rclcpp/include/rclcpp/publisher_base.hpp index 8416757a53..153d5a6ebe 100644 --- a/rclcpp/include/rclcpp/publisher_base.hpp +++ b/rclcpp/include/rclcpp/publisher_base.hpp @@ -78,11 +78,18 @@ class PublisherBase : public std::enable_shared_from_this rclcpp::node_interfaces::NodeBaseInterface * node_base, const std::string & topic, const rosidl_message_type_support_t & type_support, - const rcl_publisher_options_t & publisher_options); + const rcl_publisher_options_t & publisher_options, + const PublisherEventCallbacks & event_callbacks, + bool use_default_callbacks); RCLCPP_PUBLIC virtual ~PublisherBase(); + /// Add event handlers for passed in event_callbacks. + RCLCPP_PUBLIC + void + bind_event_callbacks(const PublisherEventCallbacks & event_callbacks, bool use_default_callbacks); + /// Get the topic that this publisher publishes on. /** \return The topic name. */ RCLCPP_PUBLIC @@ -348,6 +355,8 @@ class PublisherBase : public std::enable_shared_from_this rmw_gid_t rmw_gid_; const rosidl_message_type_support_t type_support_; + + const PublisherEventCallbacks event_callbacks_; }; } // namespace rclcpp diff --git a/rclcpp/include/rclcpp/subscription.hpp b/rclcpp/include/rclcpp/subscription.hpp index 32075603f6..507c26afa8 100644 --- a/rclcpp/include/rclcpp/subscription.hpp +++ b/rclcpp/include/rclcpp/subscription.hpp @@ -141,43 +141,14 @@ class Subscription : public SubscriptionBase type_support_handle, topic_name, options.to_rcl_subscription_options(qos), + // NOTE(methylDragon): Passing these args separately is necessary for event binding + options.event_callbacks, + options.use_default_callbacks, callback.is_serialized_message_callback()), any_callback_(callback), options_(options), message_memory_strategy_(message_memory_strategy) { - if (options_.event_callbacks.deadline_callback) { - this->add_event_handler( - options_.event_callbacks.deadline_callback, - RCL_SUBSCRIPTION_REQUESTED_DEADLINE_MISSED); - } - if (options_.event_callbacks.liveliness_callback) { - this->add_event_handler( - options_.event_callbacks.liveliness_callback, - RCL_SUBSCRIPTION_LIVELINESS_CHANGED); - } - if (options_.event_callbacks.incompatible_qos_callback) { - this->add_event_handler( - options_.event_callbacks.incompatible_qos_callback, - RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS); - } else if (options_.use_default_callbacks) { - // Register default callback when not specified - try { - this->add_event_handler( - [this](QOSRequestedIncompatibleQoSInfo & info) { - this->default_incompatible_qos_callback(info); - }, - RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS); - } catch (UnsupportedEventTypeException & /*exc*/) { - // pass - } - } - if (options_.event_callbacks.message_lost_callback) { - this->add_event_handler( - options_.event_callbacks.message_lost_callback, - RCL_SUBSCRIPTION_MESSAGE_LOST); - } - // Setup intra process publishing if requested. if (rclcpp::detail::resolve_use_intra_process(options_.use_intra_process_comm, *node_base)) { using rclcpp::detail::resolve_intra_process_buffer_type; diff --git a/rclcpp/include/rclcpp/subscription_base.hpp b/rclcpp/include/rclcpp/subscription_base.hpp index 09f62d5c11..af12880ad6 100644 --- a/rclcpp/include/rclcpp/subscription_base.hpp +++ b/rclcpp/include/rclcpp/subscription_base.hpp @@ -84,12 +84,20 @@ class SubscriptionBase : public std::enable_shared_from_this const rosidl_message_type_support_t & type_support_handle, const std::string & topic_name, const rcl_subscription_options_t & subscription_options, + const SubscriptionEventCallbacks & event_callbacks, + bool use_default_callbacks, bool is_serialized = false); /// Destructor. RCLCPP_PUBLIC virtual ~SubscriptionBase(); + /// Add event handlers for passed in event_callbacks. + RCLCPP_PUBLIC + void + bind_event_callbacks( + const SubscriptionEventCallbacks & event_callbacks, bool use_default_callbacks); + /// Get the topic that this subscription is subscribed on. RCLCPP_PUBLIC const char * @@ -578,6 +586,8 @@ class SubscriptionBase : public std::enable_shared_from_this uint64_t intra_process_subscription_id_; std::shared_ptr subscription_intra_process_; + const SubscriptionEventCallbacks event_callbacks_; + private: RCLCPP_DISABLE_COPY(SubscriptionBase) diff --git a/rclcpp/src/rclcpp/publisher_base.cpp b/rclcpp/src/rclcpp/publisher_base.cpp index 0f8d9c0996..93dbcf814c 100644 --- a/rclcpp/src/rclcpp/publisher_base.cpp +++ b/rclcpp/src/rclcpp/publisher_base.cpp @@ -45,11 +45,14 @@ PublisherBase::PublisherBase( rclcpp::node_interfaces::NodeBaseInterface * node_base, const std::string & topic, const rosidl_message_type_support_t & type_support, - const rcl_publisher_options_t & publisher_options) + const rcl_publisher_options_t & publisher_options, + const PublisherEventCallbacks & event_callbacks, + bool use_default_callbacks) : rcl_node_handle_(node_base->get_shared_rcl_node_handle()), intra_process_is_enabled_(false), intra_process_publisher_id_(0), - type_support_(type_support) + type_support_(type_support), + event_callbacks_(event_callbacks) { auto custom_deleter = [node_handle = this->rcl_node_handle_](rcl_publisher_t * rcl_pub) { @@ -98,6 +101,8 @@ PublisherBase::PublisherBase( rmw_reset_error(); throw std::runtime_error(msg); } + + bind_event_callbacks(event_callbacks_, use_default_callbacks); } PublisherBase::~PublisherBase() @@ -126,6 +131,38 @@ PublisherBase::get_topic_name() const return rcl_publisher_get_topic_name(publisher_handle_.get()); } +void +PublisherBase::bind_event_callbacks( + const PublisherEventCallbacks & event_callbacks, bool use_default_callbacks) +{ + if (event_callbacks.deadline_callback) { + this->add_event_handler( + event_callbacks.deadline_callback, + RCL_PUBLISHER_OFFERED_DEADLINE_MISSED); + } + if (event_callbacks.liveliness_callback) { + this->add_event_handler( + event_callbacks.liveliness_callback, + RCL_PUBLISHER_LIVELINESS_LOST); + } + if (event_callbacks.incompatible_qos_callback) { + this->add_event_handler( + event_callbacks.incompatible_qos_callback, + RCL_PUBLISHER_OFFERED_INCOMPATIBLE_QOS); + } else if (use_default_callbacks) { + // Register default callback when not specified + try { + this->add_event_handler( + [this](QOSOfferedIncompatibleQoSInfo & info) { + this->default_incompatible_qos_callback(info); + }, + RCL_PUBLISHER_OFFERED_INCOMPATIBLE_QOS); + } catch (UnsupportedEventTypeException & /*exc*/) { + // pass + } + } +} + size_t PublisherBase::get_queue_size() const { diff --git a/rclcpp/src/rclcpp/subscription_base.cpp b/rclcpp/src/rclcpp/subscription_base.cpp index 871321fbe8..0225747b3a 100644 --- a/rclcpp/src/rclcpp/subscription_base.cpp +++ b/rclcpp/src/rclcpp/subscription_base.cpp @@ -39,12 +39,15 @@ SubscriptionBase::SubscriptionBase( const rosidl_message_type_support_t & type_support_handle, const std::string & topic_name, const rcl_subscription_options_t & subscription_options, + const SubscriptionEventCallbacks & event_callbacks, + bool use_default_callbacks, bool is_serialized) : node_base_(node_base), node_handle_(node_base_->get_shared_rcl_node_handle()), node_logger_(rclcpp::get_node_logger(node_handle_.get())), use_intra_process_(false), intra_process_subscription_id_(0), + event_callbacks_(event_callbacks), type_support_(type_support_handle), is_serialized_(is_serialized) { @@ -80,9 +83,10 @@ SubscriptionBase::SubscriptionBase( rcl_node_get_name(rcl_node_handle), rcl_node_get_namespace(rcl_node_handle)); } - rclcpp::exceptions::throw_from_rcl_error(ret, "could not create subscription"); } + + bind_event_callbacks(event_callbacks_, use_default_callbacks); } SubscriptionBase::~SubscriptionBase() @@ -101,6 +105,43 @@ SubscriptionBase::~SubscriptionBase() ipm->remove_subscription(intra_process_subscription_id_); } +void +SubscriptionBase::bind_event_callbacks( + const SubscriptionEventCallbacks & event_callbacks, bool use_default_callbacks) +{ + if (event_callbacks.deadline_callback) { + this->add_event_handler( + event_callbacks.deadline_callback, + RCL_SUBSCRIPTION_REQUESTED_DEADLINE_MISSED); + } + if (event_callbacks.liveliness_callback) { + this->add_event_handler( + event_callbacks.liveliness_callback, + RCL_SUBSCRIPTION_LIVELINESS_CHANGED); + } + if (event_callbacks.incompatible_qos_callback) { + this->add_event_handler( + event_callbacks.incompatible_qos_callback, + RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS); + } else if (use_default_callbacks) { + // Register default callback when not specified + try { + this->add_event_handler( + [this](QOSRequestedIncompatibleQoSInfo & info) { + this->default_incompatible_qos_callback(info); + }, + RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS); + } catch (UnsupportedEventTypeException & /*exc*/) { + // pass + } + } + if (event_callbacks.message_lost_callback) { + this->add_event_handler( + event_callbacks.message_lost_callback, + RCL_SUBSCRIPTION_MESSAGE_LOST); + } +} + const char * SubscriptionBase::get_topic_name() const { diff --git a/rclcpp/test/rclcpp/node_interfaces/test_node_topics.cpp b/rclcpp/test/rclcpp/node_interfaces/test_node_topics.cpp index 264577a739..ecfc89a6aa 100644 --- a/rclcpp/test/rclcpp/node_interfaces/test_node_topics.cpp +++ b/rclcpp/test/rclcpp/node_interfaces/test_node_topics.cpp @@ -36,16 +36,14 @@ const rosidl_message_type_support_t EmptyTypeSupport() return *rosidl_typesupport_cpp::get_message_type_support_handle(); } -const rcl_publisher_options_t PublisherOptions() +const rclcpp::PublisherOptionsWithAllocator> PublisherOptions() { - return rclcpp::PublisherOptionsWithAllocator>().template - to_rcl_publisher_options(rclcpp::QoS(10)); + return rclcpp::PublisherOptionsWithAllocator>(); } -const rcl_subscription_options_t SubscriptionOptions() +const rclcpp::SubscriptionOptionsWithAllocator> SubscriptionOptions() { - return rclcpp::SubscriptionOptionsWithAllocator>() - .to_rcl_subscription_options(rclcpp::QoS(10)); + return rclcpp::SubscriptionOptionsWithAllocator>(); } } // namespace @@ -55,7 +53,9 @@ class TestPublisher : public rclcpp::PublisherBase public: explicit TestPublisher(rclcpp::Node * node) : rclcpp::PublisherBase( - node->get_node_base_interface().get(), "topic", EmptyTypeSupport(), PublisherOptions()) {} + node->get_node_base_interface().get(), "topic", EmptyTypeSupport(), + PublisherOptions().to_rcl_publisher_options(rclcpp::QoS(10)), + PublisherOptions().event_callbacks, PublisherOptions().use_default_callbacks) {} }; class TestSubscription : public rclcpp::SubscriptionBase @@ -63,7 +63,9 @@ class TestSubscription : public rclcpp::SubscriptionBase public: explicit TestSubscription(rclcpp::Node * node) : rclcpp::SubscriptionBase( - node->get_node_base_interface().get(), EmptyTypeSupport(), "topic", SubscriptionOptions()) {} + node->get_node_base_interface().get(), EmptyTypeSupport(), "topic", + SubscriptionOptions().to_rcl_subscription_options(rclcpp::QoS(10)), + SubscriptionOptions().event_callbacks, SubscriptionOptions().use_default_callbacks) {} std::shared_ptr create_message() override {return nullptr;} std::shared_ptr diff --git a/rclcpp/test/rclcpp/test_publisher.cpp b/rclcpp/test/rclcpp/test_publisher.cpp index 1dabd0e3d6..8b7f2fcd50 100644 --- a/rclcpp/test/rclcpp/test_publisher.cpp +++ b/rclcpp/test/rclcpp/test_publisher.cpp @@ -243,10 +243,9 @@ const rosidl_message_type_support_t EmptyTypeSupport() return *rosidl_typesupport_cpp::get_message_type_support_handle(); } -const rcl_publisher_options_t PublisherOptions() +const rclcpp::PublisherOptionsWithAllocator> PublisherOptions() { - return rclcpp::PublisherOptionsWithAllocator>().template - to_rcl_publisher_options(rclcpp::QoS(10)); + return rclcpp::PublisherOptionsWithAllocator>(); } class TestPublisherBase : public rclcpp::PublisherBase @@ -254,7 +253,9 @@ class TestPublisherBase : public rclcpp::PublisherBase public: explicit TestPublisherBase(rclcpp::Node * node) : rclcpp::PublisherBase( - node->get_node_base_interface().get(), "topic", EmptyTypeSupport(), PublisherOptions()) {} + node->get_node_base_interface().get(), "topic", EmptyTypeSupport(), + PublisherOptions().to_rcl_publisher_options(rclcpp::QoS(10)), + PublisherOptions().event_callbacks, PublisherOptions().use_default_callbacks) {} }; /* diff --git a/rclcpp/test/rclcpp/test_type_support.cpp b/rclcpp/test/rclcpp/test_type_support.cpp index 1732031029..682907e2a9 100644 --- a/rclcpp/test/rclcpp/test_type_support.cpp +++ b/rclcpp/test/rclcpp/test_type_support.cpp @@ -58,10 +58,9 @@ class TestTypeSupport : public ::testing::Test rclcpp::Node::SharedPtr node = std::make_shared("my_node", "/ns"); }; -const rcl_publisher_options_t PublisherOptions() +const rclcpp::PublisherOptionsWithAllocator> PublisherOptions() { - return rclcpp::PublisherOptionsWithAllocator>().template - to_rcl_publisher_options(rclcpp::QoS(10)); + return rclcpp::PublisherOptionsWithAllocator>(); } // Auxiliary classes used to test rosidl_message_type_support_t getters @@ -77,7 +76,8 @@ class TestTSParameterEvent : public rclcpp::PublisherBase node->get_node_base_interface().get(), "topicTSParameterEvent", *ts_parameter_event, - PublisherOptions()) {} + PublisherOptions().to_rcl_publisher_options(rclcpp::QoS(10)), + PublisherOptions().event_callbacks, PublisherOptions().use_default_callbacks) {} }; const rosidl_message_type_support_t * ts_set_parameter_result = @@ -91,7 +91,8 @@ class TestTSSetParameterResult : public rclcpp::PublisherBase node->get_node_base_interface().get(), "topicTSSetParameterResult", *ts_set_parameter_result, - PublisherOptions()) {} + PublisherOptions().to_rcl_publisher_options(rclcpp::QoS(10)), + PublisherOptions().event_callbacks, PublisherOptions().use_default_callbacks) {} }; const rosidl_message_type_support_t * ts_parameter_descriptor = @@ -105,7 +106,8 @@ class TestTSParameterDescriptor : public rclcpp::PublisherBase node->get_node_base_interface().get(), "topicTSParameterDescriptor", *ts_parameter_descriptor, - PublisherOptions()) {} + PublisherOptions().to_rcl_publisher_options(rclcpp::QoS(10)), + PublisherOptions().event_callbacks, PublisherOptions().use_default_callbacks) {} }; const rosidl_message_type_support_t * ts_list_parameter_result = @@ -119,7 +121,8 @@ class TestTSListParametersResult : public rclcpp::PublisherBase node->get_node_base_interface().get(), "topicTSListParametersResult", *ts_list_parameter_result, - PublisherOptions()) {} + PublisherOptions().to_rcl_publisher_options(rclcpp::QoS(10)), + PublisherOptions().event_callbacks, PublisherOptions().use_default_callbacks) {} }; /*