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
def initDobot(api): # Clean Command Queued dType.SetQueuedCmdClear(api) # デバイスのシリアルナンバーを取得する dSN = dType.GetDeviceSN(api) print(dSN) # デバイス名を取得する dName = dType.GetDeviceName(api) print(dName) # デバイスのバージョンを取得する majorV, minorV, revision = dType.GetDeviceVersion(api) print(majorV, minorV, revision) # JOGパラメータの設定 dType.SetJOGJointParams(api, 200, 200, 200, 200, 200, 200, 200, 200, isQueued=1) # 関節座標系での各モータの速度および加速度の設定 dType.SetJOGCoordinateParams(api, 200, 200, 200, 200, 200, 200, 200, 200, isQueued=1) # デカルト座標系での各方向への速度および加速度の設定 # JOG動作の速度、加速度の比率を設定 dType.SetJOGCommonParams(api, 100, 100, isQueued=1) # PTPパラメータの設定 dType.SetPTPJointParams(api, 200, 200, 200, 200, 200, 200, 200, 200, isQueued=1) # 関節座標系の各モータの速度および加速度を設定 # デカルト座標系での各方向への速度および加速度の設定 dType.SetPTPCoordinateParams(api, 200, 200, 200, 200, isQueued=1) # PTP動作の速度、加速度の比率を設定 dType.SetPTPCommonParams(api, 100, 100, isQueued=1)
def connectDobots(): global id_m1 #also in dobotStates[id_m1] global id_magL global id_magR global m1 global magL global magR print(dType.SearchDobot(api)) USBnms = dType.SearchDobot(api) #print(dType.GetDeviceName(api, id_)) usb_n = 0 while (usb_n < 3): id_ = connectCOM(USBnms[usb_n]) nm = dType.GetDeviceName(api, id_)[0] #print('found %s with id: %d at USB: %s'%(nm, id_, USBnms[usb_n])) if (nm.find('d2') is not -1): magR, id_magL = connectDobot(id_, "magR", QColor(255, 177, 0, 166), window.checkBox_MagL, window.label_MagL_id, True) #1 # rail connected id_nms_default[id_magR] = 'id_magR' elif (nm.find('d1') is not -1): magL, id_magR = connectDobot(id_, "magL", QColor(0, 255, 0, 166), window.checkBox_MagR, window.label_MagR_id) #2 id_nms_default[id_magL] = 'id_magL' elif (nm.find('M1') is not -1): m1, id_m1 = connectDobot( id_, "m1", QColor(0, 111, 255, 166), window.checkBox_M1, window.label_M1_id ) #0 # QtCore.Qt.green QColor(0, 0, 255) Qt.darkYellow id_nms_default[id_m1] = 'id_m1' usb_n += 1 if (dobotStates[id_m1].bOn): print(dType.GetArmOrientation(api, id_m1)) dType.SetArmOrientation( api, id_m1, 0, 1) #!! SetArmOrientationEx -> SetArmOrientation print(dType.GetArmOrientation(api, id_m1)) # print('dobots connected') # print(dobotStates[id_m1]) # print(dobotStates[id_magL]) # print(dobotStates[id_magR]) # print(dobotRailState) m1.posPivot_loadFromFile() setSpeed(35)
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
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, 100, 100, 100, 100, 200, 200, 200, 200, isQueued = 1) dType.SetPTPCommonParams(api, 100, 100, isQueued = 1) #Async Home #dType.SetHOMECmd(api, temp = 0, isQueued = 1) print("Device Name:" , dType.GetDeviceName(api)) print("Hareket-01: Kablo.1 konumuna git") dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode, 260, 150, 80, 0, isQueued = 1) print("Hareket-02: Kablo.1 konumunda alçal") dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode, 260, 150, 20, 0, isQueued = 1) ## Gripper Close dType.SetEndEffectorGripper(api, gripperOn, 1, 1) ###dType.SetWAITCmd(api, 1, 1) print("Hareket-03: Kablo.1 konumunda yüksel") dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode, 260, 150, 80, 0, isQueued = 1) print("Hareket-04: Kablo.2 konumunda git") dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode, 260, -150, 80, 0, isQueued = 1) print("Hareket-05: Kablo.2 konumunda alçal") dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode, 260, -150, 20, 0, isQueued = 1)