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 Communication Component/Robot_Interface/YASKAWA/sample/MM_S7_Viz_SwitchTCP path.

Project

Mech-Vision and Mech-Viz projects

Prerequisites

  • This example program is provided for reference only. Before using the program, please modify the program according to the actual scenario.

  • This example program involves multiple tools. As such, before you load or run the example program, please enable the multi-tool feature on the teach pendant. For more information, visit Multiple Tool Check.

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.

sample7

The table below describes the bolded code.

Feature Code and description

Obtain the planned path

'get planned path, 1st argument
'(2) means getting pose in Pose
CALL JOB:MM_GET_VIZDATA ARGF"2;51;52;53"
  • MM_GET_VIZDATA: The command to obtain the path planned by Mech-Viz.

  • 2: The pose type of the obtained waypoint is set to TCP.

  • 51: The I variable that has an ID of 51. This variable stores the number of waypoints returned by the vision system.

  • 52: The I variable that has an ID of 52. This variable stores the position of the Vision Move waypoint (picking waypoint) in the path.

  • 53: The I variable that has an ID of 53. This variable stores the command execution status code.

The entire statement indicates that the robot obtains the planned path from the Mech-Viz project.

The returned planned path is saved to the robot memory and cannot be directly obtained. To access the planned path, you must store the planned path in a subsequent step.

Store the planned path

'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"
  • MM_GET_POSE: The command to store the planned path.

  • 1: Store the first waypoint.

  • 81: The P variable that has an ID of 81. This variable stores the TCP of the first waypoint.

  • 61: The I variable that has an ID of 61. This variable stores the label of the first waypoint.

  • 62: The I variable that has an ID of 62. This variable stores the tool ID of the first waypoint.

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.

  • Please store the planned path based on the actual Mech-Viz project. In this example, the path planned by Mech-Viz consists of three waypoints: the first waypoint is the approach waypoint of picking (P081), the second waypoint is the picking waypoint (P082), and the third waypoint is the departure waypoint of picking (P083). I064 specifies the ID of the tool used by the robot when the robot moves to the picking waypoint (P082).

  • This sample will change the tool ID based on the I064 value. As such, the Mech-Viz project used must include a Change Tool Step and the parameters of the Change Tool Step must be properly set.

    • The Change Tool Step must be connected to the Has results output port of the Check Vision Result Step.

    • The Operation Mode parameter of the Change Tool Step must be set to Auto-switch to appropriate tool.

Change the tool based on the tool ID

'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
  • I064: The ID of the tool to be used at the picking waypoint.

  • SETE P081 TL#(0): Set the tool data of P081 to 0.

  • SWITCH~CASE~DEFAULT~ENDSWITCH: Perform different operation based on the value of I064.

    The code here is comments, intended to provide you with an idea of how to write your own code. You need to write the specific execution logic here based on your actual project requirements.
    • If the ID of the tool at the picking waypoint is 1, the tool data of the three positions in the picking path will be set to 0.

    • If the ID of the tool at the picking waypoint is 2, the tool data of the three positions in the picking path will be set to 1.

    • When the tool ID of the picking waypoint is set to another value, the robot will pause.

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.

'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

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.

'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

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.