|
@@ -27,7 +27,7 @@ class AcusticSensor:
|
|
self.overhead_right = float(conf["ac_sensor"]["overhead_right"])
|
|
self.overhead_right = float(conf["ac_sensor"]["overhead_right"])
|
|
|
|
|
|
self.log_handler = logHandler.get_log_handler()
|
|
self.log_handler = logHandler.get_log_handler()
|
|
- self.log_handler.add_item("start ac_sensor")
|
|
|
|
|
|
+ self.log_handler.log_and_print("start acustic sensor")
|
|
|
|
|
|
# temporary calibration variables
|
|
# temporary calibration variables
|
|
self.time_vals = [[],[]]
|
|
self.time_vals = [[],[]]
|
|
@@ -52,11 +52,12 @@ class AcusticSensor:
|
|
self.calibration_state.next_state()
|
|
self.calibration_state.next_state()
|
|
|
|
|
|
def stop(self):
|
|
def stop(self):
|
|
- print("stop acoustic sensor")
|
|
|
|
|
|
+ self.log_handler.log_and_print("stop acustic sensor")
|
|
self.dummyActive = False
|
|
self.dummyActive = False
|
|
conn.close()
|
|
conn.close()
|
|
|
|
|
|
def _readCb_dummy(self):
|
|
def _readCb_dummy(self):
|
|
|
|
+ self.log_handler.log_and_print("acustic sensor: generating test values")
|
|
while self.dummyActive:
|
|
while self.dummyActive:
|
|
value = (900+random.randint(0,300),900+random.randint(0,300))
|
|
value = (900+random.randint(0,300),900+random.randint(0,300))
|
|
value = ((math.sin(self.n)+1)*400+900, (math.cos(self.n)+1)*400+900)
|
|
value = ((math.sin(self.n)+1)*400+900, (math.cos(self.n)+1)*400+900)
|
|
@@ -71,9 +72,11 @@ class AcusticSensor:
|
|
self.calibrate(value)
|
|
self.calibrate(value)
|
|
self.pass_to_gui(self.calculate_position(value) + value)
|
|
self.pass_to_gui(self.calculate_position(value) + value)
|
|
time.sleep(0.01)
|
|
time.sleep(0.01)
|
|
|
|
+ self.log_handler.log_and_print("acustic sensor: disabled test mode")
|
|
|
|
|
|
def _readCb(self, raw):
|
|
def _readCb(self, raw):
|
|
- self.dummyActive = False
|
|
|
|
|
|
+ if self.dummyActive == True:
|
|
|
|
+ self.dummyActive = False
|
|
value = conn.getAcusticRTTs()
|
|
value = conn.getAcusticRTTs()
|
|
# partially missing values will be ignored
|
|
# partially missing values will be ignored
|
|
if value[0] >= 0 and value[1] >= 0:
|
|
if value[0] >= 0 and value[1] >= 0:
|
|
@@ -102,8 +105,7 @@ class AcusticSensor:
|
|
self.cal_values["right"][0] = statistics.mean(self.time_vals[1])
|
|
self.cal_values["right"][0] = statistics.mean(self.time_vals[1])
|
|
|
|
|
|
# all values have been captured
|
|
# all values have been captured
|
|
- print("calibration measurements:", self.cal_values)
|
|
|
|
- self.log_handler.add_item("calibration measurements:", self.cal_values)
|
|
|
|
|
|
+ self.log_handler.log_and_print("calibration measurements:", self.cal_values)
|
|
|
|
|
|
# calculate distances from config
|
|
# calculate distances from config
|
|
# /| _.-|
|
|
# /| _.-|
|
|
@@ -132,15 +134,11 @@ class AcusticSensor:
|
|
self.sonic_speed = statistics.mean((sonicspeed_1,sonicspeed_2))
|
|
self.sonic_speed = statistics.mean((sonicspeed_1,sonicspeed_2))
|
|
self.overhead_left = overhead_1
|
|
self.overhead_left = overhead_1
|
|
self.overhead_right = overhead_2
|
|
self.overhead_right = overhead_2
|
|
- print("calibration results:")
|
|
|
|
- print(" sonicspeed: {:8.6f} mm/us".format(self.sonic_speed))
|
|
|
|
- print(" overhead_left: {:8.3f} us".format(self.overhead_left))
|
|
|
|
- print(" overhead_right: {:8.3f} us".format(self.overhead_right))
|
|
|
|
-
|
|
|
|
- self.log_handler.add_item("calibration results:")
|
|
|
|
- self.log_handler.add_item(" sonicspeed: {:8.6f} mm/us".format(self.sonic_speed))
|
|
|
|
- self.log_handler.add_item(" overhead_left: {:8.3f} us".format(self.overhead_left))
|
|
|
|
- self.log_handler.add_item(" overhead_right: {:8.3f} us".format(self.overhead_right))
|
|
|
|
|
|
+
|
|
|
|
+ self.log_handler.log_and_print("calibration results:")
|
|
|
|
+ self.log_handler.log_and_print(" sonicspeed: {:8.6f} mm/us".format(self.sonic_speed))
|
|
|
|
+ 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.calibration_state.next_state()
|
|
self.calibration_state.next_state()
|
|
|
|
|