From 037c8288f2738791cbf44975ffeee426da6fce19 Mon Sep 17 00:00:00 2001 From: A Farzat Date: Thu, 27 Nov 2025 07:02:52 +0300 Subject: Import the project --- controllers/final/sleep.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 controllers/final/sleep.py (limited to 'controllers/final/sleep.py') 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 -- cgit v1.2.3-70-g09d2