Skip to main content

Sequence node

Sequence node representation

The sequence node has a number of children that are executed in order. When the root sequence node gets selected, it will immediately transition to Running (after checking the decorators). While in Running, it will select the child node for which all predecessors have succeeded (or where there is none for the first child). If any child fails, the sequence node transitions to Failed. If all children pass, the sequence node moves to Succeeded.

Properties

PropertyDescription
Child semanticsExecuted in order
Parametersname: name of the node
children: ordered list of sub-trees
Success criterionAll children have succeeded
Failure criterionAny child fails

Python API

The node can be constructed by parameterizing it either on creation or by using the builder pattern as shown below. You can use Task nodes and actions interchangeably.

# Define the enable_motion skill.
enable_motion_skill = skills.enable_motion(clear_faults=True)
enable_gripper_skill = skills.enable_pinch_gripper()

# Define the corresponding sequence using actions
enable_1 = BT.Sequence(children=[enable_motion_skill, enable_gripper_skill])

# Define the corresponding sequence using a mix of task nodes and actions
enable_2 = BT.Sequence(children=[BT.Task(name="Enable motion", action=enable_motion_skill),
enable_gripper_skill])

# Define the corresponding sequence using the builder pattern
enable_3 = BT.Sequence().set_children([BT.Task(name="Enable motion", action=enable_motion_skill),
enable_gripper_skill])