@@ -52,7 +52,7 @@ class RosTopicSubNode : public BT::ConditionNode
5252 protected:
5353 struct SubscriberInstance
5454 {
55- void init (std::shared_ptr<rclcpp::Node> node, const std::string& topic_name)
55+ void init (std::shared_ptr<rclcpp::Node> node, const std::string& topic_name, const rclcpp::QoS& qos_profile )
5656 {
5757 // create a callback group for this particular instance
5858 callback_group =
@@ -68,7 +68,7 @@ class RosTopicSubNode : public BT::ConditionNode
6868 {
6969 broadcaster (msg);
7070 };
71- subscriber = node->create_subscription <TopicT>(topic_name, 1 , callback, option);
71+ subscriber = node->create_subscription <TopicT>(topic_name, qos_profile , callback, option);
7272 }
7373
7474 std::shared_ptr<Subscriber> subscriber;
@@ -98,6 +98,7 @@ class RosTopicSubNode : public BT::ConditionNode
9898 std::string topic_name_;
9999 boost::signals2::connection signal_connection_;
100100 std::string subscriber_key_;
101+ rclcpp::QoS qos_profile_;
101102
102103 rclcpp::Logger logger ()
103104 {
@@ -175,7 +176,7 @@ class RosTopicSubNode : public BT::ConditionNode
175176
176177private:
177178
178- bool createSubscriber (const std::string& topic_name);
179+ bool createSubscriber (const std::string& topic_name, const rclcpp::QoS& qos_profile );
179180};
180181
181182// ----------------------------------------------------------------
@@ -187,7 +188,7 @@ template<class T> inline
187188 const NodeConfig &conf,
188189 const RosNodeParams& params)
189190 : BT::ConditionNode(instance_name, conf),
190- node_ (params.nh)
191+ node_ (params.nh), qos_profile_(params.qos_profile)
191192{
192193 // check port remapping
193194 auto portIt = config ().input_ports .find (" topic_name" );
@@ -202,15 +203,15 @@ template<class T> inline
202203 " Both [topic_name] in the InputPort and the RosNodeParams are empty." );
203204 }
204205 else {
205- createSubscriber (params.default_port_value );
206+ createSubscriber (params.default_port_value , params. qos_profile );
206207 }
207208 }
208209 else if (!isBlackboardPointer (bb_topic_name))
209210 {
210211 // If the content of the port "topic_name" is not
211212 // a pointer to the blackboard, but a static string, we can
212213 // create the client in the constructor.
213- createSubscriber (bb_topic_name);
214+ createSubscriber (bb_topic_name, params. qos_profile );
214215 }
215216 else {
216217 // do nothing
@@ -223,13 +224,13 @@ template<class T> inline
223224 " Both [topic_name] in the InputPort and the RosNodeParams are empty." );
224225 }
225226 else {
226- createSubscriber (params.default_port_value );
227+ createSubscriber (params.default_port_value , params. qos_profile );
227228 }
228229 }
229230}
230231
231232template <class T > inline
232- bool RosTopicSubNode<T>::createSubscriber(const std::string& topic_name)
233+ bool RosTopicSubNode<T>::createSubscriber(const std::string& topic_name, const rclcpp::QoS& qos_profile )
233234{
234235 if (topic_name.empty ())
235236 {
@@ -250,7 +251,7 @@ template<class T> inline
250251 {
251252 it = registry.insert ( {subscriber_key_, std::make_shared<SubscriberInstance>() }).first ;
252253 sub_instance_ = it->second ;
253- sub_instance_->init (node_, topic_name);
254+ sub_instance_->init (node_, topic_name, qos_profile );
254255
255256 RCLCPP_INFO (logger (),
256257 " Node [%s] created Subscriber to topic [%s]" ,
@@ -266,6 +267,7 @@ template<class T> inline
266267 [this ](const std::shared_ptr<T> msg) { last_msg_ = msg; } );
267268
268269 topic_name_ = topic_name;
270+
269271 return true ;
270272}
271273
@@ -280,7 +282,7 @@ template<class T> inline
280282 {
281283 std::string topic_name;
282284 getInput (" topic_name" , topic_name);
283- createSubscriber (topic_name);
285+ createSubscriber (topic_name, qos_profile_ );
284286 }
285287
286288 auto CheckStatus = [](NodeStatus status)
0 commit comments