サンプルプログラム6:MM_S6_Viz_ErrorHandle
プログラム概要
| 機能 | ロボットはMech-Vizプロジェクトをトリガーして実行し、計画された経路を取得します。その後、ステータスコードを確認して、計画された経路が正常に取得されたかどうかを判断します。経路が正常に取得できた場合、ロボットは把持および配置を実行します。それ以外の場合は、ロボットは停止します。 | 
| ファイル場所 | Mech-VisionとMech-Vizソフトウェアのインストールディレクトリにある  | 
| 必要なプロジェクト | Mech-VisionとMech-Vizプロジェクト | 
| 使用前提 | 
 | 
| このサンプルプログラムは参考用です。ユーザーは実際の状況に応じて、このプログラムを基に変更を加える必要があります。このプログラムをそのまま使用しないでください。 | 
プログラム説明
以下はMM_S6_Viz_ErrorHandleサンプルプログラムのコードと関連する説明です。
| このサンプルは、MM_S2_Viz_Basicサンプルに比べて、エラーコードの処理機能(太字部分のコード)のみが追加されています。そのため、MM_S2_Viz_Basicサンプルと同じ部分のコードについては、以下で再度説明することはありません(詳細は MM_S2_Viz_Basicサンプルの説明 をご参照ください)。 | 
NOP
'--------------------------------
'FUNCTION: trigger Mech-Viz
'project and get planned path,
'handle errors according to
'status codes (if no point cloud
'in ROI, retry several times
'before exit loop)
'Mech-Mind, 2023-12-25
'--------------------------------
'clear I50 to I69
CLEAR I050 20
'initialize p variables
SUB P071 P071
SUB P072 P072
SUB P073 P073
'initialize i variables
SET I005 0
'move to robot home position
MOVJ C00000 VJ=50.00
'initialize communication
'parameters (initialization is
'required only once)
CALL JOB:MM_INIT_SOCKET ARGF"192.168.170.22;50000;1"
'move to image-capturing position
MOVJ C00001 VJ=50.00 PL=0
'open socket connection
CALL JOB:MM_OPEN_SOCKET
*RECAP
'trigger Mech-Viz project
CALL JOB:MM_START_VIZ ARGF"2;30"
'get planned path, 1st argument
'(1) means getting pose in JPs
CALL JOB:MM_GET_VIZDATA ARGF"1;51;52;53"
'check whether planned path has
'been got from Mech-Viz
'successfully
IFTHENEXP I053<>2100
	 IFTHENEXP I053=2038
		'no point cloud in ROI, add
		'error handling logic here
		'self-adding then check retry
		'counter
		 INC I005
		 IFTHENEXP I005<3
			'jump back to vision retry label
			'if the number of retry times is
			'less than 3
			 JUMP *RECAP
		 ELSE
			'reset counter and exit loop if
			'the number of retry times has
			'reached 3
			 SET I005 0
			 JUMP *ENDLOOP
		 ENDIF
	 ELSE
		'add other error handling logic
		'here
		 PAUSE
		 JUMP *ENDLOOP
	 ENDIF
ENDIF
'close socket connection
CALL JOB:MM_CLOSE_SOCKET
'save waypoints of the planned
'path to local variables one
'by one
CALL JOB:MM_GET_JPS ARGF"1;71;61;62"
CALL JOB:MM_GET_JPS ARGF"2;72;63;64"
CALL JOB:MM_GET_JPS ARGF"3;73;65;66"
'follow the planned path to pick
'move to approach waypoint of
'picking
MOVJ P071 VJ=50.00 PL=0
'move to picking waypoint
MOVJ P072 VJ=10.00 PL=0
'add object grasping logic here,
'such as DOUT OT#(1) ON
PAUSE
'move to departure waypoint of
'picking
MOVJ P073 VJ=50.00 PL=0
'move to intermediate waypoint of
'placing
MOVJ C00002 VJ=50.00
'move to approach waypoint of
'placing
MOVL C00003 V=166.6 PL=0
'move to placing waypoint
MOVL C00004 V=50.0 PL=0
'add object releasing logic here,
'such as DOUT OT#(1) OFF
PAUSE
'move to departure waypoint of
'placing
MOVL C00005 V=166.6 PL=0
'move back to robot home position
MOVJ C00006 VJ=50.00
*ENDLOOP
PAUSE
END上記のサンプルプログラムの処理流れは、下図の通りです。
 
下表は、エラーコード処理のコードとその説明です。
| 処理流れ | コートと説明 | ||
|---|---|---|---|
| 異なるステータスコードへの処理 | 
 ロボットが MM_GET_VIZDATA コマンドを実行した後、コマンド実行のステータスコードは変数I053に保存されます。ユーザーは具体的なステータスコードに基づいて適切な処理を行うことができます。このサンプルでの処理ロジックは次の通りです。 
 
 |