Sample Program 3: MMS3VisPath
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: |
||
Required project |
Mech-Vision project
|
||
Prerequisites |
|
| 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 |
|
||
Initialize and establish communication |
Close the communication first and then reconnect to ensure that no project remains connected. |
||
Reset the control point and declare tool variables |
|
||
Switch the Mech-Vision parameter recipe and verify the status code |
|
||
Trigger the Mech-Vision project to run and verify the status code |
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.
|
||
Obtain the path planned by the Mech-Vision project |
This command means that the robot obtains the planned path returned by Mech-Vision project 1.
|
||
Store the planned path |
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 |
|
||
Move to the pick approach point |
Move to the pick approach point and set exact-position arrival. |
||
Move to the pick point |
The robot moves linearly from the pick approach point to the pick point.
|
||
Move to the pick departure point |
The robot moves to a position above the pick point, that is, reaches the pick departure point.
|