程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python demo of dobot manipulator

編輯:Python

Official website download address :[OFFICIAL]Dobot Magician Download Center | DOBOT

0.Python Demo technological process :

One 、 Download and install python 3.7.5 64-bit Two 、 take Dobot Dynamic link library into python The running directory of or will Dobot Add the directory where the dynamic link library is located Add to the system Path environment variable ( Corresponding computer system 64 Bits or 32 position ) 3、 ... and 、 Connecting manipulator Magician, And install the suction cup kit Four 、 choice Dobot Demo Folder , And open Dobotcontrol.py file ​​​​​​​. 5、 ... and 、 Click on Run Below Run Module F5, At this time, the program will run , If appear “Connect status:DobotConnect_Occupied”, It indicates that the program connection runs normally and successfully .( Or step 4 Pycharm Open file , Click on the run )

1. Project description

stay Python There are two files in the demo .

(1)DobotControl.py:Dobot Interface secondary packaging

(2)DobotDllType.py: Specific implementation documents

Running DobotControl.py Before , Please put Dobot DLLS Directory added to python In the running directory of , Or add it to the system environment variable .

Different versions Python Need corresponding Demo The corresponding version of . for example ,64 Bit Python You should use 64 Bit Python demo, and 32 Bit Python You should use 32 Bit Python demo, Otherwise the program will report an error .

2.Python API 

DobotDllType.py Encapsulates the Dobot DLL Of C Type interface , This is a Dobot Of Python Interface . load DLL An example of .( Please ensure that the Dobot DLL Directory added to system environment variables , To ensure correct loading DLL.)

def load():
if platform.system() == "Windows":
print(" Yours dll yes 64 position , In order to run smoothly , Please guarantee your python So is the environment 64 position ")
print("python The environment is :",platform.architecture())
return CDLL("./DobotDll.dll", RTLD_GLOBAL)
elif platform.system() == "Darwin":
return CDLL("./libDobotDll.dylib", RTLD_GLOBAL)
elif platform.system() == "Linux":
return cdll.loadLibrary("libDobotDll.so")

3. Code instructions

When calling the interface related to motion (PTP、JOG etc. ) when , Ben DEMO Use queue mode .

(1) load DLL And get the Store object (API). When calling Python API when , This object will be used .

api = dType.load()

(2) Connect to Dobot Magician and print connection information . After successful connection , The relevant code will be processed .

state = dType.ConnectDobot(api, "", 115200)[0]
print("Connect status:",CON_STR[state])
if (state == dType.DobotConnect.DobotConnect_NoError):
#Dobot Operation code
dType.DisconnectDobot(api)

(3) Control queue :

dType.SetQueuedCmdClear(api) # Clear queue
dType.SetQueuedCmdStartExec(api) # Start the queue
dType.SetQueuedCmdStopExec(api) # Stop queue 

(4) Set the motion parameters

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)

(5) take PTP The command is downloaded to the queue , And get the index of the last command .

for i in range(0, 5):
if i % 2 == 0:
offset = 50
else:
offset = -50
lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode, 200 + offset, offset, offset, offset, isQueued = 1)[0]

(6) Wait for the last motion command to complete .

# If the instruction queue has not been completed, wait
while lastIndex > dType.GetQueuedCmdCurrentIndex(api)[0]:
dType.dSleep(100)


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved