Example Program 1: MM_S1_Vis_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-Vision project to run, and then obtains the vision result for picking and placing the object.

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/MM_S1_Vis_Basic path.

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_S1_Vis_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_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 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.

Switch Mech-Vision Parameter Recipe

CALL: MM_Status := MM_Switch_Model(1, 1);
  • MM_Switch_Model: The command to switch the Mech-Vision parameter recipe.

  • First 1: The Mech-Vision project ID.

  • Second1: The ID of the parameter recipe in the Mech-Vision project.

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

In this entire statement, the parameter recipe of the Mech-Vision project whose ID is 1 is switched to recipe 1.

Trigger the Mech-Vision project to run

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

  • 1: The Mech-Vision project ID.

  • 0: The Mech-Vision project is expected to return all vision points.

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

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

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

The entire statement indicates that the robot triggers the vision system to run the Mech-Vision project with an ID of 1 and expects the Mech-Vision project to return all vision points.

Get the vision result

CALL: MM_Status, MM_LastData, MM_POS_NUM := MM_Get_VisData(1);
  • MM_Get_VisData: The command to obtain the vision result.

  • 1: The Mech-Vision project ID.

  • 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 received vision points.

The entire statement indicates that the robot obtains the vision result from the Mech-Vision project with an ID of 1.

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

When the status code is 1100, the robot has successfully obtained all vision result. Otherwise, an error has occurred in the vision system. You can perform the corresponding operation based on the specific error code.

Store the vision result

CALL: MM_Pose[1], MM_Label[1], MM_Tool[1] := MM_Get_Pose(1);
  • MM_Get_Pose: The command to store the vision result.

  • 1: The first vision point is stored.

  • MM_Pose[1]: Stores the TCP pose of the first vision point, which is the TCP pose of the picking point.

  • 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 statement stores the TCP, label, and tool ID of the first vision point in the specified variables.

Move to the approach waypoint of picking

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

  • MM_Pre.z := MM_Pose[1].z + 100: Increases the Z coordinate of MM_Pre by 100 mm, i.e., assigns to MM_Pre the pose located 100 mm above the picking waypoint.

  • MLIN(MM_Pre, v500, fine, tool0): A robot linear-motion command that moves the robot in a straight line to the position specified by MM_Pre.

The entire statement indicates that the robot moves linearly to 100 mm above the picking waypoint.

Adding approach waypoints of picking can prevent the robot from colliding with objects (such as bins) in the scene when moving. You can modify the Z-axis negative offset based on the actual scenario to ensure that no collision occurs during the approaching process.

Move to the picking waypoint

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

The robot moves from the approach waypoint of picking to the picking waypoint linearly.

Move to the departure waypoint of picking

MLIN(MM_Pre, v500, fine, tool0);

The robot moves to 100 mm above the picking waypoint and reaches the departure waypoint of picking.

Adding departure waypoints of picking can prevent the robot from colliding with objects (such as bins) in the scene when moving. You can modify the Z-axis negative offset based on the actual scenario to ensure that no collision occurs during the departing process.

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.