diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4e56fd3a..87e260c8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,7 @@ Release Notes Forthcoming ----------- +* [decorators] a passthrough for debugging and visualisation, `#407 `_ * ... 2.2.2 (2023-01-28) diff --git a/py_trees/decorators.py b/py_trees/decorators.py index 65dbc847..c984e16f 100644 --- a/py_trees/decorators.py +++ b/py_trees/decorators.py @@ -893,3 +893,30 @@ def update(self) -> common.Status: if self.decorated.status == self.succeed_status: return common.Status.SUCCESS return common.Status.RUNNING + + +class PassThrough(Decorator): + """ + This decorator simply reflects the child's current status. + + This behaviour is useful for debugging or visualisation purposes. + """ + + def __init__(self, name: str, child: behaviour.Behaviour): + """ + Initialise with the standard decorator arguments. + + Args: + name: the decorator name + child: the child to be decorated + """ + super(PassThrough, self).__init__(name=name, child=child) + + def update(self) -> common.Status: + """ + Just reflect the child status. + + Returns: + the behaviour's new status :class:`~py_trees.common.Status` + """ + return self.decorated.status