def GPS_Route(drone): "Do a route in GPS" route = ( (48.764304, 2.289237), (48.764374, 2.289180), (48.764448, 2.289080), (48.764502, 2.288952), (48.764529, 2.288794), (48.764532, 2.288639), (48.764521, 2.288507), (48.764489, 2.288392), (48.764435, 2.288288), (48.764368, 2.288213), (48.764300, 2.288173), (48.764325, 2.288438), (48.764360, 2.288691), (48.764324, 2.288999), ) # That's a big one : petit parcours decoupé en tranche de 10m environ ARDroneConfig.outdoor(drone) ARDroneConfig.nervosity_level(drone, 100) wait = raw_input("Press enter to take off...") drone.takeoff() delay = 15 # Variable à régler pour correspondre au temps de parcours entre chaque point for i in range(len(route)): # wait = raw_input("Press enter to go to point " + str(i+1) + "...") while delay > 0: time.sleep(1) delay = delay - 1 print "Going to point " + str(i + 1) + " in " + str(delay) + " secs !" ARDroneConfig.goto_gps_point(drone, route[i][0], route[i][1]) wait = raw_input("Press enter to land...") drone.land() print "Done !"
def GPS_Route(drone): "Do a route in GPS" route = (48.764304, 2.289237), (48.764374, 2.289180), ( 48.764448, 2.289080 ), (48.764502, 2.288952), (48.764529, 2.288794), (48.764532, 2.288639), ( 48.764521, 2.288507), (48.764489, 2.288392), (48.764435, 2.288288), ( 48.764368, 2.288213 ), (48.764300, 2.288173), (48.764325, 2.288438), ( 48.764360, 2.288691 ), ( 48.764324, 2.288999 ) #That's a big one : petit parcours decoupé en tranche de 10m environ ARDroneConfig.outdoor(drone) ARDroneConfig.nervosity_level(drone, 100) wait = raw_input("Press enter to take off...") drone.takeoff() delay = 15 #Variable à régler pour correspondre au temps de parcours entre chaque point for i in range(len(route)): #wait = raw_input("Press enter to go to point " + str(i+1) + "...") while (delay > 0): time.sleep(1) delay = delay - 1 print "Going to point " + str(i + 1) + " in " + str(delay) + " secs !" ARDroneConfig.goto_gps_point(drone, route[i][0], route[i][1]) wait = raw_input("Press enter to land...") drone.land() print "Done !"
def command_GUI(drone): "Create a GUI to command the drone" global gui ARDroneConfig.outdoor(drone) ARDroneConfig.nervosity_level(drone, 100) gui = ARDroneGUI.ControlWindow(default_action=drone.hover) # Add command gui.add_action("<Up>", drone.forward) gui.add_action("<Down>", drone.backward) gui.add_action("<Left>", drone.left) gui.add_action("<Right>", drone.right) gui.add_action("<z>", drone.up) gui.add_action("<s>", drone.down) gui.add_action("<q>", drone.rotate_left) gui.add_action("<d>", drone.rotate_right) gui.add_action("<a>", drone.takeoff) gui.add_action("<space>", drone.land) gui.add_action("<Return>", drone.emergency) gui.add_action("<t>", drone.reset) gui.add_action("<y>", drone.calibrate) gui.add_action("<o>", lambda arg=drone: ARDroneConfig.activate_tag(drone)) gui.add_action("<e>", lambda arg=drone: ARDroneConfig.flip(drone)) print "-> Press o to start tag detection..." # Add info gui.add_printable_data("Battery", ("navdata_demo", "battery_percentage")) gui.add_printable_data("Number of tags", ("vision_detect", "nb_detected")) gui.add_printable_data("X position", ("vision_detect", "xc")) gui.add_printable_data("Y position", ("vision_detect", "yc")) gui.add_printable_data("Width", ("vision_detect", "width")) gui.add_printable_data("Height", ("vision_detect", "height")) gui.add_printable_data("Distance", ("vision_detect", "distance")) drone.change_callback(gui.callback) # Enable the GUI to receive data from the drone drone.start_navdata() gui.start()
def command_GUI(drone): "Create a GUI to command the drone" global gui ARDroneConfig.outdoor(drone) ARDroneConfig.nervosity_level(drone, 100) gui = ARDroneGUI.ControlWindow(default_action=drone.hover) # Add command gui.add_action("<Up>", drone.forward) gui.add_action("<Down>", drone.backward) gui.add_action("<Left>", drone.left) gui.add_action("<Right>", drone.right) gui.add_action("<z>", drone.up) gui.add_action("<s>", drone.down) gui.add_action("<q>", drone.rotate_left) gui.add_action("<d>", drone.rotate_right) gui.add_action("<a>", drone.takeoff) gui.add_action("<space>", drone.land) gui.add_action("<Return>", drone.emergency) gui.add_action("<t>", drone.reset) gui.add_action("<y>", drone.calibrate) gui.add_action("<o>", lambda arg=drone: ARDroneConfig.activate_tag(drone)) gui.add_action("<e>", lambda arg=drone: ARDroneConfig.flip(drone)) print "-> Press o to start tag detection..." # Add info gui.add_printable_data("Battery", ("navdata_demo", "battery_percentage")) gui.add_printable_data("Number of tags", ("vision_detect", "nb_detected")) gui.add_printable_data("X position", ("vision_detect", "xc")) gui.add_printable_data("Y position", ("vision_detect", "yc")) gui.add_printable_data("Width", ("vision_detect", "width")) gui.add_printable_data("Height", ("vision_detect", "height")) gui.add_printable_data("Distance", ("vision_detect", "distance")) drone.change_callback( gui.callback) # Enable the GUI to receive data from the drone drone.start_navdata() gui.start()