diff --git a/common/autoware_agnocast_wrapper/include/autoware/agnocast_wrapper/message_filters.hpp b/common/autoware_agnocast_wrapper/include/autoware/agnocast_wrapper/message_filters.hpp index a1dcb4bcd0..bea7c2a81a 100644 --- a/common/autoware_agnocast_wrapper/include/autoware/agnocast_wrapper/message_filters.hpp +++ b/common/autoware_agnocast_wrapper/include/autoware/agnocast_wrapper/message_filters.hpp @@ -461,17 +461,17 @@ namespace message_filters /// underlying rclcpp::Node. Inherited upstream members (connectInput, registerCallback, ...) /// are non-portable — they do not exist on the Agnocast-build Subscriber. template -class Subscriber : public ::message_filters::Subscriber +class Subscriber : public ::message_filters::Subscriber { public: - using Base = ::message_filters::Subscriber; + using Base = ::message_filters::Subscriber; Subscriber() = default; Subscriber( autoware::agnocast_wrapper::Node * node, const std::string & topic, const rmw_qos_profile_t qos = rmw_qos_profile_default) - : Base(node->get_rclcpp_node().get(), topic, qos) + : Base(node->get_rclcpp_node().get(), topic, to_base_qos(qos)) { } @@ -479,7 +479,18 @@ class Subscriber : public ::message_filters::Subscriber autoware::agnocast_wrapper::Node * node, const std::string & topic, const rmw_qos_profile_t qos = rmw_qos_profile_default) { - Base::subscribe(node->get_rclcpp_node().get(), topic, qos); + Base::subscribe(node->get_rclcpp_node().get(), topic, to_base_qos(qos)); + } + +private: + // message_filters on ROS 2 Lyrical and later takes rclcpp::QoS, and removed subscriber.h. + static auto to_base_qos(const rmw_qos_profile_t & qos) + { +#if __has_include() + return qos; +#else + return rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos), qos); +#endif } }; diff --git a/perception/autoware_ground_filter/src/ground_filter_node.cpp b/perception/autoware_ground_filter/src/ground_filter_node.cpp index ed44230196..1c2e6a7022 100644 --- a/perception/autoware_ground_filter/src/ground_filter_node.cpp +++ b/perception/autoware_ground_filter/src/ground_filter_node.cpp @@ -41,6 +41,16 @@ bool get_param(const std::vector & p, const std::string & nam } return false; } + +// message_filters on ROS 2 Lyrical and later takes rclcpp::QoS, and removed subscriber.h. +auto to_message_filters_qos(const rclcpp::QoS & qos) +{ +#if __has_include() + return qos.get_rmw_qos_profile(); +#else + return qos; +#endif +} } // namespace namespace autoware::ground_filter @@ -189,9 +199,9 @@ void GroundFilterComponent::subscribe() if (use_indices_) { // Subscribe to the input using a filter sub_input_filter_.subscribe( - this, "input", rclcpp::SensorDataQoS().keep_last(max_queue_size_).get_rmw_qos_profile()); + this, "input", to_message_filters_qos(rclcpp::SensorDataQoS().keep_last(max_queue_size_))); sub_indices_filter_.subscribe( - this, "indices", rclcpp::SensorDataQoS().keep_last(max_queue_size_).get_rmw_qos_profile()); + this, "indices", to_message_filters_qos(rclcpp::SensorDataQoS().keep_last(max_queue_size_))); if (approximate_sync_) { sync_input_indices_a_ = std::make_shared<