def Connect_click():
    """
    Dobotを接続する関数

    Returns
    -------
    0 : int
        Dobotが接続されていない場合
    1 : int
        Dobotが接続された場合
    """
    # Dobot Connect
    state = dType.ConnectDobot(
        api, "", 115200)[0]  # ConectDobot(const char* pointName, int baudrate)
    if (state != dType.DobotConnect.DobotConnect_NoError):
        print('Dobotに接続できませんでした。')
        return 0
    #Clean Command Queued
    dType.SetQueuedCmdClear(api)

    #Async Motion Params Setting
    dType.SetHOMEParams(api, 150, -200, 100, 0, isQueued=1)

    #Async Home
    dType.SetHOMECmd(api, temp=0, isQueued=1)

    #キューに入っているコマンドを実行
    dType.SetQueuedCmdStartExec(api)

    #キューに入っているコマンドを停止
    dType.SetQueuedCmdStopExec(api)

    # Dobotの初期設定
    initDobot(api)
    return 1
Esempio n. 2
0
    def dobotConnect(self):
        if (self.connected):
            print("You're already connected")
        else:
            state = dType.ConnectDobot(self.api, "", 115200)[0]
            if (state == dType.DobotConnect.DobotConnect_NoError):
                print("Connect status:", CON_STR[state])
                dType.SetQueuedCmdClear(self.api)

                dType.SetHOMEParams(self.api,
                                    self.homeX,
                                    self.homeY,
                                    self.homeZ,
                                    0,
                                    isQueued=1)
                dType.SetPTPJointParams(self.api,
                                        200,
                                        200,
                                        200,
                                        200,
                                        200,
                                        200,
                                        200,
                                        200,
                                        isQueued=1)
                dType.SetPTPCommonParams(self.api, 100, 100, isQueued=1)

                dType.SetHOMECmd(self.api, temp=0, isQueued=1)
                self.connected = True
                return self.connected
            else:
                print("Unable to connect")
                print("Connect status:", CON_STR[state])
                return self.connected
Esempio n. 3
0
    def Connect(self):
        #Connect Dobot
        self.state = dType.SearchDobot(self.api, 10)
        if not self.state:
            print("Empty")
            dType.DisconnectDobot(self.api)

        self.state = dType.ConnectDobot(self.api, "", 115200)[0]
        print(CON_STR[self.state])

        if (CON_STR[self.state] == "DobotConnect_NotFound"):
            print("Error")
            dType.DisconnectDobot(self.api)
            sys.exit("Please connect the Robot")
            return False
        dType.GetDeviceSN(self.api)
        dType.GetDeviceName(self.api)
        dType.GetDeviceVersion(self.api)
        dType.GetDeviceWithL(self.api)
        dType.GetPoseL(self.api)
        dType.GetKinematics(self.api)
        #dType.GetHOMEParams(self.api)
        print("Connect status:", CON_STR[self.state])
        if (self.state == dType.DobotConnect.DobotConnect_NoError):
            dType.SetQueuedCmdClear(self.api)
            return True
        else:
            dType.DisconnectDobot(self.api)
            return False
Esempio n. 4
0
def dohome1():
	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 Home
		#lastIndex = dType.SetHOMECmd(api, temp = 0, isQueued = 1)[0]
		lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode, 250, 0, 50, 0, isQueued = 1)[0]

		#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)
Esempio n. 5
0
def dobot_init():
    #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):
        return api
def connectCOM(COMName):
    result = dType.ConnectDobot(api, COMName, 115200)
    if (bDebug):
        print("Connect : {}, err?: {}, id: {}".format(COMName,
                                                      errorString[result[0]],
                                                      result[3]))
    if result[0] == 0:
        return result[3]
    else:
        return -1
