summaryrefslogtreecommitdiff
path: root/simulation/controllers/Soccer_Ball/Soccer_Ball.py
diff options
context:
space:
mode:
authorAbel Tim <abel.tim.t@gmail.com>2024-07-27 12:56:13 +0200
committerAbel Tim <abel.tim.t@gmail.com>2024-07-27 12:56:13 +0200
commit3d4f59f1a32b86f0193d7dea9a59a6ad7f90b16e (patch)
tree5f1f6bb0bd5f73bcefeab5b0bb46fe835f433ab9 /simulation/controllers/Soccer_Ball/Soccer_Ball.py
parentbee143bfbc078a07af52cf8ca675e80a7b30fb6c (diff)
downloadrobotica-3d4f59f1a32b86f0193d7dea9a59a6ad7f90b16e.tar.gz
robotica-3d4f59f1a32b86f0193d7dea9a59a6ad7f90b16e.zip
PCB schemas
Diffstat (limited to 'simulation/controllers/Soccer_Ball/Soccer_Ball.py')
-rw-r--r--simulation/controllers/Soccer_Ball/Soccer_Ball.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/simulation/controllers/Soccer_Ball/Soccer_Ball.py b/simulation/controllers/Soccer_Ball/Soccer_Ball.py
new file mode 100644
index 0000000..70a26d7
--- /dev/null
+++ b/simulation/controllers/Soccer_Ball/Soccer_Ball.py
@@ -0,0 +1,18 @@
+from controller import Robot, Emitter
+import time
+
+robot = Robot()
+emitter = robot.getDevice("emitter")
+
+# Time step of the simulation
+timestep = int(robot.getBasicTimeStep())
+
+# Pulse emission interval (e.g., 1 pulse per second)
+pulse_interval = 1.0
+
+# Main loop
+while robot.step(timestep) != -1:
+ current_time = robot.getTime()
+ if int(current_time) % pulse_interval == 0:
+ emitter.send(b'\x01') # Emit a single byte pulse
+ time.sleep(1.0 / pulse_interval)