A library of subtree creators that build complex patterns of behaviours representing common behaviour tree idioms.
Common decision making patterns can often be realised using a specific combination of fundamental behaviours and the blackboard. Even if this somewhat verbosely populates the tree, this is preferable to creating new composites types or overriding existing composites since this will increase tree logic complexity and/or bury details under the hood (both of which add an exponential cost to introspection/visualisation).
In this package these patterns will be referred to as PyTree Idioms and in this module you will find convenience functions that assist in creating them.
The subsections below introduce each composite briefly. For a full listing of each composite’s methods, visit the py_trees.idioms module api documentation.
First time through, make sure to follow the link through to relevant demo programs.
oneshot(variable_name='oneshot', behaviour=<py_trees.meta.Dummy object>, policy=<OneShotPolicy.ON_SUCCESSFUL_COMPLETION: [<Status.SUCCESS: 'SUCCESS'>]>)
Ensure that a particular pattern is executed through to completion just once. Thereafter it will just rebound with success.
SUCCESSonly (permits retries if it fails) is determined by the policy.
the root of the oneshot subtree
Pickup Where You left Off¶
pick_up_where_you_left_off(tasks=[<py_trees.meta.Dummy object>, <py_trees.meta.Dummy object>])
Rudely interrupted while enjoying a sandwich, a caveman (just because they wore loincloths does not mean they were not civilised), picks up his club and fends off the sabre-tooth tiger invading his sanctum as if he were swatting away a gnat. Task accomplished, he returns to the joys of munching through the layers of his sandwich.
There are alternative ways to accomplish this idiom with their pros and cons.
a) The tasks in the sequence could be replaced by a factory behaviour that dynamically checks the state of play and spins up the tasks required each time the task sequence is first entered and invalidates/deletes them when it is either finished or invalidated. That has the advantage of not requiring much of the blackboard machinery here, but disadvantage in not making visible the task sequence itself at all times (i.e. burying details under the hood).
b) A new composite which retains the index between initialisations can also achieve the same pattern with fewer blackboard shenanigans, but suffers from an increased logical complexity cost for your trees (each new composite increases decision making complexity (O(n!)).
root of the generated subtree