샘플 프로그램14: MM_S14_Vis_GetUserData
프로그램 소개
기능 설명 |
로봇은 비전 결과를 얻을 때 동시에 Mech-Vision 프로젝트에서 출력된 사용자 정의 데이터를 획득합니다. |
파일 경로 |
Mech-Vision 및 Mech-Viz의 설치 디렉토리로 이동하여 |
필요한 프로젝트 |
Mech-Vision 프로젝트 (하나 이상의 사용자 정의 포트를 출력 스텝에 추가해야 합니다). |
사용 전제 조건 |
|
이 샘플 프로그램은 참고용으로 제공됩니다. 사용자는 실제 상황에 맞춰 이 내용을 바탕으로 수정해야 하며, 해당 프로그램을 그대로 사용하지 않도록 하십시오. |
프로그램 설명
다음에는 MM_S14_Vis_GetUserData 샘플 프로그램의 코드와 관련 설명입니다.
MM_S1_Vis_Basic 샘플과 비하면, 이 샘플은 아래와 같이 굵게 표시된 코드 부분만 수정되었습니다. 따라서, MM_S14_Vis_GetUserData의 MM_S1_Vis_Basic과 일치하는 부분은 다시 설명하지 않습니다. (일치하는 부분에 대한 정보는 MM_S1_Vis_Basic샘플 프로그램 설명을 참조하십시오). |
DEF MM_S14_Vis_GetUserData ( )
;---------------------------------------------------
; FUNCTION: trigger Mech-Vision project and get
; vision result and custom data using command 110
; 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 NO.1 Mech-Vision project
MM_Start_Vis(1,0,2,init_jps)
;get vision result from NO.1 Mech-Vision project
MM_Get_Dy_Data(1,pos_num,status)
;check whether vision result has been got from Mech-Vision successfully
IF status<> 1100 THEN
;add error handling logic here according to different error codes
;e.g.: status=1003 means no point cloud in ROI
;e.g.: status=1002 means no vision result
halt
ENDIF
;save first vision point data to local variables
MM_Get_DyPose(1,Xpick_point,label)
;save received custom data
offset_x=MM_UserData[1]
offset_y=MM_UserData[2]
offset_z=MM_UserData[3]
;calculate pick approach point based on pick point
tool_offset={X 0,Y 0,Z -100,A 0,B 0,C 0}
Xpick_app=Xpick_point:tool_offset
;move to intermediate waypoint of picking
PTP pick_waypoint CONT Vel=50 % PDAT1 Tool[1] Base[0]
;move to approach waypoint of picking
LIN pick_app Vel=1 m/s CPDAT2 Tool[1] Base[0]
;move to picking waypoint
LIN pick_point Vel=0.3 m/s CPDAT3 Tool[1] Base[0]
;add object grasping logic here, such as "$OUT[1]=TRUE"
halt
;move to departure waypoint of picking
LIN pick_app Vel=1 m/s CPDAT2 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 CPDAT4 Tool[1] Base[0]
;move to placing waypoint
LIN drop Vel=0.3 m/s CPDAT5 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 CPDAT4 Tool[1] Base[0]
;move back to robot home position
PTP HOME Vel=100 % DEFAULT
END
위 샘플 프로그램 코드에 해당하는 워크플로는 아래 그림에 표시되어 있습니다.

아래 표는 굵게 표시된 코드의 설명입니다. 명령어 이름의 링크를 클릭하면 해당 명령의 상세 설명을 확인할 수 있습니다.
워크플로 | 코드와 설명 | ||||
---|---|---|---|---|---|
비전 결과 획득하기(사용자 정의 데이터가 포함됨) |
따라서, 이 명령어는 로봇이 Mech-Vision 프로젝트 1이 반환한 비전 결과를 획득하는 명령어입니다(사용자 정의 데이터가 포함됨).
|
||||
비전 결과를 저장하기(사용자 정의 데이터가 포함됨) |
따라서 이 명령어는 첫 번째 비전 포인트의말단장치 포즈, 레이블 및 사용자 정의 데이터를 지정된 변수에 저장한다는 것입니다.
위의 코드는 비전 포인트(피킹 웨이포인트)의 3개 사용자 정의 데이터 MM_UserData[1], MM_UserData[2], MM_UserData[3]을 각각 offset_x, offset_y, offset_z에 할당하는 것입니다.
|