KUKA Inline Measurement Example Program

Program Introduction

Description

You trigger Mech-Metrics from the robot side to perform measurement using Mech-MSR and return the measurement results to Mech-Metrics.

File path

You can navigate to the installation directory of Mech-MSR and Mech-Metrics by using the Mech-MSR/center/MSR_Interface/KUKA/MSR_METRICS_SAMPLE.src path.

Resource requirements

Mech-MSR solution and Mech-Metrics project

Prerequisites

  • Prepare on the inline measurement system side:

    • The current part is associated with the Mech-MSR solution in Mech-Metrics.

    • The current feature is associated with the Mech-MSR project in Mech-Metrics.

    • The Mech-MSR solution and project are open in Mech-MSR.

  • Prepare the robot side:

    • The operations in Set up Standard Interface Communication with KUKA have been completed.

    • The operations in KUKA Automatic Calibration have been completed.

    • The measurement positions have been taught.

    • The robot has been moved to the first measurement position.

    • The robot and camera have been preheated for 30 minutes before starting the measurement.

    • External lighting and temperature are stable before starting the measurement.

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

Program Description

The following is the code of the MSR_Metrics_Sample example program and the related explanation.

&ACCESS RVP
&PARAM EDITMASK = *
&PARAM TEMPLATE = C:\KRC\Roboter\Template\vorgabe
DEF MSR_METRICS_SAMPLE( )
  ;FUNCTION: Test Metrics
  INT MSR_Continuous_Mode,Measure_Result,MSR_Status
  MSR_Continuous_Mode = 0
  Measure_Result = 0
  Failed_Count[1] = 0
  Failed_Count[2] = 0
  Failed_Count[3] = 0
  MSR_Init_Socket("XML_Kuka_MSR",20,30,60)
  MSR_Start_Measure(1,"Piece01","ABC",2,10,20,30,40,50,60,70,80,MSR_Continuous_Mode,MSR_Status)
  IF MSR_Status <> 8100 THEN
    MSR_LOG("Run failed!")
    HALT;
  ENDIF
  MSR_Set_Piece_Info(1,"Piece01",MSR_Status)
  IF MSR_Status <> 8103 THEN
    MSR_LOG("Run failed!")
    HALT;
  ENDIF
