@@ -25,8 +25,11 @@ namespace BT
2525 *
2626 * An empty queue will return SUCCESS
2727 */
28+
29+
2830template <typename T>
29- class ConsumeQueue : public DecoratorNode
31+ class [[deprecated(" You are encouraged to use the LoopNode instead" )]]
32+ ConsumeQueue : public DecoratorNode
3033{
3134public:
3235 ConsumeQueue (const std::string& name, const NodeConfig& config) :
@@ -35,6 +38,9 @@ class ConsumeQueue : public DecoratorNode
3538
3639 NodeStatus tick () override
3740 {
41+ // by default, return SUCCESS, even if queue is empty
42+ NodeStatus status_to_be_returned = NodeStatus::SUCCESS;
43+
3844 if (running_child_)
3945 {
4046 NodeStatus child_state = child_node_->executeTick ();
@@ -46,6 +52,7 @@ class ConsumeQueue : public DecoratorNode
4652 else
4753 {
4854 haltChild ();
55+ status_to_be_returned = child_state;
4956 }
5057 }
5158
@@ -79,18 +86,18 @@ class ConsumeQueue : public DecoratorNode
7986 {
8087 return NodeStatus::FAILURE;
8188 }
89+ status_to_be_returned = child_state;
8290 }
8391 }
8492 }
8593
86- return NodeStatus::SUCCESS ;
94+ return status_to_be_returned ;
8795 }
8896
8997 static PortsList providedPorts ()
9098 {
91- return {InputPort<std::shared_ptr<ProtectedQueue<T>>>(" queue" ), OutputPort<T>(" popped"
92- " _ite"
93- " m" )};
99+ return {InputPort<std::shared_ptr<ProtectedQueue<T>>>(" queue" ),
100+ OutputPort<T>(" popped_item" )};
94101 }
95102
96103private:
0 commit comments