This page provides a detailed overview about the Loop If node.
Contents
Node Description
Loop If Node
The Loop If node is used to loop only if the defined condition is true.
The Loop If node loops through its children while its condition is true. By default, the Loop If node only tests the condition once each time through the loop, and that test occurs prior to running (or re-running) the first child. This means that if the condition becomes false during the execution of child nodes, the Loop If node will continue to execute all of its remaining children. Once the loop completes, the Loop If will return and perform the condition test. Only if the condition is false at this point, the Loop If node will exit.
If a Loop If node stops running because its condition failed, it will still return success to its parent. Like the Loop node, by default the stop on failure property is set to false.
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 If node. Creates a "cycleTime" variable for the specific Loop If node in Shared Data. Note that the cycle time will not be calculated until the Loop If node completes and returns to the next node in the task. For example, the cycle time for a Loop If node which has been active for 5 loops will be the total time to execute all 5 loops.
- 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.
- +
clicking the + enables the user to add any number of conditions.
Condition
- variable
drop down list - choose from a list of variables.
- logic
Choose the logic for the variable.
- variable or value
Enter the set point for the variable or value.
- Comments
User editable - add comments about this node.
Note: If a Loop If node´s condition utilizes a user variable to control looping, be sure to initialize the variable before running the Loop If node.
Benefits
The Loop If node is similar to a Loop node, but with the added feature of checking a condition before running each loop. Use this node to execute an action repeatedly while a certain condition is true.
Example
In the example below, Sawyer is in a Loop If picking objects and placing them onto a scale. When the scale reaches a specific weight, the Scale Full signal is received, and the LOOP IF ends. Sawyer continues to evaluate the Scale Full signal and jumps back into the loop when the signal is reset.