Skip to content

Commit 63fffdf

Browse files
committed
Revert "Copied chooser definition"
This reverts commit a3904a4.
1 parent a3904a4 commit 63fffdf

File tree

1 file changed

+0
-71
lines changed

1 file changed

+0
-71
lines changed

py_trees/composites.py

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -699,74 +699,3 @@ def validate_policy_configuration(self):
699699
"not children of this parallel {}[{}]""".format(missing_children_names, self.name))
700700
self.logger.error(error_message)
701701
raise RuntimeError(error_message)
702-
703-
##############################################################################
704-
# Chooser with Memory
705-
##############################################################################
706-
707-
class ChooserWithMemory(Selector):
708-
"""
709-
Choosers are Selectors with Commitment
710-
711-
.. graphviz:: dot/chooser.dot
712-
713-
A variant of the selector class. Once a child is selected, it
714-
cannot be interrupted by higher priority siblings. As soon as the chosen child
715-
itself has finished it frees the chooser for an alternative selection. i.e. priorities
716-
only come into effect if the chooser wasn't running in the previous tick.
717-
718-
.. note::
719-
This is the only composite in py_trees that is not a core composite in most behaviour tree implementations.
720-
Nonetheless, this is useful in fields like robotics, where you have to ensure that your manipulator doesn't
721-
drop it's payload mid-motion as soon as a higher interrupt arrives. Use this composite
722-
sparingly and only if you can't find another way to easily create an elegant tree composition for your task.
723-
724-
Args:
725-
name (:obj:`str`): the composite behaviour name
726-
children ([:class:`~py_trees.behaviour.Behaviour`]): list of children to add
727-
"""
728-
729-
def __init__(self, name="Chooser", children=None):
730-
super(ChooserWithMemory, self).__init__(name, children)
731-
732-
def tick(self):
733-
"""
734-
Run the tick behaviour for this chooser. Note that the status
735-
of the tick is (for now) always determined by its children, not
736-
by the user customised update function.
737-
738-
Yields:
739-
:class:`~py_trees.behaviour.Behaviour`: a reference to itself or one of its children
740-
"""
741-
self.logger.debug("%s.tick()" % self.__class__.__name__)
742-
# Required behaviour for *all* behaviours and composites is
743-
# for tick() to check if it isn't running and initialise
744-
if self.status != Status.RUNNING:
745-
# chooser specific initialisation
746-
# invalidate everything
747-
for child in self.children:
748-
child.stop(Status.INVALID)
749-
self.current_child = None
750-
# run subclass (user) initialisation
751-
self.initialise()
752-
# run any work designated by a customised instance of this class
753-
self.update()
754-
if self.current_child is not None:
755-
# run our child, and invalidate anyone else who may have been ticked last run
756-
# (bit wasteful always checking for the latter)
757-
for child in self.children:
758-
if child is self.current_child:
759-
for node in self.current_child.tick():
760-
yield node
761-
elif child.status != Status.INVALID:
762-
child.stop(Status.INVALID)
763-
else:
764-
for child in self.children:
765-
for node in child.tick():
766-
yield node
767-
if child.status == Status.RUNNING or child.status == Status.SUCCESS:
768-
self.current_child = child
769-
break
770-
new_status = self.current_child.status if self.current_child is not None else Status.FAILURE
771-
self.stop(new_status)
772-
yield self

0 commit comments

Comments
 (0)