Exemple #1
0
def work():
    dType.SetQueuedCmdClear(api)
    init()
    offset=0;offset1=0
    print(waittime2)
    for i in range(0, 10):
        print(i)
        if i % 4 == 0:
            offset = 0;offset1=-50
        elif i % 4 == 1:
            offset = 0;offset1=0
        elif i % 4 == 2:
            offset = 20;offset1=0
        elif i % 4 == 3:
            offset = 0;offset1=0

        lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode,postion[0]+offset1,postion[1],postion[2]-offset,postion[3])[0]  # 移动

        dType.SetWAITCmd(api, waittime2)
        dType.SetQueuedCmdStartExec(api)

    # Wait for Executing Last Command
    while lastIndex > dType.GetQueuedCmdCurrentIndex(api)[0]:
        dType.dSleep(200)

    #Stop to Execute Command Queued
    dType.SetQueuedCmdStopExec(api)
    dType.SetQueuedCmdClear(api)
Exemple #2
0
def move_around():  # just for test
    dType.SetQueuedCmdClear(api)  # Clean Command Queued
    move(board.LOWER_LEFT)
    move(board.LOWER_RIGHT)
    move(board.UPPER_RIGHT)
    move(board.UPPER_LEFT)
    last_idx = move(board.CENTER_POINT)
    dType.SetQueuedCmdStartExec(api)  # Start to Execute Command Queued
    while last_idx > dType.GetQueuedCmdCurrentIndex(
            api)[0]:  # Wait for Executing Last Command
        dType.dSleep(100)
    dType.SetQueuedCmdStopExec(api)  # Stop to Execute Command Queued
Exemple #3
0
def set_chess(x, y):
    dType.SetQueuedCmdClear(api)  # Clean Command Queued
    chess.get_chess()
    move(relay_point)
    board.down_chess(x, y)
    last_idx = move(origin_point)

    dType.SetQueuedCmdStartExec(api)  # Start to Execute Command Queued
    while last_idx > dType.GetQueuedCmdCurrentIndex(
            api)[0]:  # Wait for Executing Last Command
        dType.dSleep(100)
    dType.SetQueuedCmdStopExec(api)  # Stop to Execute Command Queued
Exemple #4
0
def moveForward(offset=0):
    """
    default offset = 0 means above the phone screen
    when offset = -70, it means moveBackward, (to let the camera get the image)
    """
    dType.SetQueuedCmdClear(api)
    init()
    last_index = dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode,
                                 postion[0] + offset, postion[1], postion[2],
                                 postion[3])[0]  # 移动
    dType.SetQueuedCmdStartExec(api)

    while last_index > dType.GetQueuedCmdCurrentIndex(api)[0]:
        dType.dSleep(0)
    dType.SetQueuedCmdStopExec(api)
    dType.SetQueuedCmdClear(api)
Exemple #5
0
def press_screen(press_time):
    dType.SetQueuedCmdClear(api)
    init() if press_time > 450 else init(coordinate=9000)
    waiting_time = press_time * 0.001

    for i in range(0, 2):
        offset = 20 if i % 2 == 0 else 0
        last_index = dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode,
                                     postion[0], postion[1],
                                     postion[2] - offset, postion[3])[0]
        dType.SetWAITCmd(api, waiting_time)
        dType.SetQueuedCmdStartExec(api)

    while last_index > dType.GetQueuedCmdCurrentIndex(api)[0]:
        dType.dSleep(0)
    dType.SetQueuedCmdStopExec(api)
    dType.SetQueuedCmdClear(api)
    #    for y in range(0, 4):
    #        lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPJUMPXYZMode, xArr[x], y2DArr[x][y], zCoor, 0, isQueued = 1)[0]
    #        print(y2DArr[x][y])

    #Draws an 'X' in each grid space, uses offset value
    #Moves from UL to BR, jumps to UR, then moves from UR to BL
    #for x in range(0, 3):
    #    for y in range(0, 3):
    #        lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPJUMPXYZMode, xArr[x] - xOS, y2DArr[x][y] - yOS[x], zCoor, 0, isQueued = 1)[0]
    #        lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode, xArr[x + 1] + xOS, y2DArr[x + 1][y + 1] + yOS[x], zCoor, 0, isQueued = 1)[0]
    #        lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPJUMPXYZMode, xArr[x] - xOS, y2DArr[x][y + 1] + yOS[x], zCoor, 0, isQueued = 1)[0]
    #        lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode, xArr[x + 1] + xOS, y2DArr[x + 1][y] - yOS[x], zCoor, 0, isQueued = 1)[0]

    #lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPJUMPXYZMode, xMax, yArr[0], zCoor, 0, isQueued = 1)[0] #A coords
    #lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPJUMPXYZMode, xMax, yArr[1], zCoor, 0, isQueued = 1)[0] #B coords
    #lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPJUMPXYZMode, xMin, yArr[2], zCoor, 0, isQueued = 1)[0] #C coords
    #lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPJUMPXYZMode, xMin, yArr[3], zCoor, 0, isQueued = 1)[0] #D coords

    #Start to Execute Command Queued
    dType.SetQueuedCmdStartExec(api)

    #Wait for Executing Last Command
    while lastIndex > dType.GetQueuedCmdCurrentIndex(api)[0]:
        dType.dSleep(100)

    #Stop to Execute Command Queued
    dType.SetQueuedCmdStopExec(api)

#Disconnect Dobot
dType.DisconnectDobot(api)