샘플 프로그램18: MM_S18_Viz_GetUserData
프로그램 소개
기능 설명 |
로봇은 피킹 경로를 얻을 때 동시에 Mech-Vision 프로젝트에서 출력된 사용자 정의 데이터를 획득합니다. |
파일 경로 |
Mech-Vision 및 Mech-Viz의 설치 디렉토리로 이동하여 |
필요한 프로젝트 |
Mech-Vision 프로젝트 (하나 이상의 사용자 정의 포트를 출력 스텝에 추가해야 합니다) 및 Mech-Viz 프로젝트 (말단장치 유형은 디팔레타이징 진공 그리퍼입니다). |
사용 전제 조건 |
|
이 샘플 프로그램은 참고용으로 제공됩니다. 사용자는 실제 상황에 맞춰 이 내용을 바탕으로 수정해야 하며, 해당 프로그램을 그대로 사용하지 않도록 하십시오. |
프로그램 설명
다음에는 MM_S18_Viz_GetUserData 샘플 프로그램의 코드와 관련 설명입니다.
MM_S15_Viz_GetDoList 샘플과 비하면, 이 샘플은 아래와 같이 굵게 표시된 코드 부분만 수정되었습니다. 따라서, MM_S18_Viz_GetUserData의 MM_S15_Viz_GetDoList과 일치하는 부분은 다시 설명하지 않습니다. (일치하는 부분에 대한 정보는 MM_S15_Viz_GetDoList 샘플 프로그램 설명을 참조하십시오). |
DEF MM_S18_Viz_GetUserData ( )
;---------------------------------------------------
; FUNCTION: trigger Mech-Viz project, then get
; planned path and get custom data from Mech-Vision
; using command 210
; Mech-Mind, 2023-12-25
;---------------------------------------------------
;set current tool no. to 1
BAS(#TOOL,1)
;set current base no. to 0
BAS(#BASE,0)
;move to robot home position
PTP HOME Vel=100 % DEFAULT
;initialize communication parameters (initialization is required only once)
MM_Init_Socket("XML_Kuka_MMIND",873,871,60)
;move to image-capturing position
LIN camera_capture Vel=1 m/s CPDAT1 Tool[1] Base[0]
;trigger Mech-Viz project
MM_Start_Viz(2,init_jps)
;get planned path
MM_Get_PlanData(0,3,pos_num,vis_pos_num,status)
;check whether planned path has been got from Mech-Viz successfully
IF status<> 2100 THEN
;add error handling logic here according to different error codes
;e.g.: status=2038 means no point cloud in ROI
halt
ENDIF
;get gripper control signal list
MM_Get_Dolist(0,0)
;save waypoints of the planned path to local variables one by one
FOR count=1 TO pos_num
MM_Get_PlanJps(count,3,pick_point[count],move_type[count],tool_num[count],speed[count])
ENDFOR
Xpick_point1=pick_point[1]
Xpick_point2=pick_point[2]
Xpick_point3=pick_point[3]
;save received custom data
offset_x=MM_UserData[1]
offset_y=MM_UserData[2]
offset_z=MM_UserData[3]
;follow the planned path to pick
;move to approach waypoint of picking
PTP pick_point1 Vel=50 % PDAT1 Tool[1] Base[0]
;move to picking waypoint
PTP pick_point2 Vel=10 % PDAT2 Tool[1] Base[0]
;add object grasping logic here
halt
;set gripper control signal
MM_Set_Dolist(0)
;move to departure waypoint of picking
PTP pick_point3 Vel=50 % PDAT3 Tool[1] Base[0]
;move to intermediate waypoint of placing
PTP drop_waypoint CONT Vel=100 % PDAT2 Tool[1] Base[0]
;move to approach waypoint of placing
LIN drop_app Vel=1 m/s CPDAT3 Tool[1] Base[0]
;move to placing waypoint
LIN drop Vel=0.3 m/s CPDAT4 Tool[1] Base[0]
;add object releasing logic here, such as "$OUT[1]=FALSE"
halt
;move to departure waypoint of placing
LIN drop_app Vel=1 m/s CPDAT3 Tool[1] Base[0]
;move back to robot home position
PTP HOME Vel=100 % DEFAULT
END
위 샘플 프로그램 코드에 해당하는 워크플로는 아래 그림에 표시되어 있습니다.

아래 표는 새롭게 추가된 코드의 설명입니다. 명령어 이름의 링크를 클릭하면 해당 명령의 상세 설명을 확인할 수 있습니다.
워크플로 | 코드와 설명 | ||||
---|---|---|---|---|---|
웨이포인트의 사용자 정의 데이터를 저장하기 |
로봇은 MM_Get_PlanData명령어를 실행하여 웨이포인트의 비전 이동 계획 결과와 사용자 정의 데이터를 얻고, 그 후 MM_Get_PlanJps 명령어를 실행하여 로봇 메모리에 저장된 웨이포인트의 비전 이동 계획 결과를 MM_Plan_Results 전역 배열에 저장하고 사용자 정의 데이터를 MM_UserData 전역 배열에 저장합니다. 위의 코드는 비전 이동 웨이포인트(피킹 웨이포인트)의 3개 사용자 정의 데이터 MM_UserData[1], MM_UserData[2], MM_UserData[3]을 각각 offset_x, offset_y, offset_z에 할당하는 것입니다.
|