コード例 #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
コード例 #2
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
コード例 #3
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.right_SwingTurn(right_turn_speed, right_turn_time)
        time.sleep(1)

        go_turn_stop.go_forward(speed,go_time)

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

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

    except :
        pass
コード例 #4
0
ファイル: maze_move.py プロジェクト: hj9097/practice
def go_right():
    # while back wheel on the line
    go_turn_stop.go_forward(forward_speed)
    time.sleep(forward_time)
    # first 70 turn
    go_turn_stop.right_turn(turn_speed, turn_time1)
    # plus turn
    while recog_line.get_01()[2] != 0:
        go_turn_stop.right_turn(turn_speed, turn_time2)
コード例 #5
0
ファイル: maze_move.py プロジェクト: TongSeola/2018_07_Tong
def go_left() :
''' function needed for moving object left and giving recognized line status'''
    # Continue until the rear wheel is at the crossroads
    go_turn_stop.go_forward(forward_speed)
    time.sleep(forward_time)

    # Output sensor recognition result
    status = recog_line.get_01()
    print("this is ", status)

    if status == [1, 1, 1, 1, 1] :
        # at first, turn 70 degree
        go_turn_stop.left_turn2(turn_speed, turn_time1)
        while recog_line.get_01()[1] != 0:
            # second, give plus turn to move more accurate
            go_turn_stop.left_turn2(turn_speed, turn_time2)
	    print("left turn")
    else :
	# return nothing, because when we use 'if', 'break' sometimes operate oddly
	return
コード例 #6
0
ファイル: maze_move.py プロジェクト: TongSeola/2018_07_Tong
def U_turn() :
''' function needed to do u-turn when the object meets Dead-end path'''
    # Move forward a little
    go_turn_stop.go_forward(forward_speed)
    time.sleep(0.5)

    # at first, turn 130 degree
    go_turn_stop.right_turn2(turn_speed, turn_time1)

    while recog_line.get_01()[2] != 0:
	# second, give plus turn to move more accurate
        go_turn_stop.right_turn2(turn_speed, turn_time2)
        print("U turn")
コード例 #7
0
ファイル: maze_move.py プロジェクト: TongSeola/2018_07_Tong
def go_right() :
''' function needed to move object right'''
    # Continue until the rear wheel is at the crossroads
    go_turn_stop.go_forward(forward_speed)
    time.sleep(forward_time)
    print("go forward")

    # at first, turn 70 degree
    go_turn_stop.right_turn2(turn_speed, turn_time1)

    # second, give plus turn to move more accurate
    while recog_line.get_01()[2] != 0:
        go_turn_stop.right_turn2(turn_speed, turn_time2)
        print("right turn")
コード例 #8
0
ファイル: maze_move.py プロジェクト: hj9097/practice
def go_left():
    go_turn_stop.go_forward(forward_speed)
    time.sleep(forward_time)

    # this code go remove is OK??
    status = recog_line.get_01()
    print("this is ", status)

    if status == [1, 1, 1, 1, 1]:
        # first 70 turn
        go_turn_stop.left_turn(turn_speed, turn_time1)
        while status[2] != 0:
            # plus turn
            go_turn_stop.left_turn(turn_speed, turn_time2)
    elif status == [1, 1, 0, 1, 1]:
        return
コード例 #9
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
コード例 #10
0
ファイル: start_run.py プロジェクト: TongSeola/2018_07_Tong
import recog_line
import setup

dis = 17  #20
speed = 20
time = 0.5

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

        # when the distance is above the dis, moving object forwards
        while (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.right_PointTurn(speed, time)

            else :
                go_turn_stop.left_PointTurn(speed, time)

        else :
            evasion_obs.evasion()

except KeyboardInterrupt:
    go_turn_stop.pwm_low()
コード例 #11
0
ファイル: maze_move.py プロジェクト: hj9097/practice
def U_turn():
    go_turn_stop.go_forward(forward_speed)
    time.sleep(0.5)
    go_turn_stop.right_turn(turn_speed, turn_time1)
    while recog_line.get_01()[2] != 0:
        go_turn_stop.right_turn(turn_speed, turn_time2)
コード例 #12
0
import maze_move
# go_right()  go_left()  U_turn()
import go_turn_stop
# go_forward(speed)  stop()  pwm_setup()  right_turn(speed, running_time)  left_turn(speed, running_time)
import setup
# rightmotor(forward)  leftmotor(forward)
import recog_line
# get_01()  line_status(led_list)
import time
# sleep(time)

status = recog_line.get_01()
speed = 50
# little time
turn_time = 0.5
try:
    while True:
        line = recog_line.line_status(status)
        print(line)

        if line == "inLine":
            go_turn_stop.go_forward(speed)

        elif line == "right":
            go_turn_stop.right_turn(speed, turn_time)
        elif line == "left":
            go_turn_stop.left_turn(speed, turn_time)

        elif line == "Uturn":
            maze_move.U_turn()