diff options
| author | A Farzat <a@farzat.xyz> | 2025-11-27 07:02:52 +0300 |
|---|---|---|
| committer | A Farzat <a@farzat.xyz> | 2025-11-27 07:02:52 +0300 |
| commit | 037c8288f2738791cbf44975ffeee426da6fce19 (patch) | |
| tree | 77d5de7e9f8e13bdfaee2dcc23124557b95396c2 /controllers/final/sleep.py | |
| download | csca5342-037c8288f2738791cbf44975ffeee426da6fce19.tar.gz csca5342-037c8288f2738791cbf44975ffeee426da6fce19.zip | |
Import the project
Diffstat (limited to 'controllers/final/sleep.py')
| -rw-r--r-- | controllers/final/sleep.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/controllers/final/sleep.py b/controllers/final/sleep.py new file mode 100644 index 0000000..34d8fa4 --- /dev/null +++ b/controllers/final/sleep.py @@ -0,0 +1,16 @@ +from py_trees.behaviour import Behaviour +from py_trees.common import Status + +# This provides the same functionality as py_trees's internal Timer class, but +# uses the number of steps instead of time, ensuring the same result regardless +# of the simulation speed. +class Sleep(Behaviour): + def __init__(self, name, steps=20): + super().__init__(name) + self.steps = steps + + def update(self): + while self.steps > 0: + self.steps -= 1 + return Status.RUNNING + return Status.SUCCESS |
