샘플 프로그램12: MM_S12_Viz_ForLoop
프로그램 소개
기능 설명 |
로봇이 Mech-Viz 프로젝트 실행을 트리거한 후, 경로 계획 결과를 획득하고 루프를 통해 계획된 경로를 저장하여 피킹 및 배치 작업을 수행합니다. |
파일 경로 |
Mech-Vision 및 Mech-Viz의 설치 디렉토리로 이동하여 |
필요한 프로젝트 |
Mech-Vision와 Mech-Viz 프로젝트 |
사용 전제 조건 |
|
이 샘플 프로그램은 참고용으로 제공됩니다. 사용자는 실제 상황에 맞춰 이 내용을 바탕으로 수정해야 하며, 해당 프로그램을 그대로 사용하지 않도록 하십시오. |
프로그램 설명
다음에는 MM_S12_Viz_ForLoop 샘플 프로그램의 코드와 관련 설명입니다.
MM_S2_Viz_Basic은 웨이포인트를 하나씩으로 저장하는 반면, MM_S12_Viz_ForLoop은 루프를 통해 웨이포인트를 저장합니다(이 기능의 코드는 굵게 표시됨). 따라서, MM_S12_Viz_ForLoop의 MM_S2_Viz_Basic과 일치하는 부분은 다시 설명하지 않습니다. (일치하는 부분에 대한 정보는 MM_S2_Viz_Basic샘플 프로그램 설명을 참조하십시오). |
DEF MM_S12_Viz_ForLoop ( )
;---------------------------------------------------
; FUNCTION: trigger Mech-Viz project and get
; planned path, get poses using for-loop structure
; 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, 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 planned path to local variables using for-loop structure
FOR count=1 TO pos_num
MM_Get_Jps(count,pick_point[count],label[count],toolid[count])
ENDFOR
Xpick_point1=pick_point[1]
Xpick_point2=pick_point[2]
Xpick_point3=pick_point[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
위 샘플 프로그램 코드에 해당하는 워크플로는 아래 그림에 표시되어 있습니다.

아래 표는 루프를 통해 웨이포인트를 저장하는 기능의 설명입니다. 명령어 이름의 링크를 클릭하면 해당 명령의 상세 설명을 확인할 수 있습니다.
워크플로 | 코드와 설명 |
---|---|
루프를 통해 계획 경로를 저장하기 |
분 샘플이 계획한 경로 중 웨이포인트는 3개로 가정하면 위 코드는 MM_S2_Viz_Basic 샘플 중 아래와 같이 3개의 명령어와 동일합니다.
|