This page provides a detailed overview about the Loop Node.
Contents
Node Description
Loop Node
The Loop node is used to run its children in order and repeats until a specified max count is reached. By default, Loop nodes loop through their children as long as the node’s current count is less than the max loop count. Each time through the loop, the node’s current count is incremented by 1.
Node Type
Composite - has 0 or more children, and is typically used to control the logical flow of execution of the tree.
Node Editor
- ID
Not editable
- Name
Auto generated and user editable
- track cycle time
Determines the time it takes to execute and exit the Loop node. Creates a "cycleTime" variable for the specific Loop node in Shared Data. Note that the cycle time will not be calculated until the Loop node completes and returns to the next node in the task. For example, the cycle time for a Loop node with 5 loops will be the total time to execute all 5 loops.
- max loop count
Specifies the maximum times the loop will loop. By default, set to 5. Select infinity by clicking the infinity switch. To use a variable to specify max loop count, see the user variable control property below.
- user variable control
If this is checked the user must specify a variable that will be used to specify the max loop count instead of entering a constant. The max loop count entry will change to a drop down list called user variable control. The variable must be an integer. Use this option when the number of loops must be controlled by some aspect of the task (number of locations in a pattern, for example).
- stop on failure
By default this is set to false meaning that the loop will not stop if any of its children return failure. Set this to true if the loop should end if a child returns failure.
Benefits
The nodes in the behavior tree are executed from left to right, top to bottom. The tree does not repeat itself (like the scan of ladder logic in a PLC), so a Loop node must be incorporated. It is included automatically when starting with a Basic Task. Most tasks will have only 1 loop node. A second loop node is most often added in parallel with the robot branch to execute logic like a PLC. It is possible to add another loop node, but it is important to limit the number of loops, or add a Do If with "keep evaluating" enabled so that the logic does not get stuck in that loop.
Example
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article