def connectCOM(COMName, functionName):
    result = dType.ConnectDobot(api, COMName, 115200)
    print("Connect : ", COMName)
    print("Connect : ", errorString[result[0]])
    if result[0] == 0:
        print("Connect got id: ", result[3])
        t1 = threading.Thread(target=functionName, args=(result[3], ))
        threads.append(t1)
        t1.setDaemon(True)
        t1.start()
Esempio n. 8
0
def connect_dobot():
    CON_STR = {
        dType.DobotConnect.DobotConnect_NoError: "DobotConnect_NoError",
        dType.DobotConnect.DobotConnect_NotFound: "DobotConnect_NotFound",
        dType.DobotConnect.DobotConnect_Occupied: "DobotConnect_Occupied"
    }

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

    return "Connect status:" + CON_STR[state]
Esempio n. 9
0
    def connection(self):
        Tempstate = dType.ConnectDobot(self.api, "", 115200)[0]
        print("Connect status:", self.CON_STR[Tempstate])

        if dType.DobotConnect.DobotConnect_NoError == Tempstate:
            self.state = True
        else:

            self.state = False
            self.close()

        return self.state
Esempio n. 10
0
    def connection(self, connect):

        global connectionState
        
        if connect == True:
            connectionState = dType.ConnectDobot(api, "", 115200)[0]
            print("Dobot connection status:", CON_STR[connectionState])
            dType.DisconnectDobot(api)
            connectionState = None
            print("Disconnected from Dobot")
        else: 
            dType.DisconnectDobot(api)
            connectionState = None
            print("Disconnected from Dobot")
Esempio n. 11
0
def init():

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

    global api
    api = dType.load()
    state = dType.ConnectDobot(api, "ttyUSB0", 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, 206.6887, 0, 135.0133, 0,
                            isQueued=1)  #set home co-ordinates  [x,y,z,r]
        dType.SetPTPJointParams(
            api, 100, 100, 100, 100, 100, 100, 100, 100,
            isQueued=1)  # joint velocities(4) and joint acceleration(4)
        dType.SetPTPCommonParams(
            api, 90, 90, isQueued=1)  #velocity ratio, acceleration ratio
        dType.SetPTPJumpParams(api, 30, 135,
                               isQueued=1)  # jump height , zLimit
        flag = 1
    else:
        pass
    lastIndex = dType.SetPTPCmd(api,
                                dType.PTPMode.PTPMOVJXYZMode,
                                212,
                                -83,
                                20,
                                100,
                                isQueued=1)[0]  #mode, x,y,z,r
    lastIndex = dType.SetHOMECmd(api, temp=0, isQueued=1)[0]

    dType.SetQueuedCmdStartExec(api)

    while lastIndex > dType.GetQueuedCmdCurrentIndex(api)[0]:
        dType.dSleep(500)
        # print(lastIndex)
    # print(lastIndex)
    dType.SetQueuedCmdStopExec(api)
    dType.SetQueuedCmdClear(api)
    return [dType, api]
 def run(self):
     api = dType.load()
     # Connection au  Dobot
     state = dType.ConnectDobot(api, "", 115200)[0]
     # si le robot est dans le bon etat
     if (state == dType.DobotConnect.DobotConnect_NotFound):
         self.fenetre.setInstruction(
             "Veuillez brancher le Dobot Magician ou installez les\ndrivers correspondants."
         )
         return
     elif (state == dType.DobotConnect.DobotConnect_Occupied):
         self.fenetre.setInstruction(
             "Veuillez liberer le port USB du robot et Réessayer.")
         return
     else:
         self.fenetre.setInstruction(
             "Dobot Magician bien connecte. Démarrage du calibrage.")
         z = Dfonct.PositionAndTexte(
             api, self.fenetre,
             "placer le bras à son point le plus bas : ")[2]
         HG = Dfonct.PositionAndTexte(
             api, self.fenetre,
             "placer le bras dans le coin haut gauche : ")
         HD = Dfonct.PositionAndTexte(
             api, self.fenetre, "placer le bras dans le coin haut droit : ")
         BG = Dfonct.PositionAndTexte(
             api, self.fenetre, "placer le bras dans le coin bas gauche : ")
         BD = Dfonct.PositionAndTexte(
             api, self.fenetre, "placer le bras dans le coin bas droit : ")
         self.fenetre.setInstruction(
             "debut du test (appuyer sur une touche pour arrêter).")
         self.fenetre.desactive()
         while (True):
             Dfonct.Movement(api, HG[0], HG[1], z)
             if self.fenetre.entrer == 1:
                 break
             Dfonct.Movement(api, HD[0], HD[1], z)
             if self.fenetre.entrer == 1:
                 break
             Dfonct.Movement(api, BD[0], BD[1], z)
             if self.fenetre.entrer == 1:
                 break
             Dfonct.Movement(api, BG[0], BG[1], z)
             if self.fenetre.entrer == 1:
                 break
         self.fenetre.setInstruction("fin du test.")
