import sensors import time import threading import queue conf = { "field":{ "x":450, "y":450 }, "ac_sensor":{ "sensor_distance":450, "y_offset":10, "left_x_offset":0, "rigth_x_offset":0, "sonicspeed":343, "overhead":50 } } def main(): up_queue = queue.Queue() down_queue = queue.Queue() calibration_sate = 0 ac_sensor = sensors.AcusticSensor(conf,up_queue,down_queue,calibration_sate) sensor_thread = threading.Thread(target=ac_sensor.start) sensor_thread.start() time.sleep(3) calibration_sate = 1 print(calibration_sate) time.sleep(3) down_queue.put("calibrate") try: while True: time.sleep(1) print(calibration_sate) except KeyboardInterrupt: print("stop") except Exception as e: print("Error: ",e) finally: down_queue.put("stop") sensor_thread.join() main()