Ejemplo n.º 1
0
def evasion():

    right_turn_speed = 50
    right_turn_time = 0.4

    left_turn_speed = 20
    left_turn_time = 0.4

    go_speed = 5
    go_time = 1

    try:

        go_turn_stop.rightSwingTurn(right_turn_speed, right_turn_time)
        time.sleep(1)

        go_turn_stop.go_forward(go_speed, go_time)

        go_turn_stop.leftSwingTurn(left_turn_speed, left_turn_time)

        while recog_line.get_01()[4] != 0:
            go_turn_stop.go_forward_any(go_speed)

        while recog_line.get_01()[2] != 0:
            go_turn_stop.leftSwingTurn(left_turn_speed, left_turn_time)

    except:
        pass
Ejemplo n.º 2
0
def evasion():

    # Swing Turn 's angle
    right_turn_speed = 50
    right_turn_time = 0.4
    # Point Turn 's angle
    left_turn_speed = 30
    left_turn_time = 0.4
    # The speed that the executor wants
    speed = 43
    go_time = 1.5

    try:
        go_turn_stop.rightSwingTurn(right_turn_speed, right_turn_time)
        time.sleep(1)

        go_turn_stop.go_forward(speed, go_time)

        go_turn_stop.leftSwingTurn(left_turn_speed, left_turn_time)
        time.sleep(1)
        WB = recog_line.get_01()

        while recog_line.numberOfCases(WB) != 'inLine':
            go_turn_stop.go_forward_any(speed)
        else:
            time.sleep(1)
            break

    except:
        pass
Ejemplo n.º 3
0
def evasion():

    right_turn_speed = 50
    short_time = 0.1

    left_turn_speed = 20
    long_time = 0.4

    go_speed = 5
    go_time = 1

    dis = 20
    try:

        get_distance = recog_obs.get_Distance()

        while get_distance > dis:
            go_turn_stop.rightSwingTurn(right_turn_speed, short_time)
            break

        go_turn_stop.go_forward(go_speed, go_time)

        go_turn_stop.leftSwingTurn(left_turn_speed, long_time)

        while recog_line.get_01()[4] != 0:
            go_turn_stop.go_forward_any(go_speed)

        while recog_line.get_01()[2] != 0:
            go_turn_stop.leftSwingTurn(left_turn_speed, short_time)
            break

    except:
        pass
Ejemplo n.º 4
0
def evasion():

    # Swing Turn 's angle
    right_turn_speed = 50
    right_turn_time = 0.4

    # Point Turn 's angle
    left_turn_speed = 20
    left_turn_time = 0.4

    # The speed that the executor wants
    speed_high = 43
    speed_low = 1.5

    try:

        go_turn_stop.rightSwingTurn(right_turn_speed, right_turn_time)
        time.sleep(1)

        while recog_line.get_01() == [0, 0, 0, 0, 0]:
            go_turn_stop.rightRoundTurn(speed_high, speed_low)

        go_turn_stop.leftSwingTurn(left_turn_speed, left_turn_time)
        # go_turn_stop.go_forward(speed,go_time)
        #
        # go_turn_stop.leftSwingTurn(left_turn_speed, left_turn_time)
        # time.sleep(1)
        #
        # WB = recog_line.get_01()
        #
        # while [ True for x in WB if x==0]:
        #     break
        #
        # else :
        #     go_turn_stop.forward_any(speed, go_time)
        #     time.sleep(0.1)

    except:
        pass
Ejemplo n.º 5
0
        if (get_distance > dis):

            W_and_B = recog_line.get_01()
            print(W_and_B)

            if recog_line.numberOfCases(W_and_B) == 'inLine' :
                go_turn_stop.go_forward(speed_go,time_go)
                print("inLine")

            elif recog_line.numberOfCases(W_and_B) == 'leftSide' :
                while W_and_B[2] != 0 :
                    go_turn_stop.rightSwingTurn(speed_turn, time_turn)
                    break
                
            elif recog_line.numberOfCases(W_and_B) == "final" : 
                go_turn_stop.stop()
                print("stop")
                break
            
            else :
                while W_and_B[2] != 0 :
                    go_turn_stop.leftSwingTurn(speed_turn, time_turn)
                    break
               
        else :
            evasion_obs.evasion()

except KeyboardInterrupt:
    go_turn_stop.pwm_low()
Ejemplo n.º 6
0
GPIO.setwarnings(False)
go_turn_stop.pwm_setup()

dis = 17  #20
speed = 20
time = 0.5

try:
    while True:
        # ultra sensor replies the distance back
        get_distance = recog_obs.get_Distacne()
        print('distance= ', get_distance)

        # when the distance is above the dis, moving object forwards
        while (get_distance > dis):
            W_and_B = recog_line.get_01()
            if recog_line.numberOfCases(W_and_B) == 'inLine':
                go_turn_stop.go_forward(speed, time)

            elif recog_line.numberOfCases(W_and_B) == 'leftSide':
                go_turn_stop.rightSwingTurn(speed, time)

            else:
                go_turn_stop.leftSwingTurn(speed, time)

        else:
            evasion_obs.evasion()

except KeyboardInterrupt:
    go_turn_stop.pwm_low()