Example program 2: MM_S2_Viz_Basic

You are currently viewing the documentation for the latest version (2.2.0). To access a different version, click the "Switch version" button located in the upper-right corner of the page.

■ If you are not sure which version of the product you are currently using, please feel free to contact Mech-Mind Technical Support.

Program Introduction

Description

The robot triggers the Mech-Viz 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 Communication Component/Robot_Interface/EFORT/sample/MM_S2_Viz_Basic path.

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. 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 table below explains the above example program. You can click the hyperlink to the command name to view its detailed description.

Feature Code and description

Move to the image-capturing position

MJOINT(POINTC(264.2282,-217.9533,359.1164,-83.989165,1.303953,176.0864,CFG1,0,0,1), v100perc, fine, tool0);
  • MJOINT: A robot joint-motion command that directs the robot’s joints to move along a specified trajectory to the target position.

  • POINTC: Specify the target position to which the robot moves, i.e., the image-capturing position that is taught. The image-capturing position refers to the position of the robot where the camera on the robot captures images. At this position, the robot arm should not block the camera’s FOV.

  • v100perc: Specifies the upper limit of the robot’s motion speed.

  • fine: Specifies the robot’s cornering radius during motion.

  • tool0: The tool used by the robot when it moves.

The entire statement indicates that the robot moves to the taught image-capturing position by using joint position movement.

Initialize communication parameters

MM_Init_Socket(1)

The robot uses the MM_Init_Socket instruction to set the socket number for communication with the IPC.

The user must modify the socket number here according to the actual system configuration.

Establish the communication

CALL: MM_Open_Socket();

The TCP communication between the robot and the vision system is established by using the MM_Open_Socket command.

Set the Exit Port for the Branch by Msg Step in Mech-Viz

CALL: MM_Status := MM_Set_Branch(1, 1);
  • MM_Set_Branch: The command to set the exit port for the Branch by Msg Step in Mech-Viz.

  • First 1: The Step ID of the Branch by Msg Step.

  • Second 1: The Mech-Viz project takes exit port 0 of the Branch by Msg Step. Note that if this parameter is set to N, the exit port is N-1.

  • status: The variable that stores the command execution status code.

In the entire statement, the Mech-Viz project with an ID of 1 takes the port 0 of the Branch by Msg Step, as shown in the following figure.

set branch

Trigger the Mech-Viz project to run

CALL: MM_Status := MM_Start_Viz(1, MM_J);
  • MM_Start_Viz: The command to trigger the Mech-Viz project to run.

  • Robot sends its current joint positions and flange pose to the Mech-Viz project.

  • MM_J: Custom joint positions. The joint positions in this example program are of no practical use but must be set.

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.

Get the planned path

CALL: MM_Status, MM_LastData, MM_POS_NUM, MM_VisPosNum := MM_Get_VizData(1);
  • MM_Get_VizData: The command to obtain the path planned by Mech-Viz.

  • 1: Specify the pose type of obtained waypoints as joint positions.

  • status: The variable that stores the command execution status code.

  • MM_LastData: Indicates whether all vision points have been acquired.

  • MM_POS_NUM: The variable that stores the number of waypoints returned by the vision system.

  • MM_VisPosNum: The variable that stores the sequence number of the Vision Move waypoint (picking waypoint) in the path.

The entire statement indicates that the robot obtains the planned path from the Mech-Viz project.

The returned planned path is saved to the robot memory and cannot be directly obtained. To access the planned path, you must store the planned path in a subsequent step.
IF MM_Status <> 2100 THEN
	STOPPROG;
END_IF;

When the status code MM_Status is 2100, the robot has successfully obtained the planned path. Otherwise, an error has occurred in the vision system. You can perform the corresponding operation based on the specific error code.

Store the planned path

CALL: MM_JPS[1], MM_Label[1], MM_Tool[1] := MM_GET_JPS(1);
CALL: MM_JPS[2], MM_Label[2], MM_Tool[2] := MM_GET_JPS(2);
CALL: MM_JPS[3], MM_Label[3], MM_Tool[3] := MM_GET_JPS(3);
CALL: MM_JPS[4], MM_Label[4], MM_Tool[4] := MM_GET_JPS(4);
CALL: MM_JPS[5], MM_Label[5], MM_Tool[5] := MM_GET_JPS(5);
  • MM_GET_JPS: The command to store the planned path.

  • 1: Store the first waypoint.

  • MM_JPS[1]: The variable that stores the joint positions of the first waypoint.

  • MM_Label[1]: The variable that stores the label corresponding to the first vision point.

  • MM_Tool[1]: The variable that stores the tool ID corresponding to the first vision point.

The entire command “CALL: MM_JPS[1], MM_Label[1], MM_Tool[1] := MM_GET_JPS(1);” stores the joint positions, label, and tool ID of the first waypoint in the specified variables.

This sample assumes that the path planned by Mech-Viz contains five waypoints. Please store the planned path based on the actual Mech-Viz project.

Move to each waypoint in the planned path

MJOINT(MM_JPS[1], v500, fine, tool0);
MJOINT(MM_JPS[2], v500, fine, tool0);
MJOINT(MM_JPS[3], v500, fine, tool0);
MJOINT(MM_JPS[4], v500, fine, tool0);
MJOINT(MM_JPS[5], v500, fine, tool0);

The robot sequentially moves to each waypoint using joint position movement.

Close the communication

CALL: MM_Close_Socket();

The TCP communication between the robot and the vision system is closed by using the MM_Close_Socket command.

Is this page helpful?

You can give a feedback in any of the following ways:

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.