Esempio n. 13
0
 def Connect(self):
     #Connect Dobot
     self.state = dType.ConnectDobot(self.api, "", 115200)[0]
     dType.GetDeviceSN(self.api)
     dType.GetDeviceName(self.api)
     dType.GetDeviceVersion(self.api)
     dType.GetDeviceWithL(self.api)
     dType.GetPoseL(self.api)
     dType.GetKinematics(self.api)
     #dType.GetHOMEParams(self.api)
     print("Connect status:",CON_STR[self.state])
     if (self.state == dType.DobotConnect.DobotConnect_NoError):
         dType.SetQueuedCmdClear(self.api)
         return True
     else :
         dType.DisconnectDobot(self.api)
         return False
Esempio n. 14
0
def setup():

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

    global api
    api = dType.load()
    state = dType.ConnectDobot(api, "ttyUSB0", 115200)[0]
    print("Connect status:", CON_STR[state])

    dType.SetQueuedCmdStopExec(api)
    dType.SetQueuedCmdClear(api)
    return [dType, api]
Esempio n. 15
0
    def connect(self):
        # Dobot Connect
        # ConectDobot(const char* pointName, int baudrate)
        state = dType.ConnectDobot(self.api, "", 115200)[0]
        if (state != self.CON_STR[dType.DobotConnect.DobotConnect_NoError]):
            print('Dobot Connect', 'Dobotに接続できませんでした。')
            return

        #Clean Command Queued
        dType.SetQueuedCmdClear(self.api)

        #Async Motion Params Setting
        dType.SetHOMEParams(self.api, 150, -200, 100, 0, isQueued=1)

        #Async Home
        dType.SetHOMECmd(self.api, temp=0, isQueued=1)

        initDobot(self.api)
Esempio n. 16
0
def RobotInit():
    """
    机器人初始化,测试是否有机器人
    :return:
    """
    CON_STR = {
        dType.DobotConnect.DobotConnect_NoError: "success",
        dType.DobotConnect.DobotConnect_NotFound: "unconnect",
        dType.DobotConnect.DobotConnect_Occupied: "ccupied"
    }

    #Load Dll
    api = dType.load()

    #Connect Dobot2
    state = dType.ConnectDobot(api, "", 115200)[0]
    print("Connect status:", CON_STR[state])
    return CON_STR[state]
Esempio n. 17
0
def dobot_exe_nut(dX,dY,dZ,dR,j):
	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 Home
		#dType.SetHOMECmd(api, temp = 0, isQueued = 1)
		dType.SetPTPJumpParams(api,30,140)
		lastIndex = dType.SetIODO(api, 2, 1, 1)[0]
		lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPJUMPXYZMode, dX, dY, dZ, 0, isQueued = 1)[0]
		#lastIndex = dType.SetIODO(api, 2, 1, 1)[0]
		lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPJUMPXYZMode, 180, -198.45, -52.7+j, dR, isQueued = 1)[0]
		lastIndex = dType.SetIODO(api, 2, 0, 1)[0]
		
		#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)
