Sample Program 3: MMS3VisPath

You are currently viewing the documentation for a pre-release version (2.2.0). To access documentation for other versions, click the "Switch Version" button located in the upper-right corner of the page.

■ If you're unsure about the version of the product you are using, please contact Mech-Mind Technical Support for assistance.

Program Introduction

Function description

The robot triggers the Mech-Vision project to run, obtains the planned path, and then performs pick-and-place operations.

File path

Under the installation directory of Mech-Vision and Mech-Viz: Communication Component/Robot_Interface/MELFA/MMS3VisPath.

Required project

Mech-Vision project

The Mech-Vision project must contain a Path Planning Step, and the Port Type parameter of the Output Step must be set to "Predefined (Robot Path)".

Prerequisites

  1. Standard interface communication has been configured in MELFA Standard Interface Communication Configuration.

  2. Automatic calibration has been completed in MELFA Automatic Calibration.

This sample program is for reference only. Modify it according to your actual situation. Do not use it directly.

Program Explanation

The following shows the code of the MMS3VisPath sample program and related explanations.

  #Include "MMMODULE"
  MM_DROP_COM()
  Mcomnum = 7
  MM_INT_COM(Mcomnum)
  Tool P_NTool
  PMTool=(+0.00,+0.00,+0.00,+0.00,+0.00,+0.00)
  Tool PMTool
  MM_SET_MOD(1,1,MM_Status)
  If MM_Status <> 1107 Then
    Hlt
  EndIf
  MM_START_VIS(1,5,1,JntSend,MM_Status)
  If MM_Status <> 1102 Then
    Hlt
  EndIf
  Dim MM_Result(20,8)
  MM_GET_VISP(1,2,5,MM_Status,MM_WayPt_Num,MM_VPos_Num,MM_Result)
  If MM_Status <> 1103 Then
    Hlt
  EndIf
  MM_GET_POS(MM_Result,1,PPick_pre,MM_Label,MM_ToolID)
  MM_GET_POS(MM_Result,2,PPick,MM_Label2,MM_ToolID2)
  MM_GET_POS(MM_Result,3,PPick_after,MM_Label3,MM_ToolID3)
  MM_DROP_COM()
  Mov PPick_pre
  Mvs PPick
  Fine 0,P
  Mvs PPick
  Hlt
  Mvs PPick_after

The workflow corresponding to the sample program code above is shown in the following figure.

The following table explains the logic of the preceding program. Click the hyperlink of a command to view its detailed description.

Workflow Code and description

Import the MM_Module header file

  #Include "MMMODULE"

Initialize and establish communication

  MM_DROP_COM()
  Mcomnum = 7
  MM_INT_COM(Mcomnum)

Close the communication first and then reconnect to ensure that no project remains connected.

Reset the control point and declare tool variables

  Tool P_NTool
  PMTool=(+0.00,+0.00,+0.00,+0.00,+0.00,+0.00)
  Tool PMTool

Switch the Mech-Vision parameter recipe and verify the status code

  MM_SET_MOD(1,1,MM_Status)
  If MM_Status <> 1107 Then
    Hlt
  EndIf
  • MM_SET_MOD: Command for switching the Mech-Vision parameter recipe.

  • The first 1: Indicates the project ID of Mech-Vision.

  • The second 1: Indicates the expected parameter recipe ID in the Mech-Vision project.

  • <>: Not equal to. When status code MM_Status is 1107, the robot has successfully switched the parameter recipe.

Trigger the Mech-Vision project to run and verify the status code

  MM_START_VIS(1,5,1,JntSend,MM_Status)
  If MM_Status <> 1102 Then
    Hlt
  EndIf
  • MM_START_VIS: Command for triggering the Mech-Vision project to run.

  • The first 1: Mech-Vision project ID.

  • 5: Expected number of vision points returned by the Mech-Vision project.

  • The second 1: Pass the robot’s current flange pose to the Mech-Vision project.

This command means that the robot triggers the vision system to run the Mech-Vision project whose ID is 1, and expects the Mech-Vision project to return 5 vision points.

  • <>: Not equal to. When status code MM_Status is 1102, the robot has successfully run the Mech-Vision project.

Obtain the path planned by the Mech-Vision project

  Dim MM_Result(20,8)
  MM_GET_VISP(1,2,5,MM_Status,MM_WayPt_Num,MM_VPos_Num,MM_Result)
  If MM_Status <> 1103 Then
    Hlt
  EndIf
  • MM_GET_VISP: Command for obtaining the path planned by Mech-Vision.

  • Dim MM_Result(20,8): Defines a two-dimensional array used to store path points.

  • 1: Specifies the Mech-Vision project ID as 1.

  • 2: Specifies that the pose form of path points to obtain is tool pose.

  • 5: Maximum number of positions sent at one time.

This command means that the robot obtains the planned path returned by Mech-Vision project 1.

  • <>: Not equal to. When status code MM_Status is 1103, the robot has successfully obtained the planned path from Mech-Vision.

Store the planned path

  MM_GET_POS(MM_Result,1,PPick_pre,MM_Label,MM_ToolID)
  MM_GET_POS(MM_Result,2,PPick,MM_Label2,MM_ToolID2)
  MM_GET_POS(MM_Result,3,PPick_after,MM_Label3,MM_ToolID3)
  • MM_GET_POS: Command for storing the planned path. Using the first line as an example:

  • MM_Result: Two-dimensional array used to store the planned path.

  • 1: Index value of the first path point to be stored.

  • PPick_pre: Used to store the joint positions of the first path point.

  • MM_Label: Used to store the label of the first path point.

  • MM_ToolID: Used to store the tool ID of the first path point.

This command means that the tool pose, label, and end-tool ID of the first vision point are stored in the specified variables respectively.

Disconnect communication

  MM_DROP_COM()

Move to the pick approach point

  Mov PPick_pre
  Fine 0,P

Move to the pick approach point and set exact-position arrival.

Move to the pick point

  Mov PPick
  Hlt

The robot moves linearly from the pick approach point to the pick point.

Hlt means stopping program execution. If you have added statements for setting DO, you can delete the Pause statement here.

Move to the pick departure point

  Mvs PPick_after

The robot moves to a position above the pick point, that is, reaches the pick departure point.

Adding a pick departure point can prevent the robot from colliding with scene objects such as bins during movement. You can modify the negative Z-axis offset here (PPick_pre.Z) according to the actual scenario to ensure collision-free departure.

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.