Sample Program 2: Get the Path Planned by Mech-Viz

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

Required project

Mech-Vision project and Mech-Viz 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-Viz project to run

mm_start_viz

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

  • Current Position: Pass the current joint positions and flange pose of the robot into the Mech-Viz 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 the Mech-Viz project. Then Mech-Viz plans the robot picking path based on the vision result output by Mech-Vision.

Obtain the planned path and move to each path point

mm_get_data

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

  • From Viz: Obtain data from Mech-Viz.

  • mm_get_viz_data: Obtain the planned path.

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

  • pose_num: Variable that stores the number of path points returned by the vision system.

  • ss: Variable that stores the position index of the Vision Move path point (pick point) in the path.

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

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 time. You must use the subsequent Transfer planned path operation to access it.

Transfer the planned path

If g_mm_status==2100

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

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 path point. The initial value is 1.

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

  • i_pose1: Used to store the joint-position data of a path point. The initial value is {}.

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

    • mm_get_jps: Transfers the joint positions, label, and end-tool ID of a path point to specified variables.

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

    • i_pose1: Stores the joint positions of the `aaa`th path point.

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

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

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

  • MoveJ i_pose1: The robot moves to the path point in joint motion.

  • Variable ss indicates the position index of the Vision Move path point in the path. Therefore, the `ss`th path point in the path is the pick point.

  • 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.