Преглед на файлове

Merge branch 'master' of https://gogs.es-lab.de/wokoeck_ch/lern-tracking-system

Janek преди 3 години
родител
ревизия
7fedbe4f27
променени са 41 файла, в които са добавени 71 реда и са изтрити 324 реда
  1. 0 0
      LICENSE
  2. 0 0
      README.md
  3. 0 0
      arduino/.gitignore
  4. 0 0
      arduino/.vscode/extensions.json
  5. 0 0
      arduino/include/README
  6. 0 0
      arduino/include/ultrasonic.hpp
  7. 0 0
      arduino/lib/README
  8. 0 0
      arduino/platformio.ini
  9. 0 0
      arduino/src/main.cpp
  10. 1 1
      arduino/src/ultrasonic.cpp
  11. 0 0
      arduino/test/README
  12. 0 0
      images/Aufgabenstellung.jpg
  13. 0 0
      images/BOM.png
  14. 0 0
      images/Projektarbeit_final_Presentation.odp
  15. 0 0
      images/acustic tracking.jpg
  16. 0 0
      images/cave.jpg
  17. 0 0
      images/full_system.jpg
  18. 0 0
      images/item2.png
  19. 0 0
      images/screenrecord.mp4
  20. 0 0
      images/screenrecord_thumb.jpg
  21. 0 0
      images/tracking.png
  22. 0 62
      magneticSensor.py
  23. 0 233
      mainWindow.py
  24. 0 0
      raspberry-pi/.vscode/settings.json
  25. 1 1
      raspberry-pi/config.ini
  26. 0 0
      raspberry-pi/gui/SourceSansPro-Semibold.otf
  27. 0 0
      raspberry-pi/gui/graph.py
  28. 0 0
      raspberry-pi/gui/logScreen.py
  29. 25 20
      raspberry-pi/gui/mainWindow.py
  30. 0 0
      raspberry-pi/gui/popup.py
  31. 0 0
      raspberry-pi/install.sh
  32. 0 0
      raspberry-pi/logHandler.py
  33. 0 0
      raspberry-pi/main.py
  34. 0 0
      raspberry-pi/markers.png
  35. 0 0
      raspberry-pi/requirements.txt
  36. 0 0
      raspberry-pi/sensors/acousticSensor.py
  37. 0 0
      raspberry-pi/sensors/calibration.py
  38. 4 4
      raspberry-pi/sensors/connection.py
  39. 40 3
      raspberry-pi/sensors/magneticSensor.py
  40. 0 0
      raspberry-pi/sensors/opticalSensor.py
  41. 0 0
      ultrasound-tests.ods

+ 0 - 0
LICENSE


+ 0 - 0
README.md


+ 0 - 0
arduino/.gitignore


+ 0 - 0
arduino/.vscode/extensions.json


+ 0 - 0
arduino/include/README


+ 0 - 0
arduino/include/ultrasonic.hpp


+ 0 - 0
arduino/lib/README


+ 0 - 0
arduino/platformio.ini


+ 0 - 0
arduino/src/main.cpp


+ 1 - 1
arduino/src/ultrasonic.cpp

