Skip to main content

Selector node

Selector node representation

The selector node has a number of children which will be tried in order. When the root selector 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 failing decorator conditions (or where there is none for the first child). Once any child succeeds, the selector node will transition to Succeeded as well. If any child fails during execution (as long as it isn't a decorator failure), the whole node will fail.

Properties

PropertyDescription
Child semanticsChildren are executed in-order until one child succeeds or all have failed (with a condition failure).
Parametersname: name of the node
children: ordered list of sub-trees
Success criterionExactly one child has succeeded, if any other children were tried before, they can only have failed with a condition failure.
Failure criterionAll children have failed in the condition stage, or at least one node has failed execution (beyond condition evaluation).

Python API

The node can be constructed by parameterizing it either on creation or by using the builder pattern. Note that the decorator attached to the children determines which child is chosen to be executed.

pick_connector_1 = BT.Sequence(children=[approach_connector_1, pick_connector_1])
pick_connector_1.set_decorators(BT.Decorators(BT.SubTreeCondition(tree=estimate_connector_1)))
pick_connector_2 = BT.Sequence(children=[approach_connector_2, pick_connector_2])
pick_connector_2.set_decorators(BT.Decorators(BT.SubTreeCondition(tree=estimate_connector_2)))
pick_connector_3 = BT.Sequence(children=[approach_connector_3, pick_connector_3])
pick_connector_3.set_decorators(BT.Decorators(BT.SubTreeCondition(tree=estimate_connector_3)))

selector_node = BT.Selector(children=[pick_connector_1, pick_connector_2, pick_connector_3])