Example Program 3: MM_S3_Vis_Path
Program Introduction
Description |
The robot triggers the Mech-Vision project to run, and then obtains the planned path for picking and placing. |
||
File Name |
You can navigate to the installation directory of Mech-Vision and Mech-Viz and find the file by using the |
||
Project |
Mech-Vision project
|
||
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_S3_Vis_Path example program.
— This is a LUA program.
require("MM_Module")
IP_Address = "192.168.1.8"
Server_Port = 50000
Time_Out = 60
--initialize communication parameters (initialization is required only once)
MM_Init_Socket(IP_Address,Server_Port,Time_Out)
--close socket connection
MM_Close_Socket()
--open socket connection
MM_Open_Socket()
--switch recipe of NO.1 Mech-Vision project
TOP_Status=MM_Switch_Model(1,1)
print("Vision system status code:",TOP_Status)
--check whether the recipe is switched successfuly
if TOP_Status ~= 1107 then
print("Abnormal vision system status!!!",TOP_Status)
Pause()
end
TOP_Status = MM_Start_Vis(1,0,1,JP[100])
print("Vision system status code:",TOP_Status)
--Status code judgment
if TOP_Status ~= 1102 then
print("Abnormal vision system status!!!",TOP_Status)
Pause()
end
--get planned path from NO.1 Mech-Vision project
TOP_Status,TOP_Last_Data,TOP_Pos_Num,TOP_VisPosNum = MM_Get_VisPath(1,1)
print("Planned path from Mech-Vision:",TOP_Status,TOP_Last_Data,TOP_Pos_Num,TOP_VisPosNum)
--check whether planned path has been got from Mech-Vision successfully
if TOP_Status ~= 1103 then
print("Abnormal vision system status!!!",TOP_Status)
Pause()
end
--save waypoints of the planned path to local variables one by one
MM_Get_JPR(1,10,20,30)
MM_Get_JPR(2,11,21,31)
MM_Get_JPR(3,12,22,32)
--move to approach waypoint of picking
MovJ(JPR[10],{cnt = -1})
--move to picking waypoint
MovJ(JPR[11],{cnt = -1})
--add object grasping logic here, such as
Pause()
--move to departure waypoint of picking
MovJ(JPR[12],{cnt = -1})
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 | ||
|---|---|---|---|
Include the MM_Module header file |
|
||
Initialize communication parameters |
Close the communication first, then reconnect to ensure no project is currently connected. |
||
Switch Mech-Vision Parameter Recipe |
|
||
Print the status code and verify |
|
||
Trigger the Mech-Vision project to run |
|
||
Print the status code and verify |
|
||
Obtain the planned path from Mech-Vision |
The entire statement indicates that the robot obtains the planned path from the Mech-Vision project that has an ID of 1. |
||
Print the vision results and verify |
|
||
Store the planned path |
This instruction writes the tool pose, label, and end-effector tool number of the first vision point into the specified registers, respectively. |
||
Move to the approach waypoint of picking |
|
||
Move to the picking waypoint |
The robot moves to the approach waypoint of picking. |
||
Set DO commands to perform picking |
After the robot moves to the picking waypoint, you can set a DO command (such as setdo DO_1, 1;) to control the robot to use the tool to perform picking. Please set DO commands based on the actual situation.
|
||
Move the robot to the approach waypoint of placing |
The robot moves to position above the picking waypoint and reaches the departure waypoint of picking.
|