MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / tick

Method tick

src/controls/sequence_with_memory_node.cpp:24–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24NodeStatus SequenceWithMemory::tick()
25{
26 const size_t children_count = children_nodes_.size();
27
28 if(!isStatusActive(status()))
29 {
30 skipped_count_ = 0;
31 }
32 setStatus(NodeStatus::RUNNING);
33
34 while(current_child_idx_ < children_count)
35 {
36 TreeNode* current_child_node = children_nodes_[current_child_idx_];
37
38 auto prev_status = current_child_node->status();
39 const NodeStatus child_status = current_child_node->executeTick();
40
41 switch(child_status)
42 {
43 case NodeStatus::RUNNING: {
44 return child_status;
45 }
46 case NodeStatus::FAILURE: {
47 // DO NOT reset current_child_idx_ on failure
48 for(size_t i = current_child_idx_; i < childrenCount(); i++)
49 {
50 haltChild(i);
51 }
52
53 return child_status;
54 }
55 case NodeStatus::SUCCESS: {
56 current_child_idx_++;
57 // Return the execution flow if the child is async,
58 // to make this interruptible.
59 if(requiresWakeUp() && prev_status == NodeStatus::IDLE &&
60 current_child_idx_ < children_count)
61 {
62 emitWakeUpSignal();
63 return NodeStatus::RUNNING;
64 }
65 }
66 break;
67
68 case NodeStatus::SKIPPED: {
69 // It was requested to skip this node
70 current_child_idx_++;
71 skipped_count_++;
72 }
73 break;
74
75 case NodeStatus::IDLE: {
76 throw LogicError("[", name(), "]: A children should not return IDLE");
77 }
78 } // end switch
79 } // end while loop
80
81 // The entire while loop completed. This means that all the children returned SUCCESS.

Callers

nothing calls this directly

Calls 5

isStatusActiveFunction · 0.85
LogicErrorClass · 0.85
statusMethod · 0.80
sizeMethod · 0.45
executeTickMethod · 0.45

Tested by

no test coverage detected