summaryrefslogtreecommitdiff
path: root/controllers/final/sleep.py
diff options
context:
space:
mode:
Diffstat (limited to 'controllers/final/sleep.py')
-rw-r--r--controllers/final/sleep.py16
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