Sample Program 2: MM_S2_Viz_Basic

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

■ If you're unsure about the version of the product you are using, please contact Mech-Mind Technical Support for assistance.

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: Communication Component/Robot_Interface/EFORT/MM_S2_Viz_Basic.

Required project

Mech-Vision project and Mech-Viz project

Prerequisites

  1. Standard interface communication has been configured in EFORT Standard Interface Communication Configuration.

  2. Automatic calibration has been completed in EFORT Automatic Calibration.

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

MJOINT(POINTC(264.2282,-217.9533,359.1164,-83.989165,1.303953,176.0864,CFG1,0,0,1), v100perc, fine, tool0);
  • MJOINT: Joint movement command of the robot, indicating that the robot joints move along the specified path to the target position.

  • POINTC: Specifies the target position of robot movement, that is, the camera capture point.

  • v100perc: Specifies the upper limit of robot movement speed.

  • fine: Specifies the turning radius of robot movement.

  • tool0: End tool used by the robot during movement.

Therefore, this command means that the robot accurately moves to the capture point in joint motion.

Initialize communication parameters

MM_Init_Socket(1)

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

Modify the socket number here according to the actual situation.

Establish communication

CALL: MM_Open_Socket();

The robot uses MM_Open_Socket to establish a TCP communication connection with the vision system.

Set the message-branch exit of Mech-Viz

CALL: MM_Status := MM_Set_Branch(1, 1);
  • MM_Set_Branch: Command for setting the exit of a Mech-Viz message branch.

  • The first 1: Step ID of the message branch.

  • The second 1: The Mech-Viz project continues from exit 0 of the Message Branch Step. Note that if this parameter is set to N, the actual exit is N-1.

  • MM_Status: Stores the command execution status code.

Therefore, this command means that at message branch step 1, the Mech-Viz project continues from exit 0, as shown below.

set branch

Trigger the Mech-Viz project to run

CALL: MM_Status := MM_Start_Viz(1, MM_J);
  • MM_Start_Viz: Command for triggering the Mech-Viz project to run.

  • 1: Pass the robot’s current joint positions and flange pose to the Mech-Viz project.

  • MM_J: User-defined joint-position data. In this sample, this joint-position data has no practical use, but it must still be set.

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

CALL: MM_Status, MM_LastData, MM_POS_NUM, MM_VisPosNum := MM_Get_VizData(1);
  • MM_Get_VizData: Command for obtaining the path planned by Mech-Viz.

  • 1: Specifies that the pose form of path points to obtain is joint positions.

  • MM_Status: Stores the command execution status code.

  • MM_LastData: Indicates whether all path points have been obtained.

  • MM_POS_NUM: Stores the number of path points returned by the vision system.

  • MM_VisPosNum: Stores the position index of the Vision Move waypoint (pick point) in the path.

Therefore, this command means that the robot obtains the planned path returned by the Mech-Viz project.

Since the returned planned path is stored in robot memory, you cannot access it directly at this moment. You must use the subsequent "Store planned path" operation to access it.
IF MM_Status <> 2100 THEN
	STOPPROG;
END_IF;

When status code MM_Status is 2100, the robot has successfully obtained the planned path; otherwise, an exception has occurred in the vision system. Handle different exceptions according to the actual status 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: Command for storing the planned path.

  • 1: Store the first path point.

  • MM_JPS[1]: Stores the joint positions of the first path point.

  • MM_Label[1]: Stores the label corresponding to the first path point.

  • MM_Tool[1]: Stores the end-tool ID corresponding to the first path point.

Therefore, CALL: MM_JPS[1], MM_Label[1], MM_Tool[1] := MM_GET_JPS(1); means that the joint positions, label, and end-tool ID of the first path point are stored in the specified variables respectively.

This sample assumes that the path planned by Mech-Viz contains five path points. Store the planned path according to the actual Mech-Viz project.

Move to each planned path point

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 moves to each path point in sequence by joint motion.

Close communication

CALL: MM_Close_Socket();

The robot uses MM_Close_Socket to disconnect the TCP communication connection from the vision system.

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.