Esempio n. 18
0
    def __init__(self):
        self.api = dType.load()
        self.pieces = 5
        state = dType.ConnectDobot(self.api, "", 115200)[0]

        print("Connect status:", CON_STR[state])

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

        dType.SetHOMEParams(self.api, 250, 0, 50, 0, isQueued=1)
        dType.SetPTPJointParams(self.api,
                                200,
                                200,
                                200,
                                200,
                                200,
                                200,
                                200,
                                200,
                                isQueued=1)
        dType.SetPTPCommonParams(self.api, 100, 100, isQueued=1)
Esempio n. 19
0
    def connect_and_home(self):
        """
        connect and return to zero
        :return:
        """
        # Communicate at 115200 baud rate and print communication status
        state = dType.ConnectDobot(self.api, "", 115200)[0]
        print("Connect status:", self.CON_STATE[state])

        if (state == dType.DobotConnect.DobotConnect_NoError):
            # Clear tasks from old queues
            dType.SetQueuedCmdClear(self.api)

            # Set motion parameters
            dType.SetHOMEParams(self.api, 250, 0, 50, 0, isQueued=1)
            dType.SetPTPJointParams(self.api, 200, 200, 200, 200,
                                    200, 200, 200, 200, isQueued=1)
            dType.SetPTPCommonParams(self.api, 100, 100, isQueued=1)

            # Return to zero
            dType.SetHOMECmd(self.api, temp=0, isQueued=1)
            # Execution command queue
            dType.SetQueuedCmdStartExec(self.api)
Esempio n. 20
0
def connect():
    #Connect Dobot
    state = dType.ConnectDobot(api, "", 115200)[0]
    print("Connect status:", CON_STR[state])
    print(state == dType.DobotConnect.DobotConnect_NoError)

    #Clean Command Queued
    dType.SetQueuedCmdClear(api)

    #Async Motion Params Setting
    dType.SetHOMEParams(api, 250, 0, 50, 0, isQueued=1)
    dType.SetPTPJointParams(api,
                            200,
                            200,
                            200,
                            200,
                            200,
                            200,
                            200,
                            200,
                            isQueued=1)
    dType.SetPTPCommonParams(api, 100, 100, isQueued=1)

    # Enable Linear Rail
    dType.SetDeviceWithL(api, True)

    #Async Home
    dType.SetHOMECmd(api, temp=0, isQueued=1)
    #start point
    dType.SetPTPWithLCmd(api,
                         dType.PTPMode.PTPMOVJXYZMode,
                         232.1355,
                         -2.7885,
                         99.0417,
                         48.8663,
                         0.0,
                         isQueued=1)
Esempio n. 21
0
def connect_click():
    # Dobot Connect
    state = dType.ConnectDobot(
        api, "", 115200)[0]  # ConectDobot(const char* pointName, int baudrate)
    if (state != dType.DobotConnect.DobotConnect_NoError):
        mbox.showinfo('Dobot Connect', 'Dobotに接続できませんでした。')

    #Clean Command Queued
    dType.SetQueuedCmdClear(api)

    #Async Motion Params Setting
    dType.SetHOMEParams(api, 150, -200, 100, 0, isQueued=1)

    #Async Home
    dType.SetHOMECmd(api, temp=0, isQueued=1)

    #キューに入っているコマンドを実行
    dType.SetQueuedCmdStartExec(api)

    #キューに入っているコマンドを停止
    dType.SetQueuedCmdStopExec(api)

    # Dobotの初期設定
    initDobot(api)
    def Connect_click(self):
        """
        Dobotを接続する関数

        Returns
        -------
        result : int
            0 : 接続できなかった場合
            1 : 接続できた場合
            2 : すでに接続されていた場合

        """
        # Dobotがすでに接続されていた場合
        if self.connection == 1:
            return 2
        # Dobot Connect
        state = dType.ConnectDobot(
            self.api, "",
            115200)[0]  # ConectDobot(const char* pointName, int baudrate)
        if (state != dType.DobotConnect.DobotConnect_NoError):
            return 0  # Dobotに接続できなかった場合
        else:
            dType.SetCmdTimeout(self.api, 3000)
            return 1  # Dobotに接続できた場合
