def main(): if not start_only_voice_control: uri = args['uri'] logging.basicConfig() crtp.init_drivers(enable_debug_driver=False) # the command queue for the crazyflie crazyflieCommandQueue = Queue() # set up the crazyflie cf = crazyflie.Crazyflie(rw_cache='./cache') control = ControllerThread(cf, crazyflieCommandQueue) control.start() # start the web interface to the crazyflie server = Process(target=run_server, args=("0.0.0.0", control_port, crazyflieCommandQueue)) server.start() # start the path planning server pathPlanner = Process(target=run_path_planner, args=("0.0.0.0", planning_port, crazyflieCommandQueue, room_config)) pathPlanner.start() # connect to the crazyflie if uri is None: print('Scanning for Crazyflies...') available = crtp.scan_interfaces() if available: print('Found Crazyflies:') for i in available: print('-', i[0]) uri = available[0][0] else: print('No Crazyflies found!') sys.exit(1) print('Connecting to', uri) cf.open_link(uri) handle_keyboard_input(control, server) cf.close_link() if start_voice_control or start_only_voice_control: start_command_loop(f'{control_url}:{control_port}', voice_api)
def __init__(self, index, link_uri, window): self._roll = 0.0 self._pitch = 0.0 self._yaw = 0.0 self._thrust = 0 self._pressure = 0 self._mag_x = 0 self._mag_y = 0 self._mag_z = 0 self._acc_x = 0.0 self._acc_y = 0.0 self._acc_z = 0.0 self._auto = False self._index = index self._link_uri = link_uri self._window = window self._cf = crazyflie.Crazyflie() self._cf.connectSetupFinished.add_callback(self._onConnect) logger.info('Opening link to ' + link_uri) self._cf.open_link(link_uri)
elif ch == 'q': if not control.enabled: print('Uppercase Q quits the program') control.disable() elif ch == 'Q': control.disable() print('Bye!') break else: print('Unhandled key', ch, 'was pressed') if __name__ == "__main__": logging.basicConfig() crtp.init_drivers(enable_debug_driver=False) cf = crazyflie.Crazyflie(rw_cache='./cache') control = ControllerThread(cf) control.start() if URI is None: print('Scanning for Crazyflies...') available = crtp.scan_interfaces() if available: print('Found Crazyflies:') for i in available: print('-', i[0]) URI = available[0][0] else: print('No Crazyflies found!') sys.exit(1)