def main (): manager = Manager() # Range Sensor Distance distance = manager.list([0, 0, 0, 0, 0, 0]) # DataBase db = manager.list() # Command from Keyboard keyboard_cmd = manager.dict() keyboard_cmd['vld'] = 0 keyboard_cmd['cmd'] = '' # GoBack Ready goback_cmd = manager.dict() goback_cmd['vld'] = 0 #Step 1: Initialzation initialization.initialize() #Step 2: Departure operations.take_off() #Step 3: Multi threading start to_thr = Process(target = timeout, args = (runtime, )) key_thr = Process(target = keyboard_thread.keyboard_thread_wrapper_function, args = (keyboard_cmd, )) cmd_thr = Process(target = command_thread.command_thread_wrapper_function, args = (distance, keyboard_cmd, db, goback_cmd, )) rs_thr = Process(target = range_sensor_thread.range_sensor_wrapper_function, args = (distance, )) gb_thr = Process(target = goback_thread.goback_wrapper_function, args = (goback_cmd, )) cmd_thr.start() rs_thr.start() to_thr.start() key_thr.start() gb_thr.start() #Step 4: Multi threading end to_thr.join() cmd_thr.terminate() rs_thr.terminate() key_thr.terminate() gb_thr.terminate() operations.landing() time.sleep(1) cleanup.cleanup()
def main (): loop = 0 manager = Manager() distance = manager.list([0, 0, 0, 0, 0, 0]) # distance2 = manager.list([0, 0, 0, 0, 0, 0]) #Step 1: Initialzation initialization.initialize() #Step 2: Departure operations.take_off() #Step 3: Multi threading start timeout_thread = Process(target = timeout, args = (runtime, )) p1 = Process(target = command_thread.command_thread_wrapper_function, args = (distance, )) p2 = Process(target = range_sensor_thread.range_sensor_wrapper_function, args = (distance, )) p1.start() p2.start() timeout_thread.start() #Step 4: Multi threading end timeout_thread.join() p1.terminate() p2.terminate() time.sleep(1) cleanup.cleanup()
def main (): loop = 0 #Step 1: Initialzation initialization.initialize() #Step 2: Departure operations.take_off() #while True : while (loop < 300): #time for a loop: 0.15s loop += 1 #Step 2: Detect Range # for i in range(0, range_sensor.num_directions): # distance[i] = range_sensor.detect_range(i) distance[4] = range_sensor.detect_range(4) time.sleep(0.05) #Step 3: Analyze Range # if (distance[4] > 180): # #operations.hover() # operations.move_backward() # elif (distance[4] < 180): # #operations.hover() # operations.move_backward() # else: # #operations.hover() # operations.move_backward() #Step 4: Generate Next Command if (loop < 50): operations.hover() elif (loop < 100): operations.move_backward() elif (loop < 150): operations.hover() elif (loop < 200): operations.move_backward() elif (loop < 250): operations.drop() else : operations.drop() cleanup.cleanup()