@@ -52,7 +52,7 @@ class RosTopicSubNode : public BT::ConditionNode
52
52
protected:
53
53
struct SubscriberInstance
54
54
{
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 )
56
56
{
57
57
// create a callback group for this particular instance
58
58
callback_group =
@@ -68,7 +68,7 @@ class RosTopicSubNode : public BT::ConditionNode
68
68
{
69
69
broadcaster (msg);
70
70
};
71
- subscriber = node->create_subscription <TopicT>(topic_name, 1 , callback, option);
71
+ subscriber = node->create_subscription <TopicT>(topic_name, qos_profile , callback, option);
72
72
}
73
73
74
74
std::shared_ptr<Subscriber> subscriber;
@@ -98,6 +98,7 @@ class RosTopicSubNode : public BT::ConditionNode
98
98
std::string topic_name_;
99
99
boost::signals2::connection signal_connection_;
100
100
std::string subscriber_key_;
101
+ rclcpp::QoS qos_profile_;
101
102
102
103
rclcpp::Logger logger ()
103
104
{
@@ -175,7 +176,7 @@ class RosTopicSubNode : public BT::ConditionNode
175
176
176
177
private:
177
178
178
- bool createSubscriber (const std::string& topic_name);
179
+ bool createSubscriber (const std::string& topic_name, const rclcpp::QoS& qos_profile );
179
180
};
180
181
181
182
// ----------------------------------------------------------------
@@ -187,7 +188,7 @@ template<class T> inline
187
188
const NodeConfig &conf,
188
189
const RosNodeParams& params)
189
190
: BT::ConditionNode(instance_name, conf),
190
- node_ (params.nh)
191
+ node_ (params.nh), qos_profile_(params.qos_profile)
191
192
{
192
193
// check port remapping
193
194
auto portIt = config ().input_ports .find (" topic_name" );
@@ -202,15 +203,15 @@ template<class T> inline
202
203
" Both [topic_name] in the InputPort and the RosNodeParams are empty." );
203
204
}
204
205
else {
205
- createSubscriber (params.default_port_value );
206
+ createSubscriber (params.default_port_value , params. qos_profile );
206
207
}
207
208
}
208
209
else if (!isBlackboardPointer (bb_topic_name))
209
210
{
210
211
// If the content of the port "topic_name" is not
211
212
// a pointer to the blackboard, but a static string, we can
212
213
// create the client in the constructor.
213
- createSubscriber (bb_topic_name);
214
+ createSubscriber (bb_topic_name, params. qos_profile );
214
215
}
215
216
else {
216
217
// do nothing
@@ -223,13 +224,13 @@ template<class T> inline
223
224
" Both [topic_name] in the InputPort and the RosNodeParams are empty." );
224
225
}
225
226
else {
226
- createSubscriber (params.default_port_value );
227
+ createSubscriber (params.default_port_value , params. qos_profile );
227
228
}
228
229
}
229
230
}
230
231
231
232
template <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 )
233
234
{
234
235
if (topic_name.empty ())
235
236
{
@@ -250,7 +251,7 @@ template<class T> inline
250
251
{
251
252
it = registry.insert ( {subscriber_key_, std::make_shared<SubscriberInstance>() }).first ;
252
253
sub_instance_ = it->second ;
253
- sub_instance_->init (node_, topic_name);
254
+ sub_instance_->init (node_, topic_name, qos_profile );
254
255
255
256
RCLCPP_INFO (logger (),
256
257
" Node [%s] created Subscriber to topic [%s]" ,
@@ -266,6 +267,7 @@ template<class T> inline
266
267
[this ](const std::shared_ptr<T> msg) { last_msg_ = msg; } );
267
268
268
269
topic_name_ = topic_name;
270
+
269
271
return true ;
270
272
}
271
273
@@ -280,7 +282,7 @@ template<class T> inline
280
282
{
281
283
std::string topic_name;
282
284
getInput (" topic_name" , topic_name);
283
- createSubscriber (topic_name);
285
+ createSubscriber (topic_name, qos_profile_ );
284
286
}
285
287
286
288
auto CheckStatus = [](NodeStatus status)
0 commit comments