File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
behaviortree_ros2/include/behaviortree_ros2 Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -173,6 +173,16 @@ class RosTopicSubNode : public BT::ConditionNode
173173 */
174174 virtual NodeStatus onTick (const std::shared_ptr<TopicT>& last_msg) = 0;
175175
176+ /* * Clear the message that has been processed. If returns true and no new message is
177+ * received, before next call there will be no message to process. If returns false,
178+ * the next call will process the same message again, if no new message received.
179+ *
180+ * This can be equated with latched vs non-latched topics in ros 1.
181+ *
182+ * @return true will clear the message after ticking/processing.
183+ */
184+ virtual bool clear_processed_message () { return true ; }
185+
176186private:
177187
178188 bool createSubscriber (const std::string& topic_name);
@@ -294,8 +304,10 @@ template<class T> inline
294304 };
295305 sub_instance_->callback_group_executor .spin_some ();
296306 auto status = CheckStatus (onTick (last_msg_));
297- last_msg_ = nullptr ;
298-
307+ if (clear_processed_message ())
308+ {
309+ last_msg_ = nullptr ;
310+ }
299311 return status;
300312}
301313
You can’t perform that action at this time.
0 commit comments