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