robokudo.utils.tree =================== .. py:module:: robokudo.utils.tree Functions --------- .. autoapisummary:: robokudo.utils.tree.behavior_iterate_except_type robokudo.utils.tree.find_parent_of_type robokudo.utils.tree.find_children_with_name robokudo.utils.tree.get_scoped_list_of_names robokudo.utils.tree.get_scoped_name robokudo.utils.tree.setup_with_descendants_rk robokudo.utils.tree.setup_with_descendants_on_behavior robokudo.utils.tree.fix_parent_relationship_of_childs robokudo.utils.tree.find_root Module Contents --------------- .. py:function:: behavior_iterate_except_type(tree: py_trees.Behaviour, child_type, direct_descendants=False, include_tree=False) Generator similar to Behavior.iterate(). But this one doesn't traverse nodes of a specific type. It also traverses in a post-order manner like Behavior.iterate(). @param include_tree will control if you want to include 'tree' itself in the enumeration, like it is done in Behavior.iterate() .. py:function:: find_parent_of_type(behaviour: py_trees.Behaviour, parent_type) -> Optional[py_trees.Behaviour] Traverse the given behaviour up until we either hit the top of the tree or find a node of type parent_type. :return: return the first parent with type == parent_type. None otherwise .. py:function:: find_children_with_name(composite: py_trees.Composite, name: str, direct_descendants=False) -> Optional[py_trees.Behaviour] Iterate() the given composite over its children and return the first child with child.name == name. :return: Found child or None .. py:function:: get_scoped_list_of_names(behaviour: py_trees.Behaviour, scoping_behaviour_type) -> list This method can generate behaviour names which represent the structure of the tree. For that, we can prefix (or scope) the name of the input behaviour with a scoping behaviour parent. Imagine a tree like this: Sequence ("Z") | Sequence ("Y") | Behaviour ("B") Then get_scoped_list(b,Sequence) would return a list of the instances [B,Y,Z] :return: The scoped name like described above .. py:function:: get_scoped_name(behaviour: py_trees.Behaviour, scoping_behaviour_type, delimiter='/') -> str .. py:function:: setup_with_descendants_rk(tree: py_trees_ros.trees.BehaviourTree, setup_timeout=0) Call setup(0) on all children of tree.root :param tree: A py_trees_ros.trees.BehaviourTree which already constains all trees that should be setup'ed during startup. :param setup_timeout: Timeout value that is passed to the setup of each child. .. py:function:: setup_with_descendants_on_behavior(tree: py_trees.Behaviour, setup_timeout=0) Call setup(0) on all children of tree :param tree: A Behaviour, which might also be a composition :param setup_timeout: Timeout value that is passed to the setup of each child. .. py:function:: fix_parent_relationship_of_childs(behavior: py_trees.behaviour.Behaviour) Iterate top-down over this tree and reset the parent relationship for all childs. This may be required if you dynamically assign the same instance of a Behavior Tree node into different parts of the BT or also have the same instance in multiple individual Behavior Trees. :param behavior: The behavior to start with. This is typically the root node of the tree you need to "repair" .. py:function:: find_root(behavior: py_trees.Behaviour) -> Optional[py_trees.Behaviour] Find the root of this behavior tree :param behavior: :return: A py_trees.Behaviour or None