728x90
그리퍼의 동작을 제어하는 SetEndEffectorGripper()를 사용하여 반복적으로 그리퍼를 열고 닫는 시험을 진행하였다.
# 2023/3/31 test030
# gripper test - 그리퍼 제어
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 and get the CDLL object
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 (x, y, z, r)
dType.SetHOMEParams(api, 220, 0, 0, 0, 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 (동작은 X 방향으로 왕복 5회)
for i in range(0, 5):
if i % 2 == 0:
offset = 50
else:
offset = -50
lastIndex = dType.SetPTPCmd(api, dType.PTPMode.PTPMOVLXYZMode, 220 + offset, 0, 0, 0, isQueued = 1)[0]
if i % 2 == 0:
lastIndex = dType.SetEndEffectorGripper(api, 1, 1, isQueued=1)[0]
else:
lastIndex = dType.SetEndEffectorGripper(api, 1, 0, isQueued=1)[0]
# Start to Execute Command Queue
lastIndex = dType.SetEndEffectorGripper(api, 0, 0, isQueued=1)[0]
dType.SetQueuedCmdStartExec(api)
# lastIndex를 확인한 명령이 실행 될 때까지 기다린다.
while lastIndex > dType.GetQueuedCmdCurrentIndex(api)[0]:
print("wating...",lastIndex, dType.GetQueuedCmdCurrentIndex(api)[0])
dType.dSleep(100)
# Stop to Execute Command Queued
dType.SetQueuedCmdStopExec(api)
# Disconnect Dobot
dType.DisconnectDobot(api)
'로봇 프로그래밍' 카테고리의 다른 글
좌표체계에서 x와 z축 방향으로 y축 방향 결정하기 (0) | 2023.04.25 |
---|---|
상호작용 - (7) Dobot Magician 로봇 파이썬 프로그래밍 (0) | 2023.04.01 |
팔 동작 - (5) Dobot Magician Python 프로그래밍 (0) | 2023.03.31 |
팔이동 - (4) Dobot Magician 파이썬 프로그래밍 (0) | 2023.03.30 |
Dobot Magician 좌표 체계 및 동작 모드 (0) | 2023.03.29 |