サンプルプログラム16:MM_S16_Viz_GetDirection
プログラム概要
| 機能 | ロボットが計画された経路を取得し、把持を実行した後、ワーク群の向きに基づいて異なる配置方法を使用します。 | 
| ファイル場所 | Mech-VisionとMech-Vizソフトウェアのインストールディレクトリにある  | 
| 必要なプロジェクト | Mech-Visionプロジェクト、Mech-Vizプロジェクト(ロボットハンド種類がデパレタイズ用吸盤である必要があります) | 
| 使用前提 | 
 | 
| このサンプルプログラムは参考用です。ユーザーは実際の状況に応じて、このプログラムを基に変更を加える必要があります。このプログラムをそのまま使用しないでください。 | 
プログラム説明
以下はMM_S16_Viz_GetDirectionサンプルプログラムのコードと関連する説明です。
| このサンプルは、MM_S15_Viz_GetDoListサンプルに比べて、太字部分のコードのみが追加されています。そのため、MM_S15_Viz_GetDoListサンプルと同じ部分のコードについては、以下で再度説明することはありません(詳細は MM_S15_Viz_GetDoListサンプルの説明 をご参照ください)。 | 
NOP
'--------------------------------
'FUNCTION: trigger Mech-Viz
'project, then get planned path
'and get box direction using
'command 210
'Mech-Mind, 2023-12-25
'--------------------------------
'clear I50 to I69
CLEAR I050 20
'initialize p variables
SUB P071 P071
SUB P072 P072
SUB P073 P073
'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
'trigger Mech-Viz project
CALL JOB:MM_START_VIZ ARGF"2;30"
'get planned path
CALL JOB:MM_GET_PLANDATA ARGF"0;3;51;52;53"
'check whether planned path has
'been got from Mech-Viz
'successfully
IFTHENEXP I053<>2100
	'add error handling logic here
	'according to different error
	'codes
	'e.g.: I053=2038 means no
	'point cloud in ROI
	 PAUSE
ENDIF
'get gripper control signal list
CALL JOB:MM_GET_DOLIST ARGF"0;0"
'close socket connection
CALL JOB:MM_CLOSE_SOCKET
'save waypoints of the planned
'path to local variables one
'by one
CALL JOB:MM_GET_PLANPOSE ARGF"1;71;61;31"
CALL JOB:MM_GET_PLANPOSE ARGF"2;72;71;31"
CALL JOB:MM_GET_PLANPOSE ARGF"3;73;81;31"
'get box direction status from
'planned results
SET I005 R047
'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
'set gripper control signal when
'current waypoint is picking
'waypoint
CALL JOB:MM_SET_DOLIST ARGF"0"
PAUSE
'move to departure waypoint of
'picking
MOVJ P073 VJ=50.00 PL=0
'place the box according to its
'direction
IFTHENEXP I005=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
ELSE
	'move to intermediate waypoint of
	'placing
	 MOVJ C00006 VJ=50.00
	'move to approach waypoint of
	'placing
	 MOVL C00007 V=166.6 PL=0
	'move to placing waypoint
	 MOVL C00008 V=50.0 PL=0
	'add object releasing logic here,
	'such as DOUT OT#(1) OFF
	 PAUSE
	'move to departure waypoint of
	'placing
	 MOVL C00009 V=166.6 PL=0
ENDIF
'move back to robot home position
MOVJ C00010 VJ=50.00
END上記のサンプルプログラムの処理流れは、下図の通りです。
 
下表は太字部分のコードとその説明です。コマンド名のリンクをクリックすることで、その詳細な説明を確認できます。
| 処理流れ | コートと説明 | ||
|---|---|---|---|
| ワーク群の向きを取得 | 
 ロボットは MM_GET_PLANDATA コマンドを使用して経路点の「ビジョン処理による移動」の計画結果を取得し、その後、MM_GET_PLANPOSE コマンドを使用して経路点の「ビジョン処理による移動」の計画結果をロボットメモリからR031から始まる変数に保存します。変数R047はワーク群と吸盤の長辺の方向関係を示し、0は平行、1は垂直を意味します。 上記のコードは、変数R047を変数I005に代入することを意味します。その結果、変数I005はワーク群の向きを表すことになります。 | ||
| ワーク群の向きに基づいて異なる配置方法を使用 | 上記のコードは、ワーク群が吸盤の長辺と平行している場合(I005が0の場合)、そのワーク群を設定されたC00004に配置し、それ以外の場合はワーク群を設定されたC00008に配置することを意味します。 |