Пример #1
0
def flight(pidx, pidy, satisfactory, phase, centered, logo, pos_dict,
           is_it_big, seen):
    signal.signal(signal.SIGINT, signal_handler)
    iha = ihamibagla()
    armolveuc(iha, 6)
    saf = time.time()

    phase.value = 2
    logo.value = "odtu"

    inis = 0

    while iha.mode == 'GUIDED':

        #if lost.value == 1:
        #	position(iha, 0, 0, 6, 0)

        if (seen.value == 1) and not centered.value:
            inis = 1

        if centered.value:
            time.sleep(0.1)
            print("Merkezleme basarili")
            """iha.mode="LAND"
					while iha.armed==True:
						if not centered.value:
							#iha.mode = 'GUIDED'
							#time.sleep(0.3)
							#inis = 1
							break
					if not centered.value:
						continue"""

        elif inis:

            send_ned_velocity(iha, pidx.value, pidy.value, 0)
            if time.time() - saf >= 1:
                print(inis, pidx.value, pidy.value)

                saf = time.time()

        if iha.armed == 0:
            time.sleep(0.5)
            break
Пример #2
0
            and (stm_pist[1] - 0.5) < vehicle.location.local_frame.east <
        (stm_pist + 0.5)):
        break

while True:
    baslangic = time.time()
    ret, frame = cap.read()
    cv2.imwrite("kamil.jpg", frame)
    ort_x, ort_y, karar = detect_et(net, meta, "kamil.jpg")
    bitis = time.time()
    fps = 1 / (bitis - baslangic)
    print("FPS : ", fps)
    print("Karar : ", karar)
    print("tb_x:{}, tb_y:{}".format(ort_x, ort_y))
    vx, vy, aci, error = pid.update(ort_x, ort_y)
    print("HizX:{}, HizY:{}, Aci:{}, Error:{}".format(vx, vy,
                                                      (aci * 180) / math.pi,
                                                      error))
    cv2.line(cv_image, (320, 240), (ort_x, ort_y), (0, 0, 0), 5)
    send_ned_velocity(vx, vy, 0)
    if error < 10:
        break

while True:
    vehicle.mode = 'LAND'
    print(vehicle.armed)
    if vehicle.armed == 0:
        break

arm_and_takeoff(6)
Пример #3
0
def flight(pidx, pidy, satisfactory, phase, centered, logo, pos_dict,
           is_it_big, seen):
    signal.signal(signal.SIGINT, signal_handler)
    iha = ihamibagla()
    armolveuc(iha, 9)
    saf = time.time()
    init_heading = 0
    ulp = (4.2, -4.2, 5, init_heading)
    urp = (4.2, 4.2, 5, init_heading)
    dlp = (-4.2, -4.2, 5, init_heading)
    drp = (-4.2, 4.2, 5, init_heading)
    cp = (0, 0, 5, init_heading)

    phase.value = 1
    mapping_points = [(2, 2, 9), (-2, 2, 9), (-2, -2, 9)]

    for (i, (x, y, z)) in enumerate(mapping_points):
        print(iha.heading)
        position(iha, x, y, z, init_heading)
        prev_time = time.time()
        time.sleep(1.5)
        satisfactory.value = 0
        while (satisfactory.value != 1):
            if int(time.time() - prev_time) % 10 == 0:
                pass
                #print("Mapping checkpoint {}".format(i))
    print("buladayim")
    phase.value = 2
    corresponding_pos = {1: ulp, 2: urp, 3: dlp, 4: drp, 5: cp}

    for i in ["stm", "odtu", "ort", "helikopter_inis", "turk_bayragi"]:
        i = i.encode("utf-8")
        iha.mode = 'GUIDED'
        time.sleep(0.3)
        yaklasim = 1
        inis = 0
        yaklas = 0
        logo.value = i
        if iha.mode == 'GUIDED':
            pos = corresponding_pos.get(pos_dict.get(i))
            while True:
                #print("yaklasim:",yaklasim, "yaklas:", yaklas, "inis:",inis, "center:",centered.value, "seen:",seen.value)
                if (seen.value == 1) and not centered.value:
                    inis = 1
                    yaklasim = 0
                    yaklas = 0

                if yaklasim:
                    armolveuc(iha, 5)
                    position(iha, *pos)
                    time.sleep(2)

                    if ((iha.location.local_frame.north <= -4.2 * 0.92
                         and iha.location.local_frame.east >= 4.2 * 0.92) or
                        (iha.location.local_frame.north >= 4.2 * 0.92
                         and iha.location.local_frame.east >= 4.2 * 0.92) or
                        (iha.location.local_frame.north <= -4.2 * 0.92
                         and iha.location.local_frame.east <= -4.2 * 0.92) or
                        (iha.location.local_frame.north >= 4.2 * 0.92
                         and iha.location.local_frame.east <= -4.2 * 0.92)
                            or (iha.location.local_frame.north <= -8)
                            or (iha.location.local_frame.north >= 8)
                            or (iha.location.local_frame.east <= -8)
                            or (iha.location.local_frame.east >= 8)):
                        yaklasim = 0
                        inis = 1
                elif yaklas:
                    position(iha, *pos)
                    time.sleep(5)
                    yaklas = 0
                    inis = 1

                elif centered.value:
                    iha.mode = "LAND"
                    while iha.armed == True:
                        if not centered.value:
                            #iha.mode = 'GUIDED'
                            #time.sleep(0.3)
                            #inis = 1
                            break
                    if not centered.value:
                        continue

                elif inis:
                    send_ned_velocity(iha, pidx.value, pidy.value, 0)
                    if time.time() - saf >= 1:
                        print(inis, pidx.value, pidy.value)

                        saf = time.time()
                #print("lost={} ,enough={} ",format(lost.value,is_it_big.value))
                #if lost.value==1 and not is_it_big.value:
                #	inis=0
                #	yaklas=1

                if iha.armed == 0:
                    time.sleep(0.5)
                    break

            if i == "turk_bayragi" and iha.location.global_relative_frame.alt <= 0.1:
                iha.armed = False
        else:
            break
Пример #4
0
    time.sleep(d_time)
    yaw = vehicle.attitude.yaw
    loc = vehicle.location.local_frame
    N = loc.north
    E = loc.east
    D = vehicle.rangefinder.distance
    print("Coordinates: %.3f N, %.3f E, %.3f D Yaw: %3f\r" % (N, E, D, yaw))
    log.write_line('%s\t%s\t%s\t%s\n' % (N, E, D, yaw))

    if i > 3 / d_time:
        ang = 347
        r = 1
        vn = math.cos(ang * math.pi / 180) * r
        ve = math.sin(ang * math.pi / 180) * r
        print((vn, ve))
        u.send_ned_velocity(vehicle, vn, ve, 0)
        print 'moving!'

u.send_ned_velocity(vehicle, 0, 0, 0)

print 'Landing!'
log.close()
while (vehicle.mode.name != 'LAND'):
    vehicle.mode = dk.VehicleMode('LAND')
    time.sleep(2)

time.sleep(4)

while (vehicle.mode.name != mode):
    print 'Mode: %s\r' % vehicle.mode.name
    vehicle.mode = dk.VehicleMode(mode)