Parcourir la source

changed calibration_y_offset

subDesTagesMitExtraKaese il y a 3 ans
Parent
commit
0783d9c640
3 fichiers modifiés avec 12 ajouts et 8 suppressions
  1. 4 1
      raspberry-pi/config.ini
  2. 2 2
      raspberry-pi/gui/popup.py
  3. 6 5
      raspberry-pi/sensors/acusticSensor.py

+ 4 - 1
raspberry-pi/config.ini

@@ -19,9 +19,12 @@
   # left sensor x offset to the right border at x=0 in mm 
   left_x_offset = 0
 
-  # right sensor x offset to the left border at x=sensor_distance in mm 
+  # right sensor x offset to the left border at x=width in mm 
   right_x_offset = 0
 
+  # distance to y=0 at which the calibration takes place in mm
+  calibration_y_offset = 210
+
   # default speed of sound in mm / us (or km / s)
   # only used before calibration
   sonicspeed = 0.343

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

@@ -26,9 +26,9 @@ class CalibrationPopUp(tk.Frame):
     self.cs['value'] = self.calibration_state.progress
     # read state from state machine
     if self.calibration_state.get_state() == self.calibration_state.WAITING_POS_1:
-      self.instruction["text"] = "Move gondola to far left corner!"
+      self.instruction["text"] = "Move gondola to left at calibration_y_offset!"
     elif self.calibration_state.get_state() == self.calibration_state.WAITING_POS_2:
-      self.instruction["text"] = "Move gondola to far right corner!"
+      self.instruction["text"] = "Move gondola to right at calibration_y_offset!"
     elif self.calibration_state.get_state() == self.calibration_state.CALIBRATION_DONE:
       self.instruction["text"] = "Calibration Done!"
       if not self.pendingClose:

+ 6 - 5
raspberry-pi/sensors/acusticSensor.py

@@ -21,6 +21,7 @@ class AcusticSensor:
     self.sensor_y_offset        = float(conf["ac_sensor"]["y_offset"])
     self.left_sensor_x_offset   = float(conf["ac_sensor"]["left_x_offset"])
     self.right_sensor_x_offset  = float(conf["ac_sensor"]["right_x_offset"])
+    self.calibration_y_offset   = float(conf["ac_sensor"]["calibration_y_offset"])
     self.sensor_distance        = self.field_width - self.left_sensor_x_offset + self.right_sensor_x_offset
     self.sonic_speed            = float(conf["ac_sensor"]["sonicspeed"])
     self.overhead_left          = float(conf["ac_sensor"]["overhead_left"])
@@ -110,11 +111,11 @@ class AcusticSensor:
         # calculate distances from config
         #          /|                               _.-|
         #      d1 / |                       d2  _.-`   |
-        #        /  | y_off + height        _.-`       | y_off + height
+        #        /  | y_off + calYoff       _.-`       | y_off + calibration_y_offset
         #       /___|                     -____________|
         #       x_off                     x_off + width
-        distance_1 = math.sqrt(self.left_sensor_x_offset**2 + (self.sensor_y_offset + self.field_height)**2 )
-        distance_2 = math.sqrt((self.left_sensor_x_offset + self.field_width)**2 + (self.sensor_y_offset + self.field_height)**2 )
+        distance_1 = math.sqrt(self.left_sensor_x_offset**2 + (self.sensor_y_offset + self.calibration_y_offset)**2 )
+        distance_2 = math.sqrt((self.left_sensor_x_offset + self.field_width)**2 + (self.sensor_y_offset + self.calibration_y_offset)**2 )
         distancedif = distance_2 - distance_1
         timedif = self.cal_values["left"][1] - self.cal_values["left"][0]
         # speed of sound in mm/us
@@ -123,8 +124,8 @@ class AcusticSensor:
         overhead_1 = statistics.mean((self.cal_values["left"][1] - distance_1/sonicspeed_1, self.cal_values["left"][0] - distance_2/sonicspeed_1))
 
         # same for the second set of values
-        distance_1 = math.sqrt(self.right_sensor_x_offset**2 + (self.sensor_y_offset + self.field_height)**2 )
-        distance_2 = math.sqrt((self.right_sensor_x_offset + self.field_width)**2 + (self.sensor_y_offset + self.field_height)**2 )
+        distance_1 = math.sqrt(self.right_sensor_x_offset**2 + (self.sensor_y_offset + self.calibration_y_offset)**2 )
+        distance_2 = math.sqrt((self.right_sensor_x_offset + self.field_width)**2 + (self.sensor_y_offset + self.calibration_y_offset)**2 )
         distancedif = distance_2 - distance_1
         timedif = self.cal_values["right"][1] - self.cal_values["right"][0]
         sonicspeed_2 = distancedif / timedif