Sample Program 2: MM_S2_Viz_Basic
Program Introduction
Function description |
The robot triggers the Mech-Viz project to run, then obtains the path-planning result, and then performs the pick operation. |
File path |
Under the installation directory of Mech-Vision and Mech-Viz: |
Required project |
Mech-Vision project and Mech-Viz 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_S2_Viz_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_Set_Branch(1, 1);
5. CALL: MM_Status := MM_Start_Viz(1, MM_J);
6. CALL: MM_Status, MM_LastData, MM_POS_NUM, MM_VisPosNum := MM_Get_VizData(1);
7. IF MM_Status <> 2100 THEN
8. STOPPROG;
9. END_IF;
10. CALL: MM_JPS[1], MM_Label[1], MM_Tool[1] := MM_GET_JPS(1);
11. CALL: MM_JPS[2], MM_Label[2], MM_Tool[2] := MM_GET_JPS(2);
12. CALL: MM_JPS[3], MM_Label[3], MM_Tool[3] := MM_GET_JPS(3);
13. CALL: MM_JPS[4], MM_Label[4], MM_Tool[4] := MM_GET_JPS(4);
14. CALL: MM_JPS[5], MM_Label[5], MM_Tool[5] := MM_GET_JPS(5);
15. MJOINT(MM_JPS[1], v500, fine, tool0);
16. MJOINT(MM_JPS[2], v500, fine, tool0);
17. MJOINT(MM_JPS[3], v500, fine, tool0);
18. MJOINT(MM_JPS[4], v500, fine, tool0);
19. MJOINT(MM_JPS[5], v500, fine, tool0);
20. 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. |
||
Set the message-branch exit of Mech-Viz |
Therefore, this command means that at message branch step 1, the Mech-Viz project continues from exit 0, as shown below.
|
||
Trigger the Mech-Viz project to run |
Therefore, this command means that the robot triggers the vision system to run the Mech-Viz project, and then Mech-Viz plans the robot picking path based on the vision result output by Mech-Vision. |
||
Obtain the planned path |
Therefore, this command means that the robot obtains the planned path returned by the Mech-Viz project.
When status code |
||
Store the planned path |
Therefore,
|
||
Move to each planned path point |
The robot moves to each path point in sequence by joint motion. |
||
Close communication |
The robot uses MM_Close_Socket to disconnect the TCP communication connection from the vision system. |