def draw12():
     lastIndex = dType.SetPTPCmd(api,
                                 dType.PTPMode.PTPJUMPXYZMode,
                                 xArr[0] - xOS,
                                 y2DArr[0][1] - yOS[0],
                                 zCoor,
                                 0,
                                 isQueued=1)[0]
     lastIndex = dType.SetPTPCmd(api,
                                 dType.PTPMode.PTPMOVLXYZMode,
                                 xArr[1] + xOS,
                                 y2DArr[1][2] + yOS[0],
                                 zCoor,
                                 0,
                                 isQueued=1)[0]
     lastIndex = dType.SetPTPCmd(api,
                                 dType.PTPMode.PTPJUMPXYZMode,
                                 xArr[0] - xOS,
                                 y2DArr[0][2] + yOS[0],
                                 zCoor,
                                 0,
                                 isQueued=1)[0]
     lastIndex = dType.SetPTPCmd(api,
                                 dType.PTPMode.PTPMOVLXYZMode,
                                 xArr[1] + xOS,
                                 y2DArr[1][1] - yOS[0],
                                 zCoor,
                                 0,
                                 isQueued=1)[0]
     goHome()
Ejemplo n.º 2
0
def init():
    speed1=150
    speed = 500
    coordinate=500
    dType.SetPTPJointParams(api, speed1,speed1,speed1,speed1,speed1,speed1,speed1,speed1, isQueued=1)
    dType.SetPTPCommonParams(api, speed, speed, isQueued=1)
    dType.SetPTPCoordinateParams(api,coordinate,coordinate,coordinate,coordinate,isQueued=1)
 def draw20():
     lastIndex = dType.SetPTPCmd(api,
                                 dType.PTPMode.PTPJUMPXYZMode,
                                 xArr[2] - xOS,
                                 y2DArr[2][2] - yOS[2],
                                 zCoor,
                                 0,
                                 isQueued=1)[0]
     lastIndex = dType.SetPTPCmd(api,
                                 dType.PTPMode.PTPMOVLXYZMode,
                                 xArr[3] + xOS,
                                 y2DArr[3][3] + yOS[2],
                                 zCoor,
                                 0,
                                 isQueued=1)[0]
     lastIndex = dType.SetPTPCmd(api,
                                 dType.PTPMode.PTPJUMPXYZMode,
                                 xArr[2] - xOS,
                                 y2DArr[2][3] + yOS[2],
                                 zCoor,
                                 0,
                                 isQueued=1)[0]
     lastIndex = dType.SetPTPCmd(api,
                                 dType.PTPMode.PTPMOVLXYZMode,
                                 xArr[3] + xOS,
                                 y2DArr[3][2] - yOS[2],
                                 zCoor,
                                 0,
                                 isQueued=1)[0]
     goHome()
Ejemplo n.º 4
0
def play_1_loop(press_time):
    dobot_state = dType.ConnectDobot(api, "", 115200)[0]
    if dobot_state == dType.DobotConnect.DobotConnect_NoError:
        moveForward()
        press_screen(press_time)
        time.sleep(1.7)
        moveForward(offset=-70)
    dType.DisconnectDobot(api)

    time.sleep(4)
Ejemplo n.º 5
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)
 def goHome():
     lastIndex = dType.SetPTPCmd(api,
                                 dType.PTPMode.PTPJUMPXYZMode,
                                 172,
                                 -120,
                                 50,
                                 0,
                                 isQueued=1)[0]
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
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)
Ejemplo n.º 10
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
Ejemplo n.º 11
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
Ejemplo n.º 12
0
def main():
    state = dType.ConnectDobot(api, "", 115200)[0]
    print("Connect status:", CON_STR[state])
    if state == dType.DobotConnect.DobotConnect_NoError:
        work()
    dType.DisconnectDobot(api)
Ejemplo n.º 13
0
import DobotDll.DobotDllType as dType

CON_STR = {
    dType.DobotConnect.DobotConnect_NoError:  "DobotConnect_NoError",
    dType.DobotConnect.DobotConnect_NotFound: "DobotConnect_NotFound",
    dType.DobotConnect.DobotConnect_Occupied: "DobotConnect_Occupied"}

#Load Dll
api = dType.load()
waittime2=0.486
postion=[236.7609, 35.4838, -26.2502, 8.5236]

def init():
    speed1=150
    speed = 500
    coordinate=500
    dType.SetPTPJointParams(api, speed1,speed1,speed1,speed1,speed1,speed1,speed1,speed1, isQueued=1)
    dType.SetPTPCommonParams(api, speed, speed, isQueued=1)
    dType.SetPTPCoordinateParams(api,coordinate,coordinate,coordinate,coordinate,isQueued=1)
    # Async Home
    # dType.SetHOMECmd(api, temp=0, isQueued=1)


def work():
    dType.SetQueuedCmdClear(api)
    init()
    offset=0;offset1=0
    print(waittime2)
    for i in range(0, 10):
        print(i)
        if i % 4 == 0:
import threading
import DobotDll.DobotDllType as dType
import random
from pynput import keyboard
from pynput.keyboard import KeyCode

CON_STR = {
    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,
Ejemplo n.º 15
0
# just main for dobot
# in: position to put
# out: do the operation
import DobotDll.DobotDllType as dType
CON_STR = {
    dType.DobotConnect.DobotConnect_NoError: "DobotConnect_NoError",
    dType.DobotConnect.DobotConnect_NotFound: "DobotConnect_NotFound",
    dType.DobotConnect.DobotConnect_Occupied: "DobotConnect_Occupied"
}
api = dType.load()


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


def move(p):
    return dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode, p[0], p[1], p[2],
                           0, 1)[0]


class Board:
    n, m, HEIGHT = 9, 9, 2
    LOWER_LEFT = [318, -86, HEIGHT]
    LOWER_RIGHT = [318, 86, HEIGHT]
    UPPER_LEFT = [132, -86, HEIGHT]
    UPPER_RIGHT = [132, 86, HEIGHT]
    CENTER_POINT = [(LOWER_LEFT[0] + UPPER_LEFT[0]) / 2,
                    (LOWER_LEFT[1] + LOWER_RIGHT[1]) / 2, HEIGHT]
Ejemplo n.º 16
0
def connect():
    state = dType.ConnectDobot(api, "", 115200)[0]  # Connect Dobot
    print("Connect status:", CON_STR[state])
    return state
Ejemplo n.º 17
0
def move(p):
    return dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode, p[0], p[1], p[2],
                           0, 1)[0]
Ejemplo n.º 18
0
 def down_chess(self, x, y):
     move(self.location(x, y))
     dType.SetEndEffectorSuctionCup(api, True, False, isQueued=1)
Ejemplo n.º 19
0
 def get_chess(self):
     self.idx += 1
     x, y = self.idx / self.m, self.idx % self.m
     move(self.location(x, y))
     dType.SetEndEffectorSuctionCup(api, True, True, isQueued=1)
Ejemplo n.º 20
0
import time
from DobotDll import DobotDllType as dType

CON_STR = {
    dType.DobotConnect.DobotConnect_NoError: "DobotConnect_NoError",
    dType.DobotConnect.DobotConnect_NotFound: "DobotConnect_NotFound",
    dType.DobotConnect.DobotConnect_Occupied: "DobotConnect_Occupied"
}
api = dType.load()  # Load Dll
postion = [237.7514, 49.2358, -25.7501, 7.1569]


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)