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

Method tick

src/controls/sequence_node.cpp:39–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39NodeStatus SequenceNode::tick()
40{
41 const size_t children_count = children_nodes_.size();
42
43 if(!isStatusActive(status()))
44 {
45 skipped_count_ = 0;
46 }
47
48 setStatus(NodeStatus::RUNNING);
49
50 while(current_child_idx_ < children_count)
51 {
52 TreeNode* current_child_node = children_nodes_[current_child_idx_];
53
54 auto prev_status = current_child_node->status();
55 const NodeStatus child_status = current_child_node->executeTick();
56
57 switch(child_status)
58 {
59 case NodeStatus::RUNNING: {
60 return NodeStatus::RUNNING;
61 }
62 case NodeStatus::FAILURE: {
63 // Reset on failure
64 resetChildren();
65 current_child_idx_ = 0;
66 return child_status;
67 }
68 case NodeStatus::SUCCESS: {
69 current_child_idx_++;
70 // Return the execution flow if the child is async,
71 // to make this interruptible.
72 if(asynch_ && requiresWakeUp() && prev_status == NodeStatus::IDLE &&
73 current_child_idx_ < children_count)
74 {
75 emitWakeUpSignal();
76 return NodeStatus::RUNNING;
77 }
78 }
79 break;
80
81 case NodeStatus::SKIPPED: {
82 // It was requested to skip this node
83 current_child_idx_++;
84 skipped_count_++;
85 }
86 break;
87
88 case NodeStatus::IDLE: {
89 throw LogicError("[", name(), "]: A children should not return IDLE");
90 }
91 } // end switch
92 } // end while loop
93
94 // The entire while loop completed. This means that all the children returned SUCCESS.
95 const bool all_children_skipped = (skipped_count_ == children_count);
96 if(current_child_idx_ == children_count)

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