Skip to content

Commit

Permalink
Update Chooser composite for issue #6
Browse files Browse the repository at this point in the history
  • Loading branch information
hagyutae committed Apr 18, 2018
1 parent aa3e4f7 commit 817f6d3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions py_trees/src/py_trees/composites.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,16 @@ def tick(self):
if child is self.current_child:
for node in self.current_child.tick():
yield node
elif child.status != Status.INVALID:
child.stop(Status.INVALID)
if child.status == Status.FAILURE:
if not self.is_last_child(child):
child.stop(Status.FAILURE)
next_index = self.children.index(child) + 1
self.current_child = self.children[next_index]
for _node in self.current_child.tick():
yield _node
self.status = self.current_child.status
yield self
return
else:
for child in self.children:
for node in child.tick():
Expand All @@ -382,6 +390,9 @@ def tick(self):
self.stop(new_status)
yield self

def is_last_child(self, child):
return self.children and child == self.children[-1]

##############################################################################
# Sequence
##############################################################################
Expand Down

0 comments on commit 817f6d3

Please sign in to comment.