|
@@ -4,7 +4,6 @@ import time
|
|
|
import statistics
|
|
|
import math
|
|
|
import threading
|
|
|
-import noise
|
|
|
import random
|
|
|
import traceback
|
|
|
import cv2
|
|
@@ -34,12 +33,12 @@ class AcusticSensor:
|
|
|
self.n = 0
|
|
|
|
|
|
def start(self):
|
|
|
- self.running = True
|
|
|
+ self.dummyActive = True
|
|
|
if not conn.isConnected():
|
|
|
conn.open()
|
|
|
conn.addRecvCallback(self._readCb)
|
|
|
- thread = threading.Thread(target=self._readCb_dummy)
|
|
|
- thread.start()
|
|
|
+ dummyThread = threading.Thread(target=self._readCb_dummy)
|
|
|
+ dummyThread.start()
|
|
|
while True:
|
|
|
action = self.down_queue.get()
|
|
|
print("action",action)
|
|
@@ -49,16 +48,16 @@ class AcusticSensor:
|
|
|
self.calibration_state.next_state()
|
|
|
elif action == "stop":
|
|
|
print("exit Sensor")
|
|
|
- self.running = False
|
|
|
- thread.join()
|
|
|
+ self.dummyActive = False
|
|
|
+ dummyThread.join()
|
|
|
break
|
|
|
conn.close()
|
|
|
|
|
|
def _readCb_dummy(self):
|
|
|
- while self.running:
|
|
|
+ while self.dummyActive:
|
|
|
value = (900+random.randint(0,300),900+random.randint(0,300))
|
|
|
- value = ((noise.pnoise1(self.n)+1)*150+900, (noise.pnoise1(self.n*1.3+3)+1)*150+900)
|
|
|
- self.n += 0.01
|
|
|
+ value = ((math.sin(self.n)+1)*400+900, (math.cos(self.n)+1)*400+900)
|
|
|
+ self.n += 0.02
|
|
|
|
|
|
if self.calibration_state.get_state() == self.calibration_state.ACCUMULATING_1:
|
|
|
value = (1541+random.randint(-50,50),2076+random.randint(-50,50))
|
|
@@ -74,6 +73,9 @@ class AcusticSensor:
|
|
|
value = conn.getAcusticRTTs()
|
|
|
print("acc: ", value)
|
|
|
|
|
|
+ if self.dummyActive:
|
|
|
+ self.dummyActive = False
|
|
|
+
|
|
|
if value[0] >= 0 and value[1] >= 0:
|
|
|
self.calibrate(value)
|
|
|
self.pass_to_gui(self.calculate_position(value))
|