샘플 프로그램5: MM_S5_Viz_SetBranch
프로그램 소개
기능 설명 |
로봇은 먼저 Mech-Viz 프로젝트 실행을 트리거한 후, Mech-Viz 메시지 분기 아웃 포트를 설정하고 경로 계획 결과를 획득하여 피킹 및 배치 작업을 수행합니다. |
||
파일 경로 |
Mech-Vision 및 Mech-Viz의 설치 디렉토리로 이동하여 |
||
필요한 프로젝트 |
Mech-Vision와 Mech-Viz 프로젝트
|
||
사용 전제 조건 |
|
이 샘플 프로그램은 참고용으로 제공됩니다. 사용자는 실제 상황에 맞춰 이 내용을 바탕으로 수정해야 하며, 해당 프로그램을 그대로 사용하지 않도록 하십시오. |
프로그램 설명
다음에는 MM_S5_Viz_SetBranch 샘플 프로그램의 코드와 관련 설명입니다.
MM_S2_Viz_Basic 샘플과 비하면, 이 샘플은Mech-Viz메시지 분기 아웃 포트를 설정할 수 있는 기능만 추가되었습니다.(이 기능의 코드가 굵게 표시됨). 따라서, MM_S5_Viz_SetBranch의 MM_S2_Viz_Basic과 일치하는 부분은 다시 설명하지 않습니다. (일치하는 부분에 대한 정보는 MM_S2_Viz_Basic샘플 프로그램 설명을 참조하십시오). |
DEF MM_S5_Viz_SetBranch ( )
;---------------------------------------------------
; FUNCTION: trigger Mech-Viz project then set
; branch and get planned path
; 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)
;set branch, "MM_Set_Branch(Branch_Num,Exit_Num)"
MM_Set_Branch(1,1)
;get planned path, 1st argument (1) means getting pose in JPs
MM_Get_VizData(1,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
;save waypoints of the planned path to local variables one by one
MM_Get_Jps(1,Xpick_point1,label[1],toolid[1])
MM_Get_Jps(2,Xpick_point2,label[2],toolid[2])
MM_Get_Jps(3,Xpick_point3,label[3],toolid[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, such as "$OUT[1]=TRUE"
halt
;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
위 샘플 프로그램 코드에 해당하는 워크플로는 아래 그림에 표시되어 있습니다.

아래 표는 Mech-Viz 메시지 분기 아웃 포트 설정의 설명입니다. 명령어 이름의 링크를 클릭하면 해당 명령의 상세 설명을 확인할 수 있습니다.
워크플로 | 코드와 설명 |
---|---|
Mech-Viz 메시지 분기 아웃 포트를 설정하기 |
따라서, 이 명령어는 Mech-Viz프로젝트가 번호 1인 "메시지 분기" 스텝에서 아웃 포트0을 통해 계속 실행된다는 것을 나타내며, 아래 그림과 같습니다. ![]() |