Sample Program 1: MM_S1_Vis_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-Vision project to run, then obtains vision results, and then performs the pick operation.

File path

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

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_S1_Vis_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_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_Get_VisData(1);
 7. IF MM_Status <> 1100 THEN
 8.     STOPPROG;
 9. END_IF;
10. CALL: MM_Pose[1], MM_Label[1], MM_Tool[1] := MM_Get_Pose(1);
11. MM_Pre := MM_Pose[1];
12. MM_Pre.z := MM_Pose[1].z+100;
13. MLIN(MM_Pre, v500, fine, tool0);
14. MLIN(MM_Pose[1], v500, fine, tool0);
15. MLIN(MM_Pre, v500, fine, tool0);
16. 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. The capture point is where the robot is located when the camera acquires images. At this position, the robot arm should not block the camera view.

  • 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 vision 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 vision points to be returned.

Obtain vision results

CALL: MM_Status, MM_LastData, MM_POS_NUM := MM_Get_VisData(1);
  • MM_Get_VisData: Command for obtaining vision results.

  • 1: Mech-Vision project ID.

  • MM_Status: Stores the command execution status code.

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

  • MM_POS_NUM: Stores the number of obtained vision points.

Therefore, this command means that the robot obtains the vision result returned by Mech-Vision project 1.

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

When status code MM_Status is 1100, the robot has successfully obtained all vision results; otherwise, an exception has occurred in the vision system. Handle different exceptions according to the actual status code.

Store the vision result

CALL: MM_Pose[1], MM_Label[1], MM_Tool[1] := MM_Get_Pose(1);
  • MM_Get_Pose: Command for storing the vision result.

  • 1: Store the first vision point.

  • MM_Pose[1]: Stores the tool pose of the first vision point, that is, the tool pose of the pick point.

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

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

Therefore, this command means that the tool pose, label, and end-tool ID of the first vision point are stored in the specified variables respectively.

Move to the pick approach point

MM_Pre := MM_Pose[1];
MM_Pre.z := MM_Pose[1].z+100;
MLIN(MM_Pre, v500, fine, tool0);
  • MM_Pre := MM_Pose[1]: Assign the pose of the pick point (MM_Pose[1]) to variable MM_Pre.

  • MM_Pre.z := MM_Pose[1].z+100: Increase the Z-axis coordinate of MM_Pre by 100 mm, that is, assign the pose 100 mm above the pick point to MM_Pre.

  • MLIN(MM_Pre, v500, fine, tool0): Linear movement command of the robot, indicating that the robot moves linearly to the position specified by MM_Pre.

Therefore, the preceding code means that the robot moves linearly to a point 100 mm above the pick point.

Adding a pick approach point can prevent collision between the robot and scene objects such as bins during movement. Modify the Z-axis offset according to the actual scenario to ensure collision-free approach.

Move to the pick point

MLIN(MM_Pose[1], v500, fine, tool0);

The robot moves linearly from the pick approach point to the pick point.

Move to the pick departure point

MLIN(MM_Pre, v500, fine, tool0);

The robot moves to a point 100 mm above the pick point, that is, reaches the pick departure point.

Adding a pick departure point can prevent collision between the robot and scene objects such as bins during movement. Modify the Z-axis offset according to the actual scenario to ensure collision-free departure.

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.