Sample Program 3: MM_S3_Vis_Path

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-Vision project to run, then obtains the planned path, and then performs the pick operation.

File path

Under the installation directory of Mech-Vision and Mech-Viz: Communication Component/Robot_Interface/EFORT/MM_S3_Vis_Path.

Required project

Mech-Vision 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_S3_Vis_Path 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_Switch_Model(1, 1);
 5. CALL: MM_Status := MM_Start_Vis(1, 0, 1, MM_J);
 6. CALL: MM_Status, MM_LastData, MM_POS_NUM, MM_VisPosNum := MM_Get_VisPath(1, 2);
 7. IF MM_Status <> 1103 THEN
 8.     STOPPROG;
 9. END_IF;
10. CALL: MM_Pose[1], MM_Label[1], MM_Tool[1] := MM_Get_Pose(1);
11. CALL: MM_Pose[2], MM_Label[2], MM_Tool[2] := MM_Get_Pose(2);
12. CALL: MM_Pose[3], MM_Label[3], MM_Tool[3] := MM_Get_Pose(3);
13. CALL: MM_Pose[4], MM_Label[4], MM_Tool[4] := MM_Get_Pose(4);
14. CALL: MM_Pose[5], MM_Label[5], MM_Tool[5] := MM_Get_Pose(5);
15. MJOINT(MM_Pose[1], v500, fine, tool0);
16. MJOINT(MM_Pose[2], v500, fine, tool0);
17. MJOINT(MM_Pose[3], v500, fine, tool0);
18. MJOINT(MM_Pose[4], v500, fine, tool0);
19. MJOINT(MM_Pose[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.

Switch the Mech-Vision parameter recipe

CALL: MM_Status := MM_Switch_Model(1, 1);
  • MM_Switch_Model: Command for switching the Mech-Vision parameter recipe.

  • The first 1: Mech-Vision project ID.

  • The second 1: Parameter recipe ID in the Mech-Vision project.

  • MM_Status: Stores the command execution status code.

Therefore, this command means switching the parameter recipe of Mech-Vision project 1 to recipe 1.

Trigger the Mech-Vision project to run

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

  • 1: Mech-Vision project ID.

  • 0: Expect all path points to be returned by the Mech-Vision project.

  • 1: Pass the robot’s current joint positions and flange pose to the Mech-Vision 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.

  • MM_Status: Stores the command execution status code.

Therefore, this command means that the robot triggers the vision system to run Mech-Vision project 1 and expects all path points to be returned.

Obtain the planned path

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

  • 1: Specifies the Mech-Vision project ID.

  • 2: Specifies that the pose form of path points to obtain is tool pose.

  • 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 Mech-Vision project 1.

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 <> 1103 THEN
    STOPPROG;
END_IF;

When status code MM_Status is 1103, 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_Pose[1], MM_Label[1], MM_Tool[1] := MM_Get_Pose(1);
CALL: MM_Pose[2], MM_Label[2], MM_Tool[2] := MM_Get_Pose(2);
CALL: MM_Pose[3], MM_Label[3], MM_Tool[3] := MM_Get_Pose(3);
CALL: MM_Pose[4], MM_Label[4], MM_Tool[4] := MM_Get_Pose(4);
CALL: MM_Pose[5], MM_Label[5], MM_Tool[5] := MM_Get_Pose(5);
  • MM_Get_Pose: Command for storing the planned path.

  • 1: Store the first path point.

  • MM_Pose[1]: Stores the tool pose 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_Pose[1], MM_Label[1], MM_Tool[1] := MM_Get_Pose(1); means that the tool pose, 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-Vision contains five path points. Store the planned path according to the actual Mech-Vision project.

Move to each planned path point

MJOINT(MM_Pose[1], v500, fine, tool0);
MJOINT(MM_Pose[2], v500, fine, tool0);
MJOINT(MM_Pose[3], v500, fine, tool0);
MJOINT(MM_Pose[4], v500, fine, tool0);
MJOINT(MM_Pose[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.