;FOLD PTP P3 CONT Vel=100 % PDAT3 Tool[1] Base[0];%{PE}
;FOLD Parameters ;%{h}
;Params IlfProvider=kukaroboter.basistech.inlineforms.movement.old; Kuka.IsGlobalPoint=False; Kuka.PointName=P3; Kuka.BlendingEnabled=True; Kuka.MoveDataPtpName=PDAT3; Kuka.VelocityPtp=100; Kuka.CurrentCDSetIndex=0; Kuka.MovementParameterFieldEnabled=True; IlfCommand=PTP
;ENDFOLD
$BWDSTART = FALSE
PDAT_ACT = PPDAT3
FDAT_ACT = FP3
BAS(#PTP_PARAMS, 100.0)
;SET_CD_PARAMS (0)
PTP XP3 C_Dis
;ENDFOLD
  MSR_Measure_Feature(1,1,MSR_Status)
  IF MSR_Status <> 8101 THEN
    MSR_LOG("Run failed!")
    HALT;
  ENDIF
;FOLD PTP P2 CONT Vel=100 % PDAT2 Tool[1] Base[0];%{PE}
;FOLD Parameters ;%{h}
;Params IlfProvider=kukaroboter.basistech.inlineforms.movement.old; Kuka.IsGlobalPoint=False; Kuka.PointName=P2; Kuka.BlendingEnabled=True; Kuka.MoveDataPtpName=PDAT2; Kuka.VelocityPtp=100; Kuka.CurrentCDSetIndex=0; Kuka.MovementParameterFieldEnabled=True; IlfCommand=PTP
;ENDFOLD
$BWDSTART = FALSE
PDAT_ACT = PPDAT2
FDAT_ACT = FP2
BAS(#PTP_PARAMS, 100.0)
;SET_CD_PARAMS (0)
PTP XP2 C_Dis
;ENDFOLD
  MSR_Measure_Feature(1,1,MSR_Status)
  IF MSR_Status <> 8101 THEN
    MSR_LOG("Run failed!")
    HALT;
  ENDIF
;FOLD PTP P4 CONT Vel=100 % PDAT4 Tool[1] Base[0];%{PE}
;FOLD Parameters ;%{h}
;Params IlfProvider=kukaroboter.basistech.inlineforms.movement.old; Kuka.IsGlobalPoint=False; Kuka.PointName=P4; Kuka.BlendingEnabled=True; Kuka.MoveDataPtpName=PDAT4; Kuka.VelocityPtp=100; Kuka.CurrentCDSetIndex=0; Kuka.MovementParameterFieldEnabled=True; IlfCommand=PTP
;ENDFOLD
$BWDSTART = FALSE
PDAT_ACT = PPDAT4
FDAT_ACT = FP4
BAS(#PTP_PARAMS, 100.0)
;SET_CD_PARAMS (0)
PTP XP4 C_Dis
;ENDFOLD
  MSR_Measure_Feature(1,1,MSR_Status)
  IF MSR_Status <> 8101 THEN
    MSR_LOG("Run failed!")
    HALT;
  ENDIF
  MSR_End_Measure(1,Measure_Result,Failed_Count[],MSR_Status)
  IF MSR_Status <> 8102 THEN
    MSR_LOG("Run failed!")
    HALT;
  ENDIF
  MSR_View_Piece_Data(1,"Piece01",MSR_Status)
  IF MSR_Status <> 8104 THEN
    MSR_LOG("Run failed!")
    HALT;
  ENDIF
  WAIT SEC 1
END

The table below explains the above example program. In the above code, the lines that are commented out start with ;. The following table does not explain what is commented out.

Workflow Code and description

Initialize communication

INT MSR_Continuous_Mode,Measure_Result,MSR_Status
MSR_Continuous_Mode = 0
Measure_Result = 0
Failed_Count[1] = 0
Failed_Count[2] = 0
Failed_Count[3] = 0
MSR_Init_Socket("XML_Kuka_MSR",20,30,60)
  • INT MSR_Continuous_Mode,Measure_Result,MSR_Status: Declare three integer variables, MSR_Continuous_Mode, Measure_Result, and MSR_Status.

    • MSR_Continuous_Mode = 0: Initialize the MSR_Continuous_Mode variable to 0 to store the operation mode.

    • Measure_Result = 0: Initialize the Measure_Result variable to 0 to store the final measurement result.

    • MSR_Status: Used to save the status code returned by the command and verify it after each critical command.

    • Failed_Count[1] = 0: Initialize the first element of the Failed_Count array to 0, which stores the number of measurement items of the part whose value exceeds tolerance 1.

    • Failed_Count[2] = 0: Initialize the second element of the Failed_Count array to 0, which stores the number of measurement items of the part whose value exceeds tolerance 2.

    • Failed_Count[3] = 0: Initialize the third element of the Failed_Count array to 0, which stores the number of measurement items of the part whose value exceeds tolerance 3.

  • MSR_Init_Socket("XML_Kuka_MSR",20,30,60): Establish the TCP communication between the inline measurement system and the robot.

    • "XML_Kuka_MSR": The network configuration file.

    • 20: The signal number corresponding to the communication status (consistent with the XML configuration file parameters).

    • 30: The signal number corresponding to the received status (consistent with the XML configuration file parameters).

    • 60: This parameter specifies the communication timeout period. Unit: seconds.

Start measurement task

MSR_Start_Measure(1,"Piece01","ABC",2,10,20,30,40,50,60,70,80,MSR_Continuous_Mode,MSR_Status)
IF MSR_Status <> 8100 THEN
  MSR_LOG("Run failed!")
  HALT;
ENDIF
  • MSR_Start_Measure (1,"Piece01","ABC",2,10,20,30,40,50,60,70,80,MSR_Continuous_Mode,MSR_Status): Start the measurement task and set custom parameters.

    • 1: Part ID.

    • "Piece01": The part name.

    • "ABC": The part SN.

    • 2: The quality inspection mode. 1 stands for full inspection, and 2 stands for partial inspection.

    • 10, 20, 30, 40, 50, 60, 70, 80: The custom parameters that were set.

    • MSR_Continuous_Mode: Used to save the operation mode returned by Mech-Metrics.

    • MSR_Status: Used to store the status code returned by the command.

  • IF MSR_Status <> 8100 THEN …​ ENDIF: If the status code is not 8100, the execution of the start measurement command has failed, and the robot will log and stop the program.

    The inspection mode and custom parameters should be consistent with those set in Mech-Metrics.

Input part to Mech-Metrics

MSR_Set_Piece_Info(1,"Piece01",MSR_Status)
IF MSR_Status <> 8103 THEN
  MSR_LOG("Run failed!")
  HALT;
ENDIF
  • MSR_Set_Piece_Info(1, "Piece01", MSR_Status): Send the part with an ID of 1 to the Mech-Metrics and obtain the command status code.

    • 1: Part ID.

    • "Piece01": The part SN.

  • IF MSR_Status <> 8103 THEN …​ ENDIF: If the status code is not 8103, it indicates that the part information input has failed. The robot records a log and stops the program.

Move the robot to a specified position and perform feature measurement

$BWDSTART = FALSE
PDAT_ACT = PPDAT3
FDAT_ACT = FP3
BAS(#PTP_PARAMS, 100.0)
PTP XP3 C_Dis
MSR_Measure_Feature(1,1,MSR_Status)
IF MSR_Status <> 8101 THEN
   MSR_LOG("Run failed!")
   HALT;
ENDIF
$BWDSTART = FALSE
PDAT_ACT = PPDAT2
FDAT_ACT = FP2
BAS(#PTP_PARAMS, 100.0)
PTP XP2 C_Dis
MSR_Measure_Feature(1,1,MSR_Status)
IF MSR_Status <> 8101 THEN
   MSR_LOG("Run failed!")
   HALT;
ENDIF
$BWDSTART = FALSE
PDAT_ACT = PPDAT4
FDAT_ACT = FP4
BAS(#PTP_PARAMS, 100.0)
PTP XP4 C_Dis
MSR_Measure_Feature(1,1,MSR_Status)
IF MSR_Status <> 8101 THEN
   MSR_LOG("Run failed!")
   HALT;
ENDIF
  • $BWDSTART = FALSE: Disable reverse path correction, i.e., do not perform path backtracking during execution.

  • PDAT_ACT = PPDAT3: Set the current point-to-point motion parameter to PPDAT3, including velocity, acceleration, and transition settings. PDAT_ACT = PPDAT2 and PDAT_ACT = PPDAT4 are similar.

  • FDAT_ACT = FP3: Set the reference frame of the current position as FP3, which is used to define the reference frame the robot will use for its movements. FDAT_ACT = FP2 and FDAT_ACT = FP4 are similar.

  • BAS(#PTP_PARAMS, 100.0): Apply the basic parameters of point-to-point motion, and set the velocity to 100%.

  • PTP XP3 C_Dis: The robot moves to the XP3 position in a point-to-point manner. PTP XP2 C_Dis and PTP XP4 C_Dis are similar.

  • MSR_Measure_Feature(1,1,MSR_Status): The robot will trigger the execution of the Mech-MSR project with part ID 1 and measurement feature ID 1, and obtain the command status code.

    • First 1: The part ID.

    • Second 1: The feature ID.

  • IF MSR_Status <> 8101 THEN …​ ENDIF: Check the status code every time a feature measurement is triggered. If the status code is not 8101, the robot side logs and stops the program.

You need to teach the measurement positions (XP2, XP3, XP4) in advance. For information about how to teach the waypoint, see the Teach Calibration Start Point section in the KUKA Automatic Calibration.

End measurement

MSR_End_Measure(1,Measure_Result,Failed_Count[],MSR_Status)
IF MSR_Status <> 8102 THEN
  MSR_LOG("Run failed!")
  HALT;
ENDIF
  • MSR_End_Measure(1,Measure_Result,Failed_Count[],MSR_Status): End the measurement, store the measurement results in Measure_Result, update the Failed_Count array, and obtain the command status code at the same time.

  • IF MSR_Status <> 8102 THEN …​ ENDIF: If the status code is not 8102, it indicates that the execution of the end measurement command has failed. The robot side shall log the event and stop the program.

Query history data

MSR_View_Piece_Data(1,"Piece01",MSR_Status)
IF MSR_Status <> 8104 THEN
  MSR_LOG("Run failed!")
  HALT;
ENDIF
WAIT SEC 1
END
  • MSR_View_Piece_Data (1,"Piece01",MSR_Status): Input the part SN through external software, switch the data view of the Mech-Metrics software main interface to the part with the input SN, and obtain the command status code.

  • IF MSR_Status <> 8104 THEN …​ ENDIF: If the status code is not 8104, it indicates that the historical data query has failed. The robot records a log and stops the program.

Is this page helpful?

You can give a feedback in any of the following ways:

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.