Sample Program 1: MM_S1_Vis_Basic
Program Introduction
Function description |
The robot triggers the Mech-Vision project to run, then obtains vision results, and then performs the pick operation. |
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 MM_S1_Vis_Basic sample program and related explanations.
1. MJOINT(POINTC(264.2282,-217.9533,359.1164,-83.989165,1.303953,176.0864,CFG1,0,0,1), v100perc, fine, tool0);
2. MM_Init_Socket(1);
3. CALL: MM_Open_Socket();
4. CALL: MM_Status := MM_Switch_Model(1, 1);
5. CALL: MM_Status := MM_Start_Vis(1, 0, 1, MM_J);
6. CALL: MM_Status, MM_LastData, MM_POS_NUM := MM_Get_VisData(1);
7. IF MM_Status <> 1100 THEN
8. STOPPROG;
9. END_IF;
10. CALL: MM_Pose[1], MM_Label[1], MM_Tool[1] := MM_Get_Pose(1);
11. MM_Pre := MM_Pose[1];
12. MM_Pre.z := MM_Pose[1].z+100;
13. MLIN(MM_Pre, v500, fine, tool0);
14. MLIN(MM_Pose[1], v500, fine, tool0);
15. MLIN(MM_Pre, v500, fine, tool0);
16. CALL: MM_Close_Socket();
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 | ||
|---|---|---|---|
Move to the image-capturing point |
Therefore, this command means that the robot accurately moves to the capture point in joint motion. |
||
Initialize communication parameters |
The robot uses MM_Init_Socket to set the socket number for communication with the IPC.
|
||
Establish communication |
The robot uses MM_Open_Socket to establish a TCP communication connection with the vision system. |
||
Switch the Mech-Vision parameter recipe |
Therefore, this command means switching the parameter recipe of Mech-Vision project 1 to recipe 1. |
||
Trigger the Mech-Vision project to run |
Therefore, this command means that the robot triggers the vision system to run Mech-Vision project 1 and expects all vision points to be returned. |
||
Obtain vision results |
Therefore, this command means that the robot obtains the vision result returned by Mech-Vision project 1.
When status code |
||
Store the vision result |
Therefore, this command means that the tool pose, label, and end-tool ID of the first vision point are stored in the specified variables respectively. |
||
Move to the pick approach point |
Therefore, the preceding code means that the robot moves linearly to a point 100 mm above the pick point.
|
||
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 point 100 mm above the pick point, that is, reaches the pick departure point.
|
||
Close communication |
The robot uses MM_Close_Socket to disconnect the TCP communication connection from the vision system. |