This page provides a detailed overview about the do if node.
Contents
Node Description
Do If Node
The do if node is used to check a condition and only execute specific logic when it the condition is true, for example, a variable being equal to a certain value.
If a Do If node’s condition is false, the Do If node will return failure. Unlike the Loop If Node, it does not loop through its children, i.e. the children are run at most once and return.
Node Type
Composite - has 0 or more children, and is typically used to control the logical flow of execution of the tree.
Node Inspector
- ID
Not editable
- name
Auto generated and user editable
- track cycle time
Determines the cycle time of how long it takes to execute the branch; the time it takes to complete all children contained within the Do If node. When turned on, it will create a variable for the specific Do If Node in Shared Data.
- keep evaluating
When switched off (false, the default) the do if node only tests the condition at the start of the sequence, and acts as a 'gate' prior to running the first child. This means that if the condition(s) of the do if node are no longer met while the children of the do if node are running, the node will continue to execute to completion. When keep evaluating is turned on (true), the Do If Node will continue to check if the condition(s) while the children are executing below, and it will immediately stop executing the children as soon as the condition(s) are no longer met.
- invert condition
Enabling the option will invert the results of the logic. If it evaluates to true, it will change it false and vice versa.
- stop on failure
By default this is set to false meaning that the Do If actions will not stop if and when any of its children return failure. Set this to true if you want the Do If to end when a child returns failure.
- +
Clicking the + enables you to add any number of conditions to form AND and OR equations. The lowest + creates a separate parenthesis, where as the inner + creates an additional condition inside the current parenthesis. For the example below Condition = ((Variable1 OR Variable2) AND Variable3)
Condition
- variable
drop down list - choose the variable or signal to be checked from the list, or start typing to filter the list.
- logic
Choose the logic for the variable.
- variable or value
Enter a value or select a variable for comparison.
- Comments
User editable - add comments about this node.
Benefits
Do If nodes are used extensively in tasks to control the flow of logic based on signals, variables, and measured forces. They can be used to add "smarts" to the logic, such as checking for a missed pick and attempting again, then throwing an error if the maximum number of attempts were made.
Example
In the example below, a robot grasps on to a wheel and turns it to determine if it can move freely as an inspection process. There is a Do If that checks a signal which will determine whether the entire branch will be executed or not. The next Do If node looks at the measured torque and since "keep evaluating" is enabled, it will jump out of that branch when the torque limit is met. The last Do If nodes checks a variable to determine if the error condition should be executed.