def change_fly(event):
    """
    What happens when you press the fly button on the matplotlib interface.

    This button toggles flying. If pressed while still flying it turns lands
    the drone and turns off
    """

    global flying, scf
    scf = SyncCrazyflie(uri, cf=Crazyflie(rw_cache='./cache'))
    scf.open_link()
    reset_estimator(scf)
    check_battery(scf, "Drone")
    start_console(scf, "Drone")
    flying = not flying
    if not flying and scf:
        scf.cf.commander.send_position_setpoint(0, 0, 0, 0)
Ejemplo n.º 2
0
            openvr.TrackingUniverseStanding, 0,
            openvr.k_unMaxTrackedDeviceCount)

        pos1 = get_tracker_pos(tracker1)
        pos2 = get_tracker_pos(tracker2)

        x = (pos1[0] + pos2[0]) / 2
        y = (pos1[1] + pos2[1]) / 2
        z = (pos1[2] + pos2[2]) / 2 + height_above_center
        setpoint = [x, y, z]

        scf.cf.commander.send_position_setpoint(setpoint[0], setpoint[1],
                                                setpoint[2], 0)

    pc.go_to(0.0, 0.0, 0.0)

    # Make sure that the last packet leaves before the link is closed
    # since the message queue is not flushed before closing
    time.sleep(0.1)


print("Starting")
if __name__ == '__main__':
    cflib.crtp.init_drivers(enable_debug_driver=False)

    with SyncCrazyflie(uri, cf=Crazyflie(rw_cache='./cache')) as scf:
        reset_estimator(scf)
        run_sequence(scf)

    openvr.shutdown()