Skip to content

Commit b051715

Browse files
author
Davide Faconti
committed
fix important issue with SubtreeNode
1 parent 287637e commit b051715

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

examples/t05_crossdoor.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,16 @@ int main()
6767
PublisherZMQ publisher_zmq(tree.root_node);
6868
#endif
6969

70-
// Keep on ticking until you get either a SUCCESS or FAILURE state
71-
NodeStatus status = NodeStatus::RUNNING;
72-
while (status == NodeStatus::RUNNING)
70+
//while (1)
7371
{
74-
status = tree.root_node->executeTick();
75-
CrossDoor::SleepMS(1); // optional sleep to avoid "busy loops"
72+
NodeStatus status = NodeStatus::RUNNING;
73+
// Keep on ticking until you get either a SUCCESS or FAILURE state
74+
while( status == NodeStatus::RUNNING)
75+
{
76+
status = tree.root_node->executeTick();
77+
CrossDoor::SleepMS(1); // optional sleep to avoid "busy loops"
78+
}
79+
CrossDoor::SleepMS(2000);
7680
}
7781
return 0;
7882
}

include/behaviortree_cpp/decorators/subtree_node.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ class DecoratorSubtreeNode : public DecoratorNode
2424
}
2525
auto status = child_node_->executeTick();
2626
setStatus(status);
27+
28+
// reset child if completed
29+
if( status == NodeStatus::SUCCESS || status == NodeStatus::FAILURE)
30+
{
31+
child_node_->setStatus(NodeStatus::IDLE);
32+
}
2733
return status;
2834
}
2935
};

0 commit comments

Comments
 (0)