Skip to content

Commit

Permalink
[decorators] a passthrough for debugging and visualisation
Browse files Browse the repository at this point in the history
  • Loading branch information
stonier committed Feb 7, 2023
1 parent 9708315 commit 18e1739
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Release Notes

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

2.2.2 (2023-01-28)
Expand Down
27 changes: 27 additions & 0 deletions py_trees/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 18e1739

Please sign in to comment.