샘플 프로그램11: MM_S11_Viz_Timer
프로그램 소개
기능 설명 |
로봇은 타이머를 사용하여 통신을 구축부터 피킹 및 배치 작업을 완료될 때까지 소요된 시간을 계산합니다. |
||
파일 경로 |
Mech-Vision 및 Mech-Viz의 설치 디렉토리로 이동하여
|
||
필요한 프로젝트 |
Mech-Vision와 Mech-Viz 프로젝트 |
||
사용 전제 조건 |
|
이 샘플 프로그램은 참고용으로 제공됩니다. 사용자는 실제 상황에 맞춰 이 내용을 바탕으로 수정해야 하며, 해당 프로그램을 그대로 사용하지 않도록 하십시오. |
프로그램 설명
다음에는 MM_S11_Viz_Timer 샘플 프로그램의 코드와 관련 설명입니다.
MM_S2_Viz_Basic 샘플과 비하면, 이 샘플은 타이머의 기능만 추가되었습니다.(이 기능의 코드가 굵게 표시됨). 따라서, MM_S11_Viz_Timer의 MM_S2_Viz_Basic과 일치하는 부분은 다시 설명하지 않습니다. (일치하는 부분에 대한 정보는 MM_S2_Viz_Basic 샘플 프로그램 설명을 참조하십시오). |
MODULE MM_S11_Viz_Timer
!----------------------------------------------------------
! FUNCTION: trigger Mech-Viz project and get planned path,
! add a timer to record cycle time
! Mech-Mind, 2023-12-25
!----------------------------------------------------------
!define local num variables
LOCAL VAR num pose_num:=0;
LOCAL VAR num status:=0;
LOCAL VAR num toolid{5}:=[0,0,0,0,0];
LOCAL VAR num vis_pose_num:=0;
LOCAL VAR num count:=0;
LOCAL VAR num label{5}:=[0,0,0,0,0];
LOCAL VAR clock timer;
LOCAL VAR num timer_val;
!define local joint&pose variables
LOCAL CONST jointtarget home:=[[0,0,0,0,90,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
LOCAL CONST jointtarget snap_jps:=[[0,0,0,0,90,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
LOCAL PERS robtarget camera_capture:=[[302.00,0.00,558.00],[0,0,-1,0],[0,0,0,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
LOCAL PERS robtarget drop_waypoint:=[[302.00,0.00,558.00],[0,0,-1,0],[0,0,0,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
LOCAL PERS robtarget drop:=[[302.00,0.00,558.00],[0,0,-1,0],[0,0,0,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
LOCAL PERS jointtarget jps{5}:=
[
[[11.1329,49.0771,-36.9666,0.5343,79.2476,-169.477],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]],
[[11.2355,52.1281,-23.3996,0.5938,62.6295,-169.548],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]],
[[11.1329,49.0771,-36.9666,0.5343,79.2476,-169.477],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]],
[[11.1329,49.0771,-36.9666,0.5343,79.2476,-169.477],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]],
[[0,0,0,0,90,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]]
];
!define local tooldata variables
LOCAL PERS tooldata gripper1:=[TRUE,[[0,0,0],[1,0,0,0]],[0.001,[0,0,0.001],[1,0,0,0],0,0,0]];
PROC Sample_11()
!set the acceleration parameters
AccSet 50, 50;
!set the velocity parameters
VelSet 50, 1000;
!move to robot home position
MoveAbsJ home\NoEOffs,v3000,fine,gripper1;
!initialize communication parameters (initialization is required only once)
MM_Init_Socket "127.0.0.1",50000,300;
LOOP:
!reset timer to 0
ClkReset timer;
!start timer
ClkStart timer;
!move to image-capturing position
MoveL camera_capture,v1000,fine,gripper1;
!open socket connection
MM_Open_Socket;
!trigger Mech-Viz project
MM_Start_Viz 2,snap_jps;
!get planned path, 1st argument (1) means getting pose in JPs
MM_Get_VizData 1, pose_num, vis_pose_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
Stop;
ENDIF
!close socket connection
MM_Close_Socket;
!save waypoints of the planned path to local variables one by one
MM_Get_Jps 1,jps{1},label{1},toolid{1};
MM_Get_JPS 2,jps{2},label{2},toolid{2};
MM_Get_JPS 3,jps{3},label{3},toolid{3};
!follow the planned path to pick
!move to approach waypoint of picking
MoveAbsJ jps{1},v1000,fine,gripper1;
!move to picking waypoint
MoveAbsJ jps{2},v300,fine,gripper1;
!add object grasping logic here, such as "setdo DO_1, 1;"
Stop;
!move to departure waypoint of picking
MoveAbsJ jps{3},v1000,fine,gripper1;
!move to intermediate waypoint of placing
MoveJ drop_waypoint,v1000,z50,gripper1;
!move to approach waypoint of placing
MoveL RelTool(drop,0,0,-100),v1000,fine,gripper1;
!move to placing waypoint
MoveL drop,v300,fine,gripper1;
!add object releasing logic here, such as "setdo DO_1, 0;"
Stop;
!move to departure waypoint of placing
MoveL RelTool(drop,0,0,-100),v1000,fine,gripper1;
!move back to robot home position
MoveAbsJ home\NoEOffs,v3000,fine,gripper1;
!stop timer
ClkStop timer;
!read timer value and display the cycle time in log message on teach pendant
timer_val:=ClkRead(timer);
TPWrite "single cycle time: "numtostr(timer_val,3)"s.";
GOTO LOOP;
ENDPROC
ENDMODULE
위 샘플 프로그램 코드에 해당하는 워크플로는 아래 그림에 표시되어 있습니다.

아래 표는 타이머를 사용하여 소요 시간을 계산하는 기능에 대해 설명합니다.
워크플로 | 코드와 설명 |
---|---|
루프를 통헤 통신을 구축부터 피킹 및 배치 작업을 완료될 때까지 소요된 시간을 계산하기 |
위 코드는 프로그램이 LOOP와 GOTO LOOP 사이의 코드를 순환 실행함을 나타냅니다.
위 코드는 타이머 timer을 0으로 재설정하는 것을 나타냅니다.
위 코드는 타이머 timer이 시간을 측정하기 시작함을 나타냅니다.
위 코드는 타이머 timer이 시간을 측정하기 완료함을 나타냅니다.
위의 코드는 ClkRead 명령을 통해 타이머 timer가 계산한 시간을 읽고(즉, 통신 구축부터 피킹 및 배치를 완료할 까지 걸리는 시간) 시간의 값을 timer_val 변수에 할당하는 것을 의미합니다.
이 문장은 측정된 시간을 티치 펜던트 화면에 표시하는 것을 나타냅니다. |