Skip to content

Commit 9bce189

Browse files
committed
[decorators] a passthrough for debugging and visualisation
1 parent 9708315 commit 9bce189

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Release Notes
33

44
Forthcoming
55
-----------
6+
* [decorators] a passthrough for debugging and visualisation, `#407 <https://github.com/splintered-reality/py_trees/pull/407>`_
67
* ...
78

89
2.2.2 (2023-01-28)

py_trees/decorators.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,3 +893,30 @@ def update(self) -> common.Status:
893893
if self.decorated.status == self.succeed_status:
894894
return common.Status.SUCCESS
895895
return common.Status.RUNNING
896+
897+
898+
class PassThrough(Decorator):
899+
"""
900+
This decorator simply reflects the child's current status.
901+
902+
This behaviour is useful for debugging or visualisation purposes.
903+
"""
904+
905+
def __init__(self, name: str, child: behaviour.Behaviour):
906+
"""
907+
Initialise with the standard decorator arguments.
908+
909+
Args:
910+
name: the decorator name
911+
child: the child to be decorated
912+
"""
913+
super(PassThrough, self).__init__(name=name, child=child)
914+
915+
def update(self) -> common.Status:
916+
"""
917+
Just reflect the child status.
918+
919+
Returns:
920+
the behaviour's new status :class:`~py_trees.common.Status`
921+
"""
922+
return self.decorated.status

0 commit comments

Comments
 (0)