Browse Source

update.. again

wokoeck_ch 2 years ago
parent
commit
de61b5b541

+ 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 - 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


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

@@ -158,7 +158,7 @@ class AcousticSensor:
         self.log_handler.log_and_print("  overhead_left:  {:8.3f} us".format(self.overhead_left))
         self.log_handler.log_and_print("  overhead_right: {:8.3f} us".format(self.overhead_right))
 
-        self.calibrathttps://gogs.es-lab.de/wokoeck_ch/lern-tracking-systemion_state.next_state()
+        self.calibration_state.next_state()
 
   def read(self):
     value = conn.getAcousticRTTs()

+ 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

+ 29 - 22
raspberry-pi/sensors/magneticSensor.py

@@ -1,8 +1,6 @@
 import queue
 import time
-import threading
 
-from sensors.calibration import CalibrationStateMashine
 from sensors.connection import globalArduinoSlave
 import logHandler
 
@@ -13,36 +11,45 @@ class MagneticSensor:
   def __init__(self, conf):
     self.conf = conf
     self.queue = queue.Queue()
-    self.calibration_state  = CalibrationStateMashine()
-    self.log_handler = logHandler.get_log_handler() # neu
-
-    self.field_height = float(conf["field"]["y"])
-    self.field_width = float(conf["field"]["x"])
-
-    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 #
 
   def start(self):
-    self.log_handler.log_and_print("start acoustic sensor")
     if not conn.isConnected():
       conn.open()
     conn.addRecvCallback(self._readCb)
-    self.dummyActive = True
-    dummyThread = threading.Thread(target=self._readCb_dummy)
+    self.calibrate() #
 
   def _readCb(self, raw):
-    print("mag: ", conn.getMagneticField())
-
-  def _readCb_dummy(self):
-    pass
-
-  def calibrate(self, x, y):
-    pass
+    #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
 
   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