Esempio n. 23
0
import threading
import DobotDllType as dType
from flask import Flask

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, "192.168.1.226", 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, 250, 0, 50, 0, isQueued=1)
    dType.SetPTPJointParams(api,
                            200,
                            200,
                            200,
                            200,
                            200,
                            200,
Esempio n. 24
0
import threading
import 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()

#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, 200, 200, 200, 200, isQueued = 1)
    dType.SetPTPJointParams(api, 200, 200, 200, 200, 200, 200, 200, 200, isQueued = 1)
    dType.SetPTPCommonParams(api, 100, 100, isQueued = 1)

    #Async Home
    dType.SetHOMECmd(api, temp = 0, isQueued = 1)

    #Async PTP Motion
    for i in range(0, 5):
        if i % 2 == 0:
Esempio n. 25
0
def arm(threadname):
    '''
    Thread dieu khien robot arm
    '''

    # kich thuoc kho chua hang doi voi tung mau. Dinh dang [x, y, z]
    size_wh = [1, 3, 4]

    # vi tri hien tai cua tung mau trong kho hang. Red Green Blue Yellow
    cur_pos_wh = [[0, 0, 0],
                  [0, 0, 0],
                  [0, 0, 0],
                  [0, 0, 0]]

    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])

    dType.SetHOMEParams(api, 230, 0, 50, 0, isQueued=1)
    dType.SetPTPCoordinateParams(api, 150, 200, 200, 200, isQueued=1)
    dType.SetPTPCommonParams(api, 100, 100, isQueued=1)
    dType.SetPTPJumpParams(api, 60, 150, isQueued=1)
    dType.SetPTPCmd(api, dType.PTPMode.PTPJUMPXYZMode,
                    200, 0, 50, 0, isQueued=1)
    lastIndex = dType.SetHOMECmd(api, temp = 0, isQueued = 1)[0]

    cur_cmd = dType.GetQueuedCmdCurrentIndex(api)[0]
    while lastIndex > cur_cmd:
        dType.dSleep(10)
        cur_cmd = dType.GetQueuedCmdCurrentIndex(api)[0]

    global mm_per_sec

    dType.SetQueuedCmdClear(api)
    dType.SetQueuedCmdStartExec(api)

    f = open('step', 'r')
    STEP_PER_CIRCLE = float(f.read().strip('\n'))
    f.close()
    # so buoc de truc quay du 1 vong
    # STEP_PER_CIRCLE = 17400 #16625 
    # chu vi truc quay bang chuyen
    MM_PER_CIRCLE = 3.1415926535898 * 36.0

    # so buoc trong 1 giay
    pulse_per_sec = mm_per_sec * STEP_PER_CIRCLE / MM_PER_CIRCLE
    
    # dieu khien stepper
    dType.SetEMotor(api, 0, 1, int(pulse_per_sec), isQueued=1)

    
    while state == dType.DobotConnect.DobotConnect_NoError:
        # print('number:', len(ls_obj))
        if ls_obj:
            # print("ab")
            if ls_obj[0].location[1] >= d_robot_cam-20:
                while True:
                    try: 
                        if ls_obj[0].location[1] >= d_robot_cam-100:
                            print(cur_pos_wh)
                            # neu kho hang cua mau dang xet chua day
                            if cur_pos_wh[ls_obj[0].color][2] < size_wh[2]:
                                # dung bang chuyen
                                dType.SetEMotor(api, 0, 1, int(0), isQueued=1)
                                mm_per_sec = 0
                                # gap vat the tu bang chuyen vao kho
                                pick_up(api, ls_obj[0].location, ls_obj[0].orientation, ls_obj[0].color, cur_pos_wh, size_wh)
                            else:
                                end_thread = True
                                break
                            # xoa vat the vua gap
                            ls_obj.pop(0)
                        else:
                            break
                    except Exception:
                        break
                
                # bang chuyen tiep tuc chay
        f = open('step', 'r')
        STEP_PER_CIRCLE = float(f.read().strip('\n'))
        f.close()

        # # chu vi truc quay bang chuyen
        MM_PER_CIRCLE = 3.1415926535898 * 36.0
        # # so buoc trong 1 giay
        mm_per_sec = 40
        pulse_per_sec = mm_per_sec * STEP_PER_CIRCLE / MM_PER_CIRCLE
        dType.SetEMotor(api, 0, 1, int(pulse_per_sec), isQueued=1)
            
        if end_thread:
            dType.SetEMotor(api, 0, 1, 0, isQueued=1)
            print('End process')
            dType.DisconnectDobot(api)
            break
