Sample Program 1: Get Mech-Vision Vision Result

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, obtains the vision result, and then performs picking.

Required project

Mech-Vision project

Prerequisites

  1. Standard-interface communication has been configured.

  2. Automatic calibration has been completed.

This sample program is only an example. Modify it according to the actual situation. Do not use it directly.

Program Explanation

The following is a sample program for reference only.

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

Initialize communication parameters

mm_init_socket

mm_init_socket: command for initializing communication. Its parameters are shown below.

  • 192.168.10.182: IP address of the IPC.

  • 50000: Port number of the IPC.

Therefore, this command means that the robot uses mm_init_socket to specify the IP address and port number of the communication target (the IPC).

Modify the IPC IP address and port number here according to the actual situation, and make sure they are consistent with the parameters configured in the vision system.

Move to the image-capturing point

MoveJ
	path_0
  • MoveJ: Joint-motion command of the robot, indicating that the robot moves along an arc to the specified position.

  • path_0: The target position of robot movement, namely the taught camera image-capturing point. The image-capturing point is the position where the robot is located when the camera acquires images. At this position, the robot arm should not block the camera view.

You need to teach the image-capturing point. For the specific teaching method, refer to Teach the calibration starting point in the automatic-calibration section.

Establish communication

mm_open_socket

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

Trigger the Mech-Vision project to run

mm_start_vision

mm_start_vision: command for triggering the Mech-Vision project to run. Its parameters are shown below.

  • 2: ID of the Mech-Vision project.

  • 0: Expect the Mech-Vision project to return all vision points.

  • Current Position: Pass the current joint positions and flange pose of the robot into the Mech-Vision project.

  • 90,90,90,90,90,90: Because the previous parameter is Current Position, these joint values have no practical effect here and do not need to be modified.

Therefore, this command means that the robot triggers the vision system to run Mech-Vision project 2 and expects the project to return all vision points.

Obtain vision results

mm_get_data

mm_get_data: command for obtaining data. Its parameters are shown below.

  • From Vision: Obtain data from Mech-Vision.

  • mm_get_vis_data: Obtain the vision result.

  • 2: ID of the Mech-Vision project.

  • pose_num: Variable that stores the number of obtained vision points.

  • g_mm_status (global variable): Variable that stores the command execution status code.

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

Since the returned vision result is stored in robot memory, you cannot access it directly at this time. You must use the subsequent Transfer vision result operation to access it.

Transfer the vision result and move to the pick point

If g_mm_status==1100

When status code g_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.

aaa:=1
loop_0 aaa<=pose_num
	i_pose1:={}
    mm_get_posjps
	MoveJ
		i_pose1
	aaa:=aaa+1
  • aaa: Used to control the number of loop iterations and specify the index of a vision point. The initial value is 1.

  • loop_0 aaa<=pose_num: Obtains vision-point data one by one through a loop and moves to the corresponding position.

  • i_pose1: Used to store the pose data of a vision point. The initial value is {}.

  • mm_get_posjps: command for transferring data. Its parameters are shown below.

    • mm_get_pos: Transfers the tool pose, label, and end-tool ID of a vision point to specified variables.

    • aaa: Specifies the index of the vision point to transfer. For example, if aaa is 1, the data of the first vision point is transferred.

    • i_pose1: Stores the tool pose of the `aaa`th vision point, namely the tool pose of the pick point.

    • l1: Stores the end-tool ID corresponding to the `aaa`th vision point.

    • s1: Stores the label corresponding to the `aaa`th vision point.

    Therefore, this command means that the tool pose, label, and end-tool ID of the `aaa`th vision point are transferred to the specified variables respectively.

  • MoveJ i_pose1: The robot moves to the pick point (vision point) in joint motion.

    • After the robot moves to the pick point, you can add DO-setting operations according to the actual scenario to control the end tool for picking.

    • According to the actual scenario, you can add multiple transition points before and after picking to ensure smooth robot motion and avoid unnecessary collisions.

Close communication

mm_close_socket

The robot uses mm_close_socket to disconnect the TCP communication connection with 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.