Standard Interface Commands
This section describes standard interface commands used in TCP communications between a KUKA robot and Mech-Mind Inline Measurement System. The robot (the client) sends commands to Mech-Mind Inline Measurement System (the server), and Mech-Mind Inline Measurement System returns the processed data to the robot.
Command Overview
| Command name | Required | Description |
|---|---|---|
Yes |
This command sets the IP address of the IPC, port number, and timeout period for robot communication. |
|
No |
The robot informs Mech-Metrics to begin switching projects. |
|
Yes |
The robot informs Mech-Metrics to start measuring the new part, and sends the part name, part ID, and other part information to Mech-Metrics. |
|
Yes |
This command triggers the Mech-MSR project that corresponds to the to-be-measured feature to run. If you need to perform multiple measurements, call this command multiple times. |
|
Yes |
The robot informs Mech-Metrics that the measurement ends and requests the measurement result of the part. |
|
No |
In some scenarios, the SN code of the part cannot be obtained at the beginning of measurement. For example, it needs to be scanned during measurement. This command is used to input the part ID during the measurement. |
|
No |
Input the SN of part to allow the main interface of Mech-Metrics to display the data view of the part. |
|
Yes (automatic calibration program) |
Hand-eye calibration (extrinsic parameter calibration) |
Notes
Before you call the commands, take note of the following items:
-
When programming a KUKA robot, take note of the following items:
-
Parameters in the parameter list of a command must be separated by commas (,).
-
Variable-type parameters of a command should use local variables and take effect only in the command.
-
Input and output parameters can be customized in commands.
-
For KUKA robots, commands other than Initialize Communication already contain logic for establishing and disconnecting the TCP communication, which will automatically establish and disconnect before and after execution.
-
-
Unit of data:
-
The unit of joint positions is degree (°).
-
The robot flange pose or tool pose consists of position and orientation. The position (XYZ coordinates) is measured in millimeters (mm), and the orientation is represented by Euler angles in degrees (°).
-
Initialize Communication
This command establishes the TCP communication between the robot and the inline measurement system.
Command format
MM_Init_Socket(XML_Name,Alive_Flag,Recv_Flag,Time_Out)
Input parameters
XML_Name
This parameter specifies the string-type name of the network configuration file. The name is case-sensitive. In this example, the network configuration file is XML_Kuka_MSR.xml. The file is loaded to the robot during communication setup. The file content is as follows.
<ETHERNETKRL>
<CONFIGURATION>
<EXTERNAL>
<IP>192.168.174.1</IP>
<PORT>4000</PORT>
</EXTERNAL>
<INTERNAL>
<ALIVE Set_Flag="20"/>
<BUFFERING Mode="FIFO" Limit="256"/>
<BUFFSIZE Limit="65534"/>
<TIMEOUT Connect="2000" Receive="5000"/>
<MESSAGES Display="enable" Logging="warning"/>
</INTERNAL>
</CONFIGURATION>
<RECEIVE>
<RAW>
<ELEMENT Tag="Buffer" Type="STREAM" Set_Flag="30" EOS="13,10|13|10"/>
</RAW>
</RECEIVE>
</ETHERNETKRL>
In this file, you must ensure that the IP address of the IPC is specified behind the <IP> tag and the host port number used for robot communication is specified behind the <PORT> tag. You can click Robot Communication Configuration in the toolbar of Mech-MSR to specify robot communication configurations.
Alive_Flag
This parameter indicates the value of Set_Flag in the <ALIVE> tag in the XML_Kuka_MSR.xml file. In the above example, the value must be 20. The signal that corresponds to 873 is ON. This signal indicates that the vision system and the robot are connected.
Recv_Flag
This parameter indicates the value of Set_Flag in the <RECEIVE> tag in the XML_Kuka_MSR.xml file. In the above example, the value must be 30. The signal that corresponds to 871 is ON. This signal indicates that the robot received the data sent by the inline measurement system.
Time_Out
This parameter specifies the communication timeout period. Unit: seconds.
Example
MM_Init_Socket("XML_Kuka_MSR",20,30,60)
This example indicates that the TCP communication is established between the inline measurement system and the robot by using the configuration information in the XML_Kuka_MSR.xml file.
Switch Project
The robot tells the Mech-Metrics to start switching projects.
Timing of calling
Before switching the project.
Command Format
MSR_SW_PROJ(Robot_Id:IN,Job:IN,MSR_Status:OUT)
Input Parameters
Robot_Id
This parameter indicates the part ID. The part ID is an integer between 1 and 99. The specified part ID must have been configured in the Configure Part ID window. The data type is num.
Job
This parameter indicates the project ID. The specified project ID must have been configured through project switching rules. The data type is num.
Output Parameters
MSR_Status
This parameter stores the command status code.
8105: The command is executed successfully.
-99: Abnormal Communication with the Robot.
Example
MSR_SW_PROJ(1,1,MSR_Status)
The above example indicates that the system switches to the project with part ID 1 and project ID 1, and saves the command status code in MSR_Status.
Start Measurement Task
The robot informs Mech-Metrics to start measuring the new part, and sends the part name, part ID, and other part information to Mech-Metrics.
Timing of calling
This command is sent when the measurement of a new part begins.
Command format
MSR_Start_Measure(RobotID:IN,Piece_Name:IN,Piece_SN:IN,Qc_Mode:IN,Custom_int1:IN,Custom_int2:IN,Custom_int3:IN,Custom_int4:IN,Custom_int5:IN,Custom_int6:IN,Custom_int7:IN,Custom_int8:IN,MSR_Continuous_Mode:OUT,MSR_Status:OUT)
Input Parameters
RobotID
This parameter indicates the part ID. The part ID is an integer between 1 and 99. The specified part ID must have been configured in the Configure Part ID window. The data type is num.
Piece_Name
This parameter indicates the name of the part to be measured. The part name can contain letters and digits and cannot exceed 20 characters in length. The data type is string.
Piece_SN
This parameter indicates the part SN. The part SN, also known as the part serial number, is the unique identifier of the part. The part SN can contain letters and digits and cannot exceed 30 characters in length. The data type is string.
Qc_Mode
This parameter indicates the quality inspection mode of the part. The data type is num. The meanings of each parameter value are as follows:
-
1: Full inspection.
-
2: Partial inspection.
-
Others: Use existing settings.
Custom_int1-Custom_int8
This parameter is optional. This parameter provides custom information of the part. The data type is num. Custom parameters are used only when more part information needs to be provided to Mech-Metrics. This command supports up to 8 custom parameters. The value of each custom parameter is an integer between 1 and 8.
To use a custom parameter:
-
In the upper-part ribbon of Mech-Metrics, select to configure the meaning for values (1 to 8) of the custom parameter (such as custom parameter 1).
-
Add the custom parameter to the command.
Output parameters
MSR_Continuous_Mode
This parameter indicates whether the execution is loop execution or one-time execution. The data type is num.
0: One-time execution.
1: Loop execution.
If one-time execution is specified, the robot runs the following commands in sequence: Start Measurement Task→Run Feature Measurement→Stop Measurement Task. To measure multiple features, please run the feature measurement command multiple times. For example, if you want to measure two features, the robot runs the following commands in sequence: program starts→Start Measurement Task→Run Feature Measurement→Run Feature Measurement→Stop Measurement Task→program stops.
If loop-execution is specified, the robot executes multiple command sets. The command set starts from Start Measurement Task. If one-time execution is returned by a Start Measurement Task command in a command set, the robot program stops after the command set is executed.
|
MSR_Status
This parameter stores the command status code.
8100: The command is executed successfully.
-99: Abnormal Communication with the Robot.
Example
MSR_Start_Measure(1,"zcl","ABC",2,10,20,30,40,50,60,70,80,MSR_Continuous_Mode,MSR_Status)
The above example indicates that the target object with ID 1 starts measuring a part named zcl with an SN of ABC, and specifies 8 custom parameters.
Run Feature Measurement
This command triggers the Mech-MSR project that corresponds to the to-be-measured feature to run.
Timing of calling
The robot reaches the feature’s image-taking position.
Command format
MSR_Measure_Feature("RobotID:IN","Index_Num:IN","MSR_Status:OUT")
Input Parameters
RobotID
This parameter indicates the part ID. The part ID is an integer between 1 and 99. The specified part ID must have been configured in the Configure Part ID window. The data type is num.
Index_Num
This parameter specifies the ID of the feature to be measured. The data type is num. The ID uniquely identifies the feature. The feature ID is an integer between 1 to 999.
Output Parameters
MSR_Status
This parameter stores the command status code.
8101: The command is executed successfully.
-99: Abnormal Communication with the Robot.
Example
MSR_Measure_Feature(1,1,MSR_Status)
In this example, the robot side triggers the Mech-MSR project whose part ID is 1 and whose measurement feature is 1 to run, and stores the status code in MSR_Status.
Stop Measurement Task
The robot informs Mech-Metrics that the measurement ends and requests the measurement result of the part.
Timing of calling
The last feature of the part has been photographed. The measurement of the part has been completed.
Command format
MSR_End_Measure(Robot_ID:IN,Judge:OUT,Failed_Count[]:OUT,MSR_Status:OUT)
Input Parameters
Robot_ID
This parameter indicates the part ID. The part ID is an integer between 1 and 99. The specified part ID must have been configured in the Configure Part ID window. The data type is num.
Output parameters
Judge
This parameter indicates the result of the part. 0 stands for OK, and 1 for NG. The data type is num.
Failed_Count[]
This parameter indicates the ID of the numeric register for storing the number of measurement items of the part. The data type is num. The details are as follows:
-
Failed_Count[1] Store the number of measurement items where the part is beyond the one-level tolerance range.
-
Failed_Count[2] Store the number of measurement items where the part is outside the secondary tolerance zone.
-
Failed_Count[3] Store the number of measurement items where the part exceeds the three-level tolerance.
MSR_Status
This parameter stores the command status code.
8102: The command is executed successfully.
-99: Abnormal Communication with the Robot.
Example
MSR_End_Measure(1,MSR_Judge,Failed_Count[],MSR_Status)
In the preceding example, the robot informs Mech-Metrics to stop measurement (with part ID 1), and the judgment result of the part is stored in MSR_Judge, and the number of measurement items is stored in Failed_Count[], and the command status code is stored in MSR_Status.
Import Part ID During Measurement
In some scenarios, the SN code of the part cannot be obtained at the beginning of measurement. For example, it needs to be scanned during measurement. This command is used to input the part ID during the measurement.
Timing of calling
The command can be sent any point during the current part measurement process.
Command format
MSR_Set_Piece_Info(Robot_Id:IN,Piece_Sn:IN,MSR_Status:OUT)
Input Parameters
Robot_Id
This parameter indicates the part ID. The part ID is an integer between 1 and 99. The specified part ID must have been configured in the Configure Part ID window. The data type is num.
Piece_Sn
This parameter indicates the part SN. The part SN, also known as the part serial number, is the unique identifier of the part. The part SN can contain letters and digits and cannot exceed 30 characters in length. The data type is string.
Output Parameters
MSR_Status
This parameter stores the command status code.
8103: The command is executed successfully.
-99: Abnormal Communication with the Robot.
Example
MSR_Set_Piece_Info(1,"ert",MSR_Status)
In this example, the robot sends a part with an ert SN code (the part ID is 1) to the Mech-Metrics.
Query Part Historical Data
This command inputs a part SN to allow Mech-Metrics to display the input part data in the main interface.
Timing of calling
The command can be sent at any point when the measurement is not started.
Command format
MSR_View_Piece_Data(Robot_Id,Piece_Sn:IN,MSR_Status:OUT)
Input Parameters
Robot_Id
This parameter indicates the part ID. The part ID is an integer between 1 and 99. The data type is num.
Piece_Sn
This parameter indicates the part SN. The part SN, also known as the part serial number, is the unique identifier of the part. The part SN can contain letters and digits and cannot exceed 30 characters in length. The data type is string.
Output Parameters
MSR_Status
This parameter stores the command status code.
8104: The command is executed successfully.
-99: Abnormal Communication with the Robot.
Example
MSR_View_Piece_Data(1,"ert",MSR_Status)
The above example indicates that the part SN (ert) is sent to Mech-Metrics (with part ID 1), the main interface of the Mech-Metrics is switched to the data view of this part, and the command status code is saved in MSR_Status.
Calibration
This command is used for hand-eye calibration. This command needs to be used in conjunction with the 3D Camera Calibration tool in the Camera menu bar of Mech-MSR.
Calling Sequence
This command is called for hand-eye calibration before the actual measurement.
Command Format
MM_Calib(Move_Type,PosJps,WaitTime,E1)
Input Parameters
{Move_Type}
This parameter indicates the motion type of the robot. Valid values: 1 and 2.
-
1: Linear motion (MOVEL).
-
2: Joint motion (MOVEJ).
{Pos_Jps}
This parameter specifies the type of calibration point poses to be obtained. Valid values: 1 and 2.
-
1: Tool pose.
-
2: Joint positions.
{Wait_time}
This parameter specifies the waiting time after the robot moves to the calibration point (to prevent robot vibration). The unit is seconds, and the default value is 2 seconds. The data type is num.
{Ext}
This parameter specifies the external axis data. Unit: millimeters. If a 7th axis exists and is controlled by the robot on site, this parameter must be set to the specific external exist data. Otherwise, this parameter must be set to 0.
Output Parameters
TOP_Status
This parameter stores the command status code.
Example
MM_Calib(2,1,2,0)
The above example indicates that the pose of the calibration point is specified as a tool pose. The robot moves to the calibration point based on the joint positions of the robot and then waits for 2 seconds.