@@ -3,7 +3,7 @@
 struct usData_t usData[2];
 
 void us_0_isr() {
-  if(digitalRead(US_RX_0_PIN) && usData[1].state == rxPending) {
+  if(digitalRead(US_RX_0_PIN) && usData[0].state == rxPending) {
     usData[0].pulseStart = TCNT1;
     usData[0].state = counting;
   } else if(usData[0].state == counting) {

+ 0 - 0
arduino/test/README


+ 0 - 0
images/Aufgabenstellung.jpg


+ 0 - 0
images/BOM.png


+ 0 - 0
images/Projektarbeit_final_Presentation.odp


+ 0 - 0
images/acustic tracking.jpg


+ 0 - 0
images/cave.jpg


+ 0 - 0
images/full_system.jpg


+ 0 - 0
images/item2.png


+ 0 - 0
images/screenrecord.mp4


+ 0 - 0
images/screenrecord_thumb.jpg


+ 0 - 0
images/tracking.png


+ 0 - 62
magneticSensor.py

@@ -1,62 +0,0 @@
-import queue
-import time
-import threading
-
-from sensors.calibration import CalibrationStateMashine
-from sensors.connection import globalArduinoSlave
-import logHandler
-
-conn = globalArduinoSlave()
-
-
-class MagneticSensor:
-  def __init__(self, conf):
-    self.conf = conf
-    self.queue = queue.Queue()
-    self.calibration_state = CalibrationStateMashine()
-    self.field_height = float(conf["field"]["y"])
-    self.field_width  = float(conf["field"]["x"])
-
-    self.success = False
-    self.log_handler = logHandler.get_log_handler() # neu
-    #pass
-
-    self.n = 0
-
-  def start(self):
-    self.log_handler.log_and_print("start magnetic sensor")
-    if not conn.isConnected():
-      conn.open(port = self.conf["arduino"]["port"])
-    conn.addRecvCallback(self._readCb)
-    self.dummyActive = True
-    dummyThread = threading.Thread(target=self._readCb_dummy)
-    dummyThread.start()
-
-  def _readCb(self, raw):
-    print("mag: ", conn.getMagneticField())
-
-  def _readCb_dummy(self):
-    self.log_handler.log_and_print("magnetic sensor: generating test values")
-    while self.dummyActive:
-      if self.n % 4 < 1:
-        dummyPosition = (0, self.n%1 * self.field_height)
-      elif self.n % 4 < 2:
-        dummyPosition = (self.n%1 * self.field_width, self.field_height)
-      elif self.n % 4 < 3:
-        dummyPosition = (self.field_width, self.field_height - self.n%1 * self.field_height)
-      else:
-        dummyPosition = (self.field_width - self.n%1 * self.field_width, 0)
-
-      self.n  += 0.01
-
-
-  def calibrate(self, x, y):
-    pass
-
-  def read(self):
-    return conn.getMagneticField()
-
-  def stop(self): # neu
-    self.log_handler.log_and_print("stop magnetic sensor")
-    self.dummyActive = False
-    conn.close()

+ 0 - 233
mainWindow.py

@@ -1,233 +0,0 @@
-import time
-import queue
-
-import tkinter as tk
-import numpy as np
-
-from gui.popup import CalibrationPopUp
-from gui.graph import Graph
-from gui.logScreen import LogScreen
-from sensors.opticalSensor import OpticalSensor
-import logHandler
-
-
-class MainWindow(tk.Frame):
-  def __init__(self, root, conf, ac_sensor, opt_sensor, mag_sensor):
-    self.root         = root
-    self.conf         = conf
-    self.ac_sensor    = ac_sensor
-    self.opt_sensor   = opt_sensor
-    self.mag_sensor   = mag_sensor
-    self.log_handler  = logHandler.get_log_handler()
-    self.popup_window = None
-    self.log_window   = None
-    self.mainWindow   = None
-
-    tk.Frame.__init__(self, root)
-    # data plot at left side
-    self.graph = Graph(self)
-    self.graph.pack(fill=tk.BOTH, side=tk.LEFT, expand=True)
-    # frame at right side
-    self.controls = tk.Frame(self, borderwidth=4)
-    self.controls.pack(fill=tk.BOTH, side=tk.RIGHT)
-    self.controlsUpdateTime = 0
-
-    self.ac_dro_val_sums = np.ndarray((4), dtype=np.float)
-    self.ac_dro_val_count = 0
-    self.ac_dro_x = tk.StringVar()
-    self.ac_dro_y = tk.StringVar()
-    self.ac_dro_t1 = tk.StringVar()
-    self.ac_dro_t2 = tk.StringVar()
-    self.ac_label = tk.Label(self.controls, text="Acoustic Sensor", anchor="c", font=("Helvatica", 10, 'bold'))
-    self.ac_label.pack(side="top", fill="both", expand=False)
-    tk.Label(self.controls, textvariable=self.ac_dro_x, anchor="nw").pack(side="top", fill="both", expand=False)
-    tk.Label(self.controls, textvariable=self.ac_dro_y, anchor="nw").pack(side="top", fill="both", expand=False)
-    tk.Label(self.controls, textvariable=self.ac_dro_t1, anchor="nw").pack(side="top", fill="both", expand=False)
-    tk.Label(self.controls, textvariable=self.ac_dro_t2, anchor="nw").pack(side="top", fill="both", expand=False)
-
-    self.opt_dro_val_sums = np.ndarray((4), dtype=np.float)
-    self.opt_dro_val_count = 0
-    self.opt_dro_x = tk.StringVar()
-    self.opt_dro_y = tk.StringVar()
-    self.opt_dro_offset = tk.StringVar()
-    self.opt_dro_size   = tk.StringVar()
-    self.opt_label = tk.Label(self.controls, text="Optical Sensor", anchor="c", font=("Helvatica", 10, 'bold'))
-    self.opt_label.pack(side="top", fill="both", expand=False)
-    tk.Label(self.controls, textvariable=self.opt_dro_x, anchor="nw").pack(side="top", fill="both", expand=False)
-    tk.Label(self.controls, textvariable=self.opt_dro_y, anchor="nw").pack(side="top", fill="both", expand=False)
-    tk.Label(self.controls, textvariable=self.opt_dro_offset, anchor="nw").pack(side="top", fill="both", expand=False)
-    tk.Label(self.controls, textvariable=self.opt_dro_size, anchor="nw").pack(side="top", fill="both", expand=False)
-
-    self.mag_label = tk.Label(self.controls, text="Magnetic Sensor", anchor="c", font=("Helvatica", 10, 'bold'))
-    self.mag_label.pack(side="top", fill="both", expand=False)
-    self.mag_dro_x = tk.StringVar()
-    self.mag_dro_y = tk.StringVar()
-    tk.Label(self.controls, textvariable=self.mag_dro_x, anchor = "nw").pack(side = "top", fill = "both", expand = False)
-    tk.Label(self.controls, textvariable=self.mag_dro_x, anchor = "nw").pack(side = "top", fill = "both", expand = False)
-
-    self.quit_button = tk.Button(self.controls, text="Quit", command=self.root.destroy, height=2, foreground="red")
-    self.quit_button.pack(side="bottom", fill="both")
-
-    self.calibrateac_button = tk.Button(self.controls, text="Calibrate AC", command=self.calibrate_ac, height=4)
-    self.calibrateac_button.pack_forget()
-
-    self.calibratemc_button = tk.Button(self.controls, text = "Calibrate MC", command = self.calibrate_mc,height = 4)
-    self.calibratemc_button.pack_forget()
-
-    self.clear_button = tk.Button(self.controls, text="Clear graph", command=self.graph.clear, height=4)
-    self.clear_button.pack_forget()
-
-    self.logscreen_button = tk.Button(self.controls, text="Log", command=self.open_log, height=4)
-    self.logscreen_button.pack_forget()
-
-    self.menu_button = tk.Button(self.controls, text="Menu", command=self.menu, height=4)
-    self.menu_button.pack(side="bottom", fill="both")
-    
-    self.menu_back_button = tk.Button(self.controls, text="Back", command=self.back, height=4)
-    self.menu_back_button.pack_forget()
-
-  def update(self):
-    if not self.root.winfo_exists():
-      return
-
-    ac_positions = []
-    # aggregate measurements
-    while self.ac_sensor.queue.qsize() > 0:
-      name, data = self.ac_sensor.queue.get()
-      if name == "data":
-        ac_positions.append(data[0:2])
-        self.ac_dro_val_sums += data
-        self.ac_dro_val_count += 1
-
-    opt_positions = []
-    while self.opt_sensor.queue.qsize() > 0:
-      name, data = self.opt_sensor.queue.get()
-      if name == "data":
-        opt_positions.append(data[0:2])
-        self.opt_dro_val_sums += data
-        self.opt_dro_val_count += 1
-    
-    mag_positions = []
-    while self.mag_sensor.queue.qsize() > 0:
-      name, data = self.mag_sensor.queue.get()
-      if name == "data":
-        mag_positions.append(data[0:2])
-        self.mag_dro_val_sums += data
-        self.mag_dro_val_count += 1
-    
-    # graph shows all values as a line
-    self.graph.update([ac_positions, opt_positions, mag_positions])
-
-    # update status color
-    if self.ac_sensor.dummyActive:
-      self.ac_label.config(fg="white", bg="red")
-    elif len(ac_positions) > 0:
-      self.ac_label.config(fg="white", bg="green")
-    else:
-      self.ac_label.config(fg="black", bg="yellow")
-
-
-    if not self.opt_sensor.success:
-      self.opt_label.config(fg="white", bg="red")
-    elif len(opt_positions) > 0:
-      self.opt_label.config(fg="white", bg="green")
-    else:
-      self.opt_label.config(fg="black", bg="yellow")
-
-    # if not self.mag_sensor.:
-    #  self.mag_label.config(fg="white", bg="red")
-    # elif len(mag_positions) > 0:
-    #  self.mag_label.config(fg="white", bg="green")
-    # else:
-    #  self.mag_label.config(fg="black", bg="yellow")
-
-
-    # readouts will only be updated so often
-    if self.controlsUpdateTime + 0.4 < time.time():
-      self.controlsUpdateTime = time.time()
-      # they display the average of all values
-      if self.ac_dro_val_count > 0:
-        self.ac_dro_val_sums /= self.ac_dro_val_count
-      else:
-        self.ac_dro_val_sums.fill(0)
-
-      self.ac_dro_x.set("X: {:.1f} mm".format(self.ac_dro_val_sums[0]))
-      self.ac_dro_y.set("Y: {:.1f} mm".format(self.ac_dro_val_sums[1]))
-      self.ac_dro_t1.set("t1: {:.3f} ms".format(self.ac_dro_val_sums[2]/1000))
-      self.ac_dro_t2.set("t2: {:.3f} ms".format(self.ac_dro_val_sums[3]/1000))
-
-      self.ac_dro_val_sums.fill(0)
-      self.ac_dro_val_count = 0
-
-      if self.opt_dro_val_count > 0:
-        self.opt_dro_val_sums /= self.opt_dro_val_count
-      else:
-        self.opt_dro_val_sums.fill(0)
-
-      self.opt_dro_x.set("X: {:.1f} mm".format(self.opt_dro_val_sums[0]))
-      self.opt_dro_y.set("Y: {:.1f} mm".format(self.opt_dro_val_sums[1]))
-      self.opt_dro_offset.set("offset: {:.1f} %".format(self.opt_dro_val_sums[2]*100))
-      self.opt_dro_size.set("size: {:.1f} %".format(self.opt_dro_val_sums[3]*100))
-
-      self.opt_dro_val_sums.fill(0)
-      self.opt_dro_val_count = 0
-
-    if self.popup_window:
-      self.popup_window.update()
-    
-    if self.log_window:
-      self.log_window.update()
-
-    self.root.after(30, self.update)
-
-  def calibrate_ac(self):
-    self.ac_sensor.start_calibration()
-    if not self.popup_window or not self.pu_root.winfo_exists():
-      # create new window
-      self.pu_root = tk.Toplevel(self.root)
-      self.pu_root.wm_transient(self.root)
-      self.pu_root.wm_title("Acoustic Sensor Calibration")
-      # make it centered
-      x = (self.pu_root.winfo_screenwidth()  - 500) / 2
-      y = (self.pu_root.winfo_screenheight() - 200) / 2
-      self.pu_root.geometry(f'500x200+{int(x)}+{int(y)}')
-      # deactivate mainWindow
-      self.pu_root.grab_set()
-      self.popup_window = CalibrationPopUp(self.pu_root, self.ac_sensor.calibration_state, self.conf)
-      self.popup_window.pack(side="top", fill="both", expand=True)
-
-  def calibrate_mc(self):
-    pass
-
-  def open_log(self):
-    #create new window
-    self.log_root = tk.Toplevel(self.root)
-    self.log_root.wm_transient(self.root)
-    self.log_root.wm_title("Logs")
-    #center
-    x = (self.log_root.winfo_screenwidth()  - 780) / 2
-    y = (self.log_root.winfo_screenheight() - 400) / 2
-    self.log_root.geometry(f'780x400+{int(x)}+{int(y)}')
-    # deactivate mainWindow
-    self.log_root.grab_set()
-    self.log_window = LogScreen(self.log_root)
-    self.log_window.pack(side="top", fill="both", expand=True)
-
-  
-  # Menu Button
-  def menu(self):
-    self.menu_back_button.pack(side="bottom", fill="both")
-    self.calibrateac_button.pack(side="bottom", fill="both")
-    self.calibratemc_button.pack(side="bottom", fill="both")
-    self.clear_button.pack(side="bottom", fill="both")
-    self.logscreen_button.pack(side="bottom", fill="both")
-    self.menu_button.pack_forget()
-
-  #Back Button
-  def back(self):
-    self.calibrateac_button.pack_forget()
-    self.calibratemc_button.pack_forget()
-    self.clear_button.pack_forget()
-    self.logscreen_button.pack_forget()
-    self.menu_button.pack(side="bottom", fill="both")
-    self.menu_back_button.pack_forget()

+ 0 - 0
raspberry-pi/.vscode/settings.json


+ 1 - 1
raspberry-pi/config.ini

@@ -53,5 +53,5 @@
   fov = 53.50
 
 [gui]
-  fullscreen = yes
+  fullscreen = no
   log_lines  = 100

+ 0 - 0
raspberry-pi/gui/SourceSansPro-Semibold.otf


+ 0 - 0
raspberry-pi/gui/graph.py


+ 0 - 0
raspberry-pi/gui/logScreen.py


+ 25 - 20
raspberry-pi/gui/mainWindow.py

@@ -7,6 +7,7 @@ import numpy as np
 from gui.popup import CalibrationPopUp
 from gui.graph import Graph
 from gui.logScreen import LogScreen
+from sensors.opticalSensor import OpticalSensor
 import logHandler
 
 
@@ -57,24 +58,31 @@ class MainWindow(tk.Frame):
     tk.Label(self.controls, textvariable=self.opt_dro_offset, anchor="nw").pack(side="top", fill="both", expand=False)
     tk.Label(self.controls, textvariable=self.opt_dro_size, anchor="nw").pack(side="top", fill="both", expand=False)
 
-    self.mag_label = tk.Label(self.controls, text="Magnetic Sensor", anchor="c", font=("Helvatica", 10, 'bold'))
-    self.mag_label.pack(side="top", fill="both", expand=False)
+    self.mag_dro_val_sums = np.ndarray((4), dtype=np.float)
+    self.mag_dro_val_count = 0
     self.mag_dro_x = tk.StringVar()
     self.mag_dro_y = tk.StringVar()
+    self.mag_label = tk.Label(self.controls, text="Magnetic Sensor", anchor="c", font=("Helvatica", 10, 'bold'))
+    self.mag_label.pack(side="top", fill="both", expand=False)
     tk.Label(self.controls, textvariable=self.mag_dro_x, anchor = "nw").pack(side = "top", fill = "both", expand = False)
     tk.Label(self.controls, textvariable=self.mag_dro_x, anchor = "nw").pack(side = "top", fill = "both", expand = False)
-
+    #
+    #
+    
     self.quit_button = tk.Button(self.controls, text="Quit", command=self.root.destroy, height=2, foreground="red")
     self.quit_button.pack(side="bottom", fill="both")
 
-    self.calibrate_button = tk.Button(self.controls, text="Calibrate AC", command=self.calibrate_ac, height=4)
-    self.calibrate_button.pack(side="bottom", fill="both")
+    self.calibrateac_button = tk.Button(self.controls, text="Calibrate AC", command=self.calibrate_ac, height=4)
+    self.calibrateac_button.pack_forget()
+
+    self.calibratemc_button = tk.Button(self.controls, text = "Calibrate MC", command = self.calibrate_mc,height = 4)
+    self.calibratemc_button.pack_forget()
 
     self.clear_button = tk.Button(self.controls, text="Clear graph", command=self.graph.clear, height=4)
-    self.clear_button.pack(side="bottom", fill="both")
+    self.clear_button.pack_forget()
 
     self.logscreen_button = tk.Button(self.controls, text="Log", command=self.open_log, height=4)
-    self.logscreen_button.pack(side="bottom", fill="both")
+    self.logscreen_button.pack_forget()
 
     self.menu_button = tk.Button(self.controls, text="Menu", command=self.menu, height=4)
     self.menu_button.pack(side="bottom", fill="both")
@@ -82,15 +90,6 @@ class MainWindow(tk.Frame):
     self.menu_back_button = tk.Button(self.controls, text="Back", command=self.back, height=4)
     self.menu_back_button.pack_forget()
 
-    #"verstecken" der Buttons für Platz für Statusanzeigen Magnetsensor
-
-    self.calibrate_button.pack_forget()
-
-    self.clear_button.pack_forget()
-
-    self.logscreen_button.pack_forget()
-
-
   def update(self):
     if not self.root.winfo_exists():
       return
@@ -115,7 +114,7 @@ class MainWindow(tk.Frame):
     mag_positions = []
     while self.mag_sensor.queue.qsize() > 0:
       name, data = self.mag_sensor.queue.get()
-      if name == 'data':
+      if name == "data":
         mag_positions.append(data[0:2])
         self.mag_dro_val_sums += data
         self.mag_dro_val_count += 1
@@ -201,6 +200,9 @@ class MainWindow(tk.Frame):
       self.popup_window = CalibrationPopUp(self.pu_root, self.ac_sensor.calibration_state, self.conf)
       self.popup_window.pack(side="top", fill="both", expand=True)
 
+  def calibrate_mc(self):
+    pass
+
   def open_log(self):
     #create new window
     self.log_root = tk.Toplevel(self.root)
@@ -219,14 +221,17 @@ class MainWindow(tk.Frame):
   # Menu Button
   def menu(self):
     self.menu_back_button.pack(side="bottom", fill="both")
-    self.calibrate_button.pack(side="bottom", fill="both")
+    self.calibrateac_button.pack(side="bottom", fill="both")
+    self.calibratemc_button.pack(side="bottom", fill="both")
     self.clear_button.pack(side="bottom", fill="both")
     self.logscreen_button.pack(side="bottom", fill="both")
     self.menu_button.pack_forget()
 
+  #Back Button
   def back(self):
-    self.calibrate_button.pack_forget()
+    self.calibrateac_button.pack_forget()
+    self.calibratemc_button.pack_forget()
     self.clear_button.pack_forget()
     self.logscreen_button.pack_forget()
     self.menu_button.pack(side="bottom", fill="both")
-    self.menu_back_button.pack_forget()
+    self.menu_back_button.pack_forget()

+ 0 - 0
raspberry-pi/gui/popup.py


+ 0 - 0
raspberry-pi/install.sh


+ 0 - 0
raspberry-pi/logHandler.py


+ 0 - 0
raspberry-pi/main.py


+ 0 - 0
raspberry-pi/markers.png


+ 0 - 0
raspberry-pi/requirements.txt


+ 0 - 0
raspberry-pi/sensors/acousticSensor.py


+ 0 - 0
raspberry-pi/sensors/calibration.py


+ 4 - 4
raspberry-pi/sensors/connection.py

@@ -126,14 +126,14 @@ class ArduinoSlave(SerialConnection):
     return (
       int(self.sensorData[5]) / 1000,
       int(self.sensorData[6]) / 1000,
-      int(self.sensorData[7]) / 1000
+      int(self.sensorData[7]) / 1000,
     )
   
   def getGyroValues(self):
     return (
-      int(self.sensorData[8])  / 1000,
-      int(self.sensorData[9])  / 1000,
-      int(self.sensorData[10]) / 1000
+      int(self.sensorData[8])  / 1000, #
+      int(self.sensorData[9])  / 1000, #
+      int(self.sensorData[10]) / 1000  #
     )
   
   def getTemperature(self): # in °C

+ 40 - 3
raspberry-pi/sensors/magneticSensor.py

@@ -1,9 +1,11 @@
 import queue
 import time
+<<<<<<< HEAD
 import threading
 import random
+=======
+>>>>>>> de61b5b54174156bc78823188e70ac7b94fdde66
 
-from sensors.calibration import CalibrationStateMashine
 from sensors.connection import globalArduinoSlave
 import logHandler
 
@@ -14,6 +16,7 @@ class MagneticSensor:
   def __init__(self, conf):
     self.conf = conf
     self.queue = queue.Queue()
+<<<<<<< HEAD
     self.calibration_state  = CalibrationStateMashine()
     self.log_handler = logHandler.get_log_handler() # neu
     self.success = False
@@ -24,12 +27,21 @@ class MagneticSensor:
     self.n = 0
   
     #pass
+=======
+    self.log_handler = logHandler.get_log_handler()
+    self.gyro_x = []
+    self.gyro_y = []
+    self.gyro_z = []
+    self.offset_x = 0 #
+    self.offset_y = 0 #
+    self.offset_z = 0 #
+>>>>>>> de61b5b54174156bc78823188e70ac7b94fdde66
 
   def start(self):
-    self.log_handler.log_and_print("start acoustic sensor")
     if not conn.isConnected():
       conn.open()
     conn.addRecvCallback(self._readCb)
+<<<<<<< HEAD
     self.dummyActive = True
     dummyThread = threading.Thread(target=self._readCb_dummy)
     dummyThread.start()
@@ -47,11 +59,36 @@ class MagneticSensor:
 
   def calibrate(self, x, y):
     pass
+=======
+    self.calibrate() #
+
+  def _readCb(self, raw):
+    #print("mag: ", conn.getMagneticField())
+    #print("accel: ", conn.getAccelValues())
+    print("gyro: ", conn.getGyroValues())
+
+  def calibrate(self):
+    # Gyroscope Calibration
+    i = 0
+    while i < 500:
+      self.gyro_x.append(conn.getGyroValues()) #
+      self.gyro_y.append(conn.getGyroValues()) #
+      self.gyro_z.append(conn.getGyroValues()) #
+      print("gyro_x: %d", self.gyro_x)
+      i += 1
+      if i == 500:
+        self.offset_x = sum(self.gyro_x) / len(self.gyro_x)
+        self.offset_y = sum(self.gyro_y) / len(self.gyro_y) 
+        self.offset_z = sum(self.gyro_z) / len(self.gyro_z) 
+        #pass
+    # Accelerometer Calibration
+    # Magnetometer Calibration
+>>>>>>> de61b5b54174156bc78823188e70ac7b94fdde66
 
   def read(self):
     return conn.getMagneticField()
 
-  def stop(self): # neu
+  def stop(self):
     self.log_handler.log_and_print("stop magnetic sensor")
     conn.close()
 

+ 0 - 0
raspberry-pi/sensors/opticalSensor.py


+ 0 - 0
ultrasound-tests.ods