From 7d3d907feabdcafc6662cb042f49fbf797870404 Mon Sep 17 00:00:00 2001 From: wanfeng <42433161+starrye@users.noreply.github.com> Date: Tue, 3 Sep 2024 19:26:13 +0800 Subject: [PATCH] [composites] Reduce circulation when the parallel node policy is SuccessOnOne (#440) --- py_trees/composites.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/py_trees/composites.py b/py_trees/composites.py index 83c65725..6326cb48 100644 --- a/py_trees/composites.py +++ b/py_trees/composites.py @@ -731,14 +731,11 @@ def tick(self) -> typing.Iterator[behaviour.Behaviour]: new_status = common.Status.SUCCESS self.current_child = self.children[-1] elif type(self.policy) is common.ParallelPolicy.SuccessOnOne: - successful = [ - child - for child in self.children - if child.status == common.Status.SUCCESS - ] - if successful: - new_status = common.Status.SUCCESS - self.current_child = successful[-1] + for child in reversed(self.children): + if child.status == common.Status.SUCCESS: + new_status = common.Status.SUCCESS + self.current_child = child + break elif type(self.policy) is common.ParallelPolicy.SuccessOnSelected: if all( [c.status == common.Status.SUCCESS for c in self.policy.children]