Example program 2: MM_S2_Viz_Basic
Program Introduction
Description |
The robot triggers the Mech-Viz project to run, and then obtains the planned path for picking and placing. |
File path |
You can navigate to the installation directory of Mech-Vision and Mech-Viz and find the file by using the |
Project |
Mech-Vision and Mech-Viz projects |
Prerequisites |
|
This example program is provided for reference only. Before using the program, please modify the program according to the actual scenario. |
Program Description
This part describes the MM_S2_Viz_Basic example program.
1: !-------------------------------- ;
2: !FUNCTION: trigger Mech-Viz ;
3: !project and get planned path ;
4: !Mech-Mind, 2023-12-25 ;
5: !-------------------------------- ;
6: ;
7: !set current uframe NO. to 0 ;
8: UFRAME_NUM=0 ;
9: !set current tool NO. to 1 ;
10: UTOOL_NUM=1 ;
11: !move to robot home position ;
12:J P[1] 100% FINE ;
13: !initialize communication ;
14: !parameters(initialization is ;
15: !required only once) ;
16: CALL MM_INIT_SKT('8','127.0.0.1',50000,5) ;
17: !move to image-capturing position ;
18:L P[2] 1000mm/sec FINE ;
19: !trigger Mech-Viz project ;
20: CALL MM_START_VIZ(2,10) ;
21: !get planned path, 1st argument ;
22: !(1) means getting pose in JPs ;
23: CALL MM_GET_VIZ(1,51,52,53) ;
24: !check whether planned path has ;
25: !been got from Mech-Viz ;
26: !successfully ;
27: IF R[53]<>2100,JMP LBL[99] ;
28: !save waypoints of the planned ;
29: !path to local variables one ;
30: !by one ;
31: CALL MM_GET_JPS(1,60,70,80) ;
32: CALL MM_GET_JPS(2,61,71,81) ;
33: CALL MM_GET_JPS(3,62,72,82) ;
34: !follow the planned path to pick ;
35: !move to approach waypoint ;
36: !of picking ;
37:J PR[60] 50% FINE ;
38: !move to picking waypoint ;
39:J PR[61] 10% FINE ;
40: !add object grasping logic here, ;
41: !such as "DO[1]=ON" ;
42: PAUSE ;
43: !move to departure waypoint ;
44: !of picking ;
45:J PR[62] 50% FINE ;
46: !move to intermediate waypoint ;
47: !of placing ;
48:J P[3] 50% CNT100 ;
49: !move to approach waypoint ;
50: !of placing ;
51:L P[4] 1000mm/sec FINE Tool_Offset,PR[2] ;
52: !move to placing waypoint ;
53:L P[4] 300mm/sec FINE ;
54: !add object releasing logic here, ;
55: !such as "DO[1]=OFF" ;
56: PAUSE ;
57: !move to departure waypoint ;
58: !of placing ;
59:L P[4] 1000mm/sec FINE Tool_Offset,PR[2] ;
60: !move back to robot home position ;
61:J P[1] 100% FINE ;
62: END ;
63: ;
64: LBL[99:vision error] ;
65: !add error handling logic here ;
66: !according to different ;
67: !error codes ;
68: !e.g.: status=2038 means no ;
69: !point cloud in ROI ;
70: PAUSE ;
The workflow corresponding to the above example program code is shown in the figure below.
The table below explains the above program. You can click the hyperlink to the command name to view its detailed description.
Feature | Code and description | ||
---|---|---|---|
Set the reference frame |
The above two statements set the selected user and tool reference frames. |
||
Move to the home position |
The entire statement indicates that the robot moves to the taught home position by using joint position movement.
|
||
Initialize communication parameters |
The entire statement indicates that the robot establishes the connection with the vision system by specifying the IP address, port number, and timeout period of the communication target (the IPC) through the MM_INIT_SKT command.
|
||
Move to the image-capturing position |
The entire command indicates that the robot moves to the image-capturing position in linear motion, with a velocity of 1000 mm/sec.
|
||
Trigger the Mech-Viz project to run |
The entire command indicates that the robot triggers the vision system to run the Mech-Viz project, and then Mech-Viz plans the robot’s picking path base on the vision result output by Mech-Vision. |
||
Obtain the planned path |
The entire statement indicates that the robot obtains the planned path from the Mech-Viz project.
The statement means that when the status code in R[53] is 2100, the robot has successfully obtained the planned path; otherwise, an exception has occurred in the vision system, and the program will jump to LBL[99] and execute the instructions there. The following is the code at LBL[99].
You can perform the corresponding operation based on the specific error code. In this example program, all error codes are handled in the same way, by stopping the program execution using the PAUSE command. |
||
Store the planned path |
The entire command “CALL MM_GET_JPS(1,60,70,80)” stores the joint positions, label, and tool ID of the first waypoint in the specified registers.
|
||
Move to the approach waypoint of picking |
The robot moves to the approach waypoint of picking (the position represented by PR[60]). |
||
Move to the picking waypoint |
The robot moves to the picking waypoint (the position represented by PR[61]). |
||
Set DO to Perform Picking |
After the robot moves to the picking waypoint, you can set a DO command (such as “DO[1]=ON”) to control the robot to use the tool to perform picking. Please set DO commands based on the actual situation.
|
||
Move to the departure waypoint of picking |
The robot moves to the departure waypoint of picking (the position represented by PR[62]). |
||
Move to the intermediate waypoint |
The entire command moves the robot in joint positions to a certain intermediate waypoint between the departure waypoint of picking and the approach waypoint of placing.
|
||
Move the robot to the approach waypoint of placing |
|
||
Move to the placing waypoint |
The robot moves from the approach waypoint of placing to the placing waypoint. |
||
Set DO commands to perform placing |
After the robot moves to the placing waypoint, you can set a DO command (such as “DO[1]=OFF”) to control the robot to use the tool to perform placing. Please set DO commands based on the actual situation.
|
||
Move the robot to the departure waypoint of placing |
The robot moves to a position above the placing waypoint and reaches the departure waypoint of placing.
|
||
Move to the home position |
The robot moves from the departure waypoint of placing to the home position again. |