Esempio n. 26
0
        if flagc % 3 == 0:
            flagb = flagb * -1

        dType.dSleep(100)
        print("11111111111:", dobotId)


#start_com("COM5")
#start_com("COM3")

maxDobotConnectCount = 20
comlist = ["COM3", "COM5"]
if __name__ == '__main__':
    threads = []
    print("Start search dobot, count:", maxDobotConnectCount)
    #for i in range(0, maxDobotConnectCount):
    #    result = dType.ConnectDobot(api, "",115200)
    for i in comlist:
        result = dType.ConnectDobot(api, i, 115200)
        if result[0] == 0:
            print("Connect success: dobotid =", result[3])
            t1 = threading.Thread(target=start_com, args=(result[3], ))
            threads.append(t1)
            t1.setDaemon(True)
            t1.start()

    for t in threads:
        t.join()

    dType.DobotExec(api)
Esempio n. 27
0
def connectDobot():
    state = dType.ConnectDobot(api, "", 115200)[0]
    return "Connect status:" + CON_STR[state]
Esempio n. 28
0
from DobotDll import *

#import os, sys
#sys.path.append(os.path.join(os.path.dirname(__file__), '.'))

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]  # ConectDobot(const char* pointName, int baudrate)
print("Connect status:", CON_STR[state])

if (state == dType.DobotConnect.DobotConnect_NoError
    ):  #stateがDobotConnect_NoErrorに等しい時

    #Clean Command Queued
    dType.SetQueuedCmdClear(api)

    #Async Motion Params Setting
    dType.SetHOMEParams(api, 250, 0, 50, 0, isQueued=1)
    dType.SetPTPJointParams(api,
                            200,
                            200,
                            200,
                            200,
Esempio n. 29
0
def main():

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

    server(8002)
import threading,time
import DobotDllType as dType


  
api = dType.load()

errorString = ['Success','NotFound','Occupied']
maxDobotConnectCount = 10

Magic_id = -1
M1_id = -1

if __name__ == '__main__':
	try:
		Magic_id = dType.ConnectDobot(api, "COM4",115200)[3]
		M1_id = dType.ConnectDobot(api, "COM3",115200)[3]
		print("Magic_id : ", Magic_id)
		print("M1_id : ", M1_id)
		
		dobotId = Magic_id
		dType.SetQueuedCmdStartExec(api,dobotId)
		
		dType.SetDeviceWithL(api, dobotId, 1) #!!!! set 1
		##dType.GetDeviceWithL(api, dobotId)
		#dType.SetWAITCmdEx(api, dobotId, 1, 1) #api, dobotId, waitTime, isQueued
		####################################### paste script here:
		current_pose = dType.GetPose(api, dobotId)
		print("start_Mag current_pose:", current_pose)
		dType.SetPTPWithLCmdEx(api, dobotId, 1, current_pose[0], current_pose[1], current_pose[2], current_pose[3], 500, 1) #SetPTPWithLCmdEx(api, dobotId, ptpMode, x, y, z, rHead,  l, isQueued=0)