Beispiel #1
0
def turn(count):
    direction = False
    if count == 1:  #우회전
        direction = True
    elif count == 0:
        return 0
    time.sleep(0.2)
    car.engine(direction, not direction, 35, 38)  # 39, 39)
    time.sleep(0.5)

    timer = 0
    while not (trackingModule.navigator() & 4):
        car.engine(direction, not direction, 35, 38)  # 39, 39)
        time.sleep(0.05)
        #timer+=1
        #if timer==6000:
        #car.engine(direction, not direction,55,55)
        #time.sleep(0.1)
        #timer=0
    car.engine(True, True, 0, 0)
    time.sleep(0.3)

    while not (trackingModule.navigator() & 4):
        car.engine(not direction, direction, 35, 38)  #39, 39)
        time.sleep(0.0075)
    car.engine(True, True, 0, 0)
    time.sleep(0.3)
Beispiel #2
0
def turn(count):
    direction = False
    if count == 1:  #우회전
        direction = True
    elif count == 0:
        return 0
    time.sleep(0.5)

    car.engine(direction, not direction, 36, 39)
    time.sleep(0.3)
    while not (trackingModule.navigator() & 4):
        car.engine(direction, not direction, 36, 39)
        time.sleep(0.001)
    car.engine(True, True, 0, 0)
    time.sleep(0.3)

    while not (trackingModule.navigator() & 4):
        car.engine(not direction, direction, 36, 39)
        time.sleep(0.0001)
    car.engine(True, True, 0, 0)
    time.sleep(0.3)
Beispiel #3
0
def turn(count):
    #time.sleep(0.5)

    ########
    direction = False
    if count == 1:  #우회전
        direction = True
    time.sleep(0.5)
    while not (trackingModule.navigator() & 4):
        car.engine(direction, not direction, 36, 39)
        time.sleep(0.001)
    car.engine(True, True, 0, 0)
    time.sleep(0.5)

    while not (trackingModule.navigator() & 4):
        car.engine(not direction, direction, 36, 39)
        time.sleep(0.0001)
    car.engine(True, True, 0, 0)
    time.sleep(0.5)

    ########
    '''while count!=0:
Beispiel #4
0
def lineTracking(speed):
    '''선을 따라 주행 comment 입력 필요

	r은 내부 l는 외부주행
	내부 주행 외부 주행은 서로 요구하는 led방향이 반대
	reverse 여부는 바퀴 출력 순서 반대
	평가 요구사함
	바깥은 좌회전으로
	내부는 우회전으로
	즉 서로 led와 바퀴 출력 순서가 반대

	둘다 안들어온다면 지그재그 주행
	'''

    bit = trackingModule.navigator()
    print(bit)

    if bit == 0 or bit == 1 or bit == 3 or bit == 24 or bit == 16:
        stop()
        sleep(0.1)
        whereToBack = True
        if trackingModule.getBeforeBit() > 6:
            whereToBack = False

        #trackingModule.navigator()

        point_turn(whereToBack, speed)
        print(whereToBack)
        counter = 0

        #trackingModule.navigator()

        while not trackingModule.bit4():
            counter += 1
            print(counter)
            if counter % 1500 == 0:
                point_turn(whereToBack, speed)
            elif counter > 60000:
                car.engine(True, True, speed, speed)
                counter = 0
        stop()
        sleep(0.1)

        car.engine(True, True, speed, speed)
    #trackingModule.navigator()
    return True
Beispiel #5
0
def lineTracking(direction):
    '''선을 따라 주행 comment 입력 필요

	r은 내부 l는 외부주행
	내부 주행 외부 주행은 서로 요구하는 led방향이 반대
	reverse 여부는 바퀴 출력 순서 반대
	평가 요구사함
	바깥은 좌회전으로
	내부는 우회전으로
	즉 서로 led와 바퀴 출력 순서가 반대

	둘다 안들어온다면 지그재그 주행
	'''

    lSpeed = 30
    rSpeed = 30
    bit = trackingModule.navigator()
    print(bit)
    if direction == 'l':
        #바깥주행
        if bit == 3 or bit < 2:
            car.engine(False, True, lSpeed, rSpeed)
            count = 0
            while not trackingModule.bit2():
                count += 1
                print(count)
                #차의 성능이 아니라 컴퓨터의 성능에 따라 갈리기 때문에 좋은 파트는 아닌듯
                if count % 1300 == 0:
                    car.engine(False, True, lSpeed + 10,
                               rSpeed)  #배터리 딸려서 턴 제대로 안되면
                elif count > 60000:
                    car.engine(True, True, lSpeed, rSpeed)
                    sleep(0.01)
                    count = 0
                pass
            stop()
            sleep(0.1)
            car.engine(True, True, lSpeed, rSpeed + 5)

        elif bit == 8 or bit > 15:
            car.engine(True, False, lSpeed, rSpeed)
            count = 0
            while not (trackingModule.bit4()):
                count += 1
                print(count)
                if count % 3000 == 0:
                    car.engine(True, False, lSpeed.rSpeed)  ##
                if count > 60000:
                    car.engine(True, True, lSpeed, rSpeed)  ##
                    sleep(0.01)
                    count = 0
                pass
            stop()
            sleep(0.1)
            car.engine(True, True, lSpeed, rSpeed + 5)

    elif direction == 'r':
        #안쪽 주행
        if bit == 24 or bit == 16 or bit == 0:
            car.engine(True, False, lSpeed, rSpeed)
            count = 0
            while not trackingModule.bit8():
                count += 1
                print(count)
                if count % 1400 == 0:
                    car.engine(True, False, lSpeed, rSpeed)
                elif count > 60000:
                    car.engine(True, True, lSpeed, rSpeed)
                    sleep(0.01)
                    count = 0
                pass
            stop()
            sleep(0.1)  #해줘야 딱 특정 비트에 닿았을 때 라는 컨디션을 조절 가능
            car.engine(True, True, lSpeed + 2, rSpeed)

        elif 1 <= bit <= 3:
            car.engine(False, True, lSpeed, rSpeed)
            count = 0
            while not (trackingModule.bit4()):
                count += 1
                print(count)
                if count % 3000 == 0:
                    car.engine(False, True, lSpeed, rSpeed)
                elif count > 60000:
                    car.engine(True, True, lSpeed, rSpeed)
                    sleep(0.01)
                    count = 0
                pass
            stop()
            sleep(0.1)
            car.engine(True, True, lSpeed + 2, rSpeed)

    return True