Exemplo n.º 1
0
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 !"
Exemplo n.º 2
0
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 !"
Exemplo n.º 3
0
def GPS_Command(drone):
    "Create a GUI to command the GPS"
    global gui, last_coord, a
    a = Log("Drone_GPS.kml", "kml")
    pos1 = GPS_Coord()
    pos2 = GPS_Coord()
    pos3 = GPS_Coord(48.763947, 2.288652)  # Stade
    drone.change_callback(
        save_gps_coord)  # Change the callback so we can save the GPS data
    gui = ARDroneGUI.ControlWindow(default_action=drone.hover)
    # Commands
    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("<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)
    ## GPS
    gui.add_action(
        "<f>",
        lambda arg=last_coord: pos1.setPoint(last_coord[1], last_coord[0]))
    gui.add_action(
        "<g>",
        lambda arg=last_coord: pos2.setPoint(last_coord[1], last_coord[0]))
    gui.add_action(
        "<h>",
        lambda arg=last_coord: pos3.setPoint(last_coord[1], last_coord[0]))
    gui.add_action(
        "<v>",
        lambda arg=pos1: ARDroneConfig.goto_gps_point(drone,
                                                      arg.getPoint()[0],
                                                      arg.getPoint()[1]))
    gui.add_action(
        "<b>",
        lambda arg=pos2: ARDroneConfig.goto_gps_point(drone,
                                                      arg.getPoint()[0],
                                                      arg.getPoint()[1]))
    gui.add_action(
        "<n>",
        lambda arg=pos3: ARDroneConfig.goto_gps_point(drone,
                                                      arg.getPoint()[0],
                                                      arg.getPoint()[1]))

    # Infos
    gui.add_printable_data("Battery", ("navdata_demo", "battery_percentage"))
    gui.add_printable_data("Latitude", ("gps_info", "latitude"))
    gui.add_printable_data("Longitude", ("gps_info", "longitude"))
    gui.add_printable_data("Altitude", ("gps_info", "elevation"))
    gui.add_printable_data("HDOP", ("gps_info", "hdop"))
    gui.add_printable_data("State", ("gps_info", "data_available"))
    print "Press o to start reception...\nF,G,H - Save GPS point\nV,B,N (key must stay pressed) - GOTO GPS Point"
    # We don't start change the callback because we would lost gps info outside the gui
    drone.start_navdata()
    gui.start()
    a.close()
Exemplo n.º 4
0
def GPS_Command(drone):
    "Create a GUI to command the GPS"
    global gui, last_coord, a
    a = Log("Drone_GPS.kml", "kml")
    pos1 = GPS_Coord()
    pos2 = GPS_Coord()
    pos3 = GPS_Coord(48.763947, 2.288652)  # Stade
    drone.change_callback(save_gps_coord)  # Change the callback so we can save the GPS data
    gui = ARDroneGUI.ControlWindow(default_action=drone.hover)
    # Commands
    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("<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)
    ## GPS
    gui.add_action("<f>", lambda arg=last_coord: pos1.setPoint(last_coord[1], last_coord[0]))
    gui.add_action("<g>", lambda arg=last_coord: pos2.setPoint(last_coord[1], last_coord[0]))
    gui.add_action("<h>", lambda arg=last_coord: pos3.setPoint(last_coord[1], last_coord[0]))
    gui.add_action("<v>", lambda arg=pos1: ARDroneConfig.goto_gps_point(drone, arg.getPoint()[0], arg.getPoint()[1]))
    gui.add_action("<b>", lambda arg=pos2: ARDroneConfig.goto_gps_point(drone, arg.getPoint()[0], arg.getPoint()[1]))
    gui.add_action("<n>", lambda arg=pos3: ARDroneConfig.goto_gps_point(drone, arg.getPoint()[0], arg.getPoint()[1]))

    # Infos
    gui.add_printable_data("Battery", ("navdata_demo", "battery_percentage"))
    gui.add_printable_data("Latitude", ("gps_info", "latitude"))
    gui.add_printable_data("Longitude", ("gps_info", "longitude"))
    gui.add_printable_data("Altitude", ("gps_info", "elevation"))
    gui.add_printable_data("HDOP", ("gps_info", "hdop"))
    gui.add_printable_data("State", ("gps_info", "data_available"))
    print "Press o to start reception...\nF,G,H - Save GPS point\nV,B,N (key must stay pressed) - GOTO GPS Point"
    # We don't start change the callback because we would lost gps info outside the gui
    drone.start_navdata()
    gui.start()
    a.close()