샘플 프로그램16: MM_S16_Viz_GetDirection
프로그램 소개
기능 설명 |
로봇은 계획 경로를 획득하여 피킹 작업을 완료한 후, 작업물 조합의 방향에 따라 다양한 배치 전략을 선택할 수 있습니다. |
파일 경로 |
Mech-Vision 및 Mech-Viz의 설치 디렉토리로 이동하여 |
필요한 프로젝트 |
Mech-Vision와 Mech-Viz 프로젝트(말단장치 유형은 디팔레타이징 진공 그리퍼입니다) |
사용 전제 조건 |
|
이 샘플 프로그램은 참고용으로 제공됩니다. 사용자는 실제 상황에 맞춰 이 내용을 바탕으로 수정해야 하며, 해당 프로그램을 그대로 사용하지 않도록 하십시오. |
프로그램 설명
다음에는 MM_S16_Viz_GetDirection 샘플 프로그램의 코드와 관련 설명입니다.
MM_S15_Viz_GetDoList 샘플과 비하면, 이 샘플은 아래와 같이 굵게 표시된 코드 부분만 수정되었습니다. 따라서, MM_S16_Viz_GetDirection의 MM_S15_Viz_GetDoList과 일치하는 부분은 다시 설명하지 않습니다. (일치하는 부분에 대한 정보는 MM_S15_Viz_GetDoList 샘플 프로그램 설명을 참조하십시오). |
DEF MM_S16_Viz_GetDirection ( )
;---------------------------------------------------
; FUNCTION: trigger Mech-Viz project, then get
; planned path and get box direction 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]
;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]
;get box direction status from planned results
box_direction=MM_Plan_Results[17]
IF box_direction==0 THEN
;move to intermediate waypoint of placing
PTP drop_waypoint_1 CONT Vel=100 % PDAT4 Tool[1] Base[0]
;move to approach waypoint of placing
LIN drop_app_1 Vel=1 m/s CPDAT2 Tool[1] Base[0]
;move to placing waypoint
LIN drop_1 Vel=0.3 m/s CPDAT3 Tool[1] Base[0]
;add object releasing logic here, such as "$OUT[1]=FALSE"
halt
;move to departure waypoint of placing
LIN drop_app_1 Vel=1 m/s CPDAT2 Tool[1] Base[0]
ELSE
;move to intermediate waypoint of placing
PTP drop_waypoint_2 CONT Vel=100 % PDAT5 Tool[1] Base[0]
;move to approach waypoint of placing
LIN drop_app_2 Vel=1 m/s CPDAT4 Tool[1] Base[0]
;move to placing waypoint
LIN drop_2 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_2 Vel=1 m/s CPDAT4 Tool[1] Base[0]
ENDIF
;move back to robot home position
PTP HOME Vel=100 % DEFAULT
END
위 샘플 프로그램 코드에 해당하는 워크플로는 아래 그림에 표시되어 있습니다.

아래 표는 굵게 표시된 코드의 설명입니다. 명령어 이름의 링크를 클릭하면 해당 명령의 상세 설명을 확인할 수 있습니다.
워크플로 | 코드와 설명 | ||
---|---|---|---|
작업물 조합의 방향을 획득하기 |
로봇은 MM_Get_PlanData명령어를 실행하여 웨이포인트의 비전 이동 계획 결과를 얻고, 그 후 MM_Get_PlanJps 명령어를 실행하여 로봇 메모리에 저장된 웨이포인트의 비전 이동 계획 결과를 MM_Plan_Results 전역 배열에 저장합니다. MM_Plan_Results 전역 배열에서 MM_Plan_Results[17]은 작업물 조합과 진공 그리퍼 길이 사이의 상대적 위치입니다. 0은 평행을 나타내고 1은 수직을 나타냅니다. 위의 코드는 MM_Plan_Results[17] 값을 box_direction 변수에 할당하는 것을 나타내며, box_direction 변수는 작업물 조합의 방향을 나타내게 됩니다. |
||
작업물 조합의 방향에 따라 다양한 배치 전략을 선택하기 |
위 코드는 작업물이 진공 그리퍼의 긴 쪽과 평행할 경우(즉, box_direction가 0인 경우), 작업물이 drop_1 위치에 배치된다는 것을 나타냅니다. 그렇지 않으면 작업물은 drop_2 위치에 배치됩니다. |