예제 #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)
예제 #2
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)
예제 #3
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)
예제 #4
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
예제 #5
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
예제 #6
0
def init(speed=100, coordinate=4000):
    dType.SetQueuedCmdClear(api)
    dType.SetPTPJointParams(api,
                            200,
                            200,
                            200,
                            200,
                            200,
                            200,
                            200,
                            200,
                            isQueued=1)
    # dType.SetPTPJointParams(api, speed, speed, speed, speed, speed, speed, speed, speed, isQueued=1)
    dType.SetPTPCoordinateParams(api,
                                 coordinate,
                                 coordinate,
                                 coordinate,
                                 coordinate,
                                 isQueued=1)
    dType.DobotConnect.DobotConnect_NoError: "DobotConnect_NoError",
    dType.DobotConnect.DobotConnect_NotFound: "DobotConnect_NotFound",
    dType.DobotConnect.DobotConnect_Occupied: "DobotConnect_Occupied"
}

#Load Dll
api = dType.load()

#Connect Dobot
state = dType.ConnectDobot(api, "", 115200)[0]
print("Connect status:", CON_STR[state])

if (state == dType.DobotConnect.DobotConnect_NoError):

    #Clean Command Queued
    dType.SetQueuedCmdClear(api)

    #Async Motion Params Setting
    dType.SetHOMEParams(api, 172, -120, 50, 0, isQueued=1)
    dType.SetPTPJointParams(api,
                            200,
                            200,
                            200,
                            200,
                            200,
                            200,
                            200,
                            200,
                            isQueued=1)
    dType.SetPTPCommonParams(api, 100, 100, isQueued=1)
    dType.SetPTPJumpParams(api, 10, 100, isQueued=1)