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

Method tick

src/controls/parallel_all_node.cpp:25–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23{}
24
25NodeStatus ParallelAllNode::tick()
26{
27 int max_failures = 0;
28 if(!getInput("max_failures", max_failures))
29 {
30 throw RuntimeError("Missing parameter [max_failures] in ParallelNode");
31 }
32 const size_t children_count = children_nodes_.size();
33 setFailureThreshold(max_failures);
34
35 size_t skipped_count = 0;
36
37 if(children_count < failure_threshold_)
38 {
39 throw LogicError("Number of children is less than threshold. Can never fail.");
40 }
41
42 setStatus(NodeStatus::RUNNING);
43
44 // Routing the tree according to the sequence node's logic:
45 for(size_t index = 0; index < children_count; index++)
46 {
47 TreeNode* child_node = children_nodes_[index];
48
49 // already completed
50 if(completed_list_.count(index) != 0)
51 {
52 continue;
53 }
54
55 NodeStatus const child_status = child_node->executeTick();
56
57 switch(child_status)
58 {
59 case NodeStatus::SUCCESS: {
60 completed_list_.insert(index);
61 }
62 break;
63
64 case NodeStatus::FAILURE: {
65 completed_list_.insert(index);
66 failure_count_++;
67 }
68 break;
69
70 case NodeStatus::RUNNING: {
71 // Still working. Check the next
72 }
73 break;
74
75 case NodeStatus::SKIPPED: {
76 skipped_count++;
77 }
78 break;
79
80 case NodeStatus::IDLE: {
81 throw LogicError("[", name(), "]: A children should not return IDLE");
82 }

Callers

nothing calls this directly

Calls 5

RuntimeErrorClass · 0.85
LogicErrorClass · 0.85
sizeMethod · 0.45
executeTickMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected