Example Program 7: MM_S7_Viz_SwitchTCP
Program Introduction
Description |
The robot starts the Mech-Viz project, obtains the path planning result, and then changes the tool according to the tool ID of the picking waypoint to perform picking and placing. |
File path |
You can navigate to the installation directory of Mech-Vision and Mech-Viz and find the file by using the |
Project |
Mech-Vision and Mech-Viz projects |
Prerequisites |
|
|
Program Description
This part describes the MM_S7_Viz_SwitchTCP example program.
The only difference between the MM_S7_Viz_SwitchTCP example program and the MM_S2_Viz_Basic example program is that MM_S7_Viz_SwitchTCP can change the tool according to the tool ID(this code of this feature is bolded). As such, only the feature of changing the tool according to the tool ID is described in the following section. For information about the parts of MM_S7_Viz_SwitchTCP that are consistent with those of MM_S2_Viz_Basic, see Example Program 2: MM_S2_Viz_Basic. |
NOP
'--------------------------------
'FUNCTION: trigger Mech-Viz
'project and get planned path,
'switch TCP according to the
'toolId
'Mech-Mind, 2023-12-25
'--------------------------------
'clear I50 to I69
CLEAR I050 20
'initialize p variables
SUB P081 P081
SUB P082 P082
SUB P083 P083
'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.10.40;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, 1st argument
'(2) means getting pose in Pose
CALL JOB:MM_GET_VIZDATA ARGF"2;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
'close socket connection
CALL JOB:MM_CLOSE_SOCKET
'switch TCP according to the
'toolId
'save waypoints of the planned
'path to local variables one
'by one
CALL JOB:MM_GET_POSE ARGF"1;81;61;62"
CALL JOB:MM_GET_POSE ARGF"2;82;63;64"
CALL JOB:MM_GET_POSE ARGF"3;83;65;66"
'reset tool signals according
'to received toolid
SWITCH I064 CASE 1
'reset tool signal
'SETE P081 TL#(0)
'SETE P082 TL#(0)
'SETE P083 TL#(0)
PAUSE
CASE 2
'reset tool signal
'SETE P081 TL#(1)
'SETE P082 TL#(1)
'SETE P083 TL#(1)
PAUSE
DEFAULT
'reset tool signal
PAUSE
ENDSWITCH
'follow the planned path to pick
'move to approach waypoint of
'picking
MOVL P081 V=166.6 PL=0
'move to picking waypoint
MOVL P082 V=50.0 PL=0
'add object grasping logic here,
'such as DOUT OT#(1) ON
SWITCH I064 CASE 1
'open tool signal
PAUSE
CASE 2
'open tool signal
PAUSE
DEFAULT
'open tool signal
PAUSE
ENDSWITCH
'move to departure waypoint of
'picking
MOVL P083 V=166.6 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
'reset tool signals according
'to received toolid
SWITCH I064 CASE 1
'reset tool signal
PAUSE
CASE 2
'reset tool signal
PAUSE
DEFAULT
'reset tool signal
PAUSE
ENDSWITCH
'move to departure waypoint of
'placing
MOVL C00005 V=166.6 PL=0
'move back to robot home position
MOVJ C00006 VJ=50.00
END
The workflow corresponding to the above example program code is shown in the figure below.
The table below describes the bolded code.
Feature | Code and description | ||
---|---|---|---|
Obtain the planned path |
The entire statement indicates that the robot obtains the planned path from the Mech-Viz project.
|
||
Store the planned path |
The entire command “CALL JOB:MM_GET_POSE ARGF"1;81;61;62"” stores the TCP, label, and tool ID of the first waypoint in the specified variables.
|
||
Change the tool based on the tool ID |
The above statement allows you to determine the tool to be used when the robot moves to the target pose (picking waypoint) based on the value of the I064, i.e., change the tool according to the label. When the robot moves to the picking waypoint, you can enable the DO signals corresponding to the tool ID, as shown in the following code.
When the robot moves to the placing waypoint, you can disable and reset the DO signals corresponding to the tool ID, as shown in the following code.
|