rparedis 2 лет назад
Родитель
Сommit
3da800b34f
2 измененных файлов с 33 добавлено и 0 удалено
  1. 5 0
      README.md
  2. 28 0
      battery/run.py

+ 5 - 0
README.md

@@ -0,0 +1,5 @@
+# EV3 Experimentation
+This repository collects all data for a plethora of experiments pertaining the EV3 Line Follower Robot.
+
+### battery
+Contains source and data files for running battery level experiments.

+ 28 - 0
battery/run.py

@@ -0,0 +1,28 @@
+#!/usr/bin/env pybricks-micropython
+
+from pybricks.ev3devices import Motor, ColorSensor
+from pybricks.parameters import Port, Direction
+from pybricks.hubs import EV3Brick
+from pybricks.tools import wait, DataLog
+
+# create the AGV
+brick = EV3Brick()
+color_sensor = ColorSensor(Port.S4)
+left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
+right_motor = Motor(Port.D, Direction.COUNTERCLOCKWISE)
+
+log = DataLog("time", "left", "right", "color", "battery", name="exp", timestamp=True, extension="csv")
+
+# Run the experiments
+left_motor.run(1000)
+right_motor.run(1000)
+t = 0
+dt = 100
+while t < 10000:
+    c = color_sensor.reflection()
+    l = left_motor.speed()
+    r = right_motor.speed()
+    b = brick.battery.voltage()
+    log.log(t, l, r, c, b)
+    t += dt
+    wait(dt)