Integration Guide Kawasaki

Note: It is strongly recommended to read the Robot communication overview prior to this integration guide.

Contents

1 Prerequisites

The Robot module is compatible with all E-series & F-series robot controllers.

2 Robot controller setup

2.1 Controller configuration

2.1.1 Network configuration

Turn on the robot controller, wait for the system to boot, open the Menu screen and select the Aux Function option:
image1
In the Aux function menu select System and Network Settings:
image2
The robot controller has two Ethernet ports. We will use Port 1 for communication with Photoneo Bin Picking Studio, while Port 2 will be utilized for transferring programs between PC and Robot controller using KRTerm.
Configure Port 1 to meet your network requirements and ensure that both the robot controller and the vision controller which will run Photoneo Bin Picking Studio are on the same subnet.
image3
Configure Port 2 for transferring programs between PC and robot controller. Click Next Page, configure the network settings and confirm by clicking the Enter button.
image4
Restart the robot controller to apply the network settings.

2.1.2 Changing the cartesian origin of the robot

Photoneo Bin Picking Studio requires the origin of the robot to be defined at the very bottom of the robot.

In Kawasaki robots, the default origin position is in the axis of the second joint, so therefore we need to redefine its position and shift it vertically down in the Z-axis.

Browse to Menu **-> **Aux Functions -> Advanced Settings -> Base Coordinates
image5
Set the Z coordinate value according to the offset table in this documentation page.

Warning: Changes to the Base Coordinates might affect your previously taught positions!

2.2 Robot module installation

2.2.1 Loading the Robot module files

The Robot module consists of two core .pg files:

- photoneo_common.pg

- customer_definitions.pg

Besides that Photoneo provides three example bin picking programs and a semi-automatic calibration example program located in folder example_programs:

- basic_application.pg

  • multiple_vision_systems.pg

- change_solution.pg

- calibration.pg

The core files (and optionally the example program you wish to use) need to be transferred to the robot controller to get the Robot module up and running.

You can copy the .pg files to the robot controller directly from the USB stick using the Pendant, however, the most convenient method of installation is to use the KRTerm tool (download_1, download_2).

Make sure that Port 2 is configured for communication with your PC and that both devices are connected to the same subnet (you must be able to ping the robot controller from the command line).

Open KRTerm and select COM -> Options to add a new robot controller:
image6
Input the IP address of Port 2 as configured in the pendant in the previous step and click the Add button:
image7
Click File -> Set Current Folder and set the path to the folder where you saved the extracted .pg files
image8
You are now ready to connect to the robot. Make sure that you are able to ping the robot controller from your PC and click on the Connect button.
If the connection has been established properly you should see the login prompt shown in the figure below:
image9
The login name is as. If login has succeeded you should be able to issue commands directly to the robot controller.
In order to load .pg files to the robot controller enter the LOAD command as is shown in the figure below:
image10
Use the LOAD command to upload all .pg files of the Robot module.
image11
Make sure all files are loaded successfully.

2.1.2 Enabling the autostart of the Robot state server

The Robot module consists of two tasks - the Action Request Client task and the Robot State Server.

While the Action Request Client is Cycle Started as a normal robotic program, the Robot State Server runs in the background from the boot.

In order to enable the Robot State Server to run properly from the first boot, it is necessary to enable the AUTOSTART.PC system switch.

On the pendant click Menu -> Aux Functions -> Advanced Settings -> System Switch
image12
Turning AUTOSTART.PC to ON enables State Server to start properly even on the first boot.
image13
Restart the robot controller to apply the autostart settings.
Note: Before proceeding further, please ensure that the Robot State Server is running - PC window on the pendant is not empty - AUTOSTART program pointer should be visible here.
image14
At this point, the robot controller is configured to work with Bin Picking Studio.

3 Robot module

The Robot module is designed to be easily integrated into existing applications written in AS language.

3.1 Robotic API

Note: It is strongly recommended to read the Photoneo robotic API prior to this section.

This section describes available API calls provided by the Robot module. These procedures are intended for high-level control of the bin picking application.

3.1.1 Connection procedures

Warning: These procedures are contained in the photoneo_common.pg API section and must not be edited!

Connection procedure

Description / Usage

Connect to Action Request Server

connect_to_vc
(
.ret_val_conn
)
Description
Function to establish a new connection to the Action Request Server.

Input parameters:

.ret_val_conn- result of the connection operation

vc_ip - an array of 4 values defining the IP of the Action Request Server (Robot interface), values must be on indices 1-4 [global variable - define it in the main program before calling the procedure]

bp_port - port on which the Action Request Server is running, it is recommended to use value 11 003 [global variable - define it in the main program before calling the procedure]

tout_open - timeout for a single connection attempt, default = 60 seconds [global variable - defined in the procedure init_consts (adjust if needed)]

connect_att - number of total connection attempts before a communication error is returned, default = 5 attempts [global variable - defined in the procedure init_consts, set to -1 for infinite connection attempts (adjust according to your needs)]

Usage
The procedure should be called only once at the beginning of the program. Only after the connection has been established it is possible to send requests.
bp_port = 11003
vc_ip[1] = 192
vc_ip[2] = 168
vc_ip[3] = 0
vc_ip[4] = 80
CALL connect_to_vc (ret_val)

Close TCP socket

close_socket
(
)
Description
Closes the open TCP socket.
Usage
Normally, it is not necessary to call this procedure as it is called automatically from the procedure Connect to Action Request Server if the socket is already open - reconnection is performed.
However, in some cases, it might happen the socket connection status variable does not report the correct status and the procedure Connect to Action Request Server fails (more specifically, its subprocedure open_socket. Then this procedure (Close TCP socket) is used to close the TCP socket left open.

3.1.2 Communication procedures

Note: Please read Action requests for detailed documentation of these procedures.

Warning: These procedures are contained in the photoneo_common.pg API section and must not be edited!

vision_system_i - global variable. Bin picking requests (except for the Change scene state request) require the vision system ID as an input parameter. It needs to be set to the correct value (ID of the vision system) before sending the request

.ret_val_X - procedure parameter. It stores the result of the procedure call.

Bin picking requests

Request

Input variables

Output variables

Initialization request

initialize_req
(
.ret_val_init,
.#start_pose,
.#end_pose
)

vision_system_i - vision system ID [global variable]

.#start_pose - start joint pose

.#end_pose - end joint pose

Note: The pose variable is defined by a set of joint displacement values.

The error code is accessible in two ways:

  • .ret_val_init - error code

  • error_msg - error code [global variable]

Initialization request [deprecated]

init_req
(
.ret_val_init,
.$start_pose,
.$end_pose
)

vision_system_i - vision system ID [global variable]

.$start_pose- start joint pose

.$end_pose - end joint pose

Note: The string pose array is created from a taught pose defined by a set of joint displacement values by the following commands (the taught pose in this example is called #pho_start).

DECOMPOSE .pho_start[0] = #pho_start
.$S = " "
.$start_pose = $ENCODE(.pho_start[0], .$S, .pho_start[1], .$S, .pho_start[2], .$S, .pho_start[3], .$S, .pho_start[4], .$S, .pho_start[5], .$S)

The error code is accessible in two ways:

  • .ret_val_init - error code

  • error_msg - error code [global variable]

Scan request

scan_req
(
.ret_val_scan
)

vision_system_i - vision system ID [global variable]

The result is accessible in two ways:

  • .ret_val_scan - result of request sending operation

  • error_msg - result of request sending operation [global variable]

Note: The response is received by the procedure Wait for scan completion.

Trajectory request

traj_req
(
.ret_val_traj
)

vision_system_i - vision system ID [global variable]

The result is accessible in two ways:

  • .ret_val_traj - result of request sending operation

  • error_msg - result of request sending operation [global variable]

Note: The response is received by the procedure Receive trajectory.

Pick-failed request

pick_failed_req
(
.ret_val_fail
)

vision_system_i - vision system ID [global variable]

The error code is accessible in two ways:

  • .ret_val_fail - error code

  • error_msg - error code [global variable]

Change scene state request

env_change_req
(
.ret_val_env,
.env_id
)

.env_id - scene state ID

The error code is accessible in two ways:

  • .ret_val_env - error code

  • error_msg - error code [global variable]

Calibration requests

Request

Input variables

Output variables

Add calibration point request

calib_add_req
(
.ret_val_add
)

—

The error code is accessible in two ways:

  • .ret_val_add - error code

  • error_msg - error code [global variable]

Solution requests

Request

Input variables

Output variables

Change solution request

change_sol_req
(
.ret_val_sol,
.solution_id
)

.solution_id - solution ID

The error code is accessible in two ways:

  • .ret_val_sol - error code

  • error_msg - error code [global variable]

Start solution request

start_sol_req
(
.ret_val_sol,
.solution_id
)

.solution_id - solution ID

The error code is accessible in two ways:

  • .ret_val_sol - error code

  • error_msg - error code [global variable]

Stop solution request

stop_sol_req
(
.ret_val_sol
)

—

The error code is accessible in two ways:

  • .ret_val_sol - error code

  • error_msg - error code [global variable]

Get running solution request

get_run_sol_req
(
.ret_val_sol
)

—

The error code is accessible in two ways:

  • .ret_val_sol - error code

  • error_msg - error code [global variable]

running_sol_id - solution ID [global variable]

Get available solutions request

avail_sols_req
(
.ret_val_sol
)

—

The error code is accessible in two ways:

  • .ret_val_sol - error code

  • error_msg - error code [global variable]

avail_sol_count - total count of available solutions [global variable]

available_sols - an array of available solution IDs, the first ID is at index 1, the last at index avail_sol_count [global variable]

Response receiving procedures

Response receiving procedures

Input variables

Output variables

Wait for scan completion

wait_for_scan
(
.ret_val_wait
)

—

The error code is accessible in two ways:

  • .ret_val_wait - error code

  • error_msg - error code [global variable]

Receive trajectory

traj_recv
(
.ret_val_traj
)

—

The error code is accessible in two ways:

  • .ret_val_traj - error code

  • error_msg - error code [global variable]

tp_invariance - tool point invariance [global variable]

gp_id - gripping point ID [global variable]

gp_invariance - gripping point invariance [global variable]

3.1.3 Bin picking procedures

Note: These procedures are contained in the customer_definitions.pg API section and should be implemented (edited) by the user according to his requirements.

Bin picking procedure

Description / Usage

Gripper attach

grip_attach
(
)
Description
A user-defined procedure. Typically it is the attach procedure used when the picked object is grasped in the Grasp waypoint.
Usage
It is automatically executed when the waypoint of the grasping method is configured to execute the Attach procedure when it is reached.

Gripper detach

grip_detach
(
)
Description
A user-defined procedure. Typically it is the detach procedure used when the picked object is placed during the placing routine defined by the robot operator.
Usage
It is automatically executed when the waypoint of the grasping method is configured to execute the Detach procedure when it is reached.

Note: Typically this procedure is not configured to be executed automatically in a waypoint as it should be called during placing which is implemented by the robot operator.

Gripper user-defined 1

grip_user_def_1
(
)
Description
A user-defined procedure.
Usage
It is automatically executed when the waypoint of the grasping method is configured to execute the User 1 procedure when it is reached.

Gripper user-defined 2

grip_user_def_2
(
)
Description
A user-defined procedure.
Usage
It is automatically executed when the waypoint of the grasping method is configured to execute the User 2 procedure when it is reached.

Gripper user-defined 3

grip_user_def_3
(
)
Description
A user-defined procedure.
Usage
It is automatically executed when the waypoint of the grasping method is configured to execute the User 3 procedure when it is reached.

Execute bin picking routine

pick_part
(
)
Description
Pre-defined procedure for execution of the bin picking routine. This procedure must not be edited directly - to adapt the execution settings please read Bin picking routine execution settings.
Usage
It should be executed after the bin picking trajectory has been received. The robot must be in the start pose when the procedure is executed. At the end of the procedure, the robot will be in the end pose with the picked object attached to the gripper.

Warning: When using multiple start poses (different for multiple vision systems) be extra careful to be in the correct one before executing this procedure.

Trajectory X configuration

traj_X_params
(
)
Description
Pre-defined procedure for configuration of the parameters (ACCEL, DECEL, SPEED, etc.) of the Xth trajectory segment of the bin picking routine.
Usage
It is automatically called before the Xth trajectory segment of the bin picking routine is executed.

Note: Go to Bin picking routine execution settings to read more about bin picking routine configuration.

3.1.4 Auxiliary procedures

Warning: These procedures are contained in the photoneo_common.pg API section and must not be edited!

Auxiliary procedure

Description / Usage

Robot State Server restart

ss_check
(
)
Description
Starts/restarts the autostart.pc task - the Robot State Server.
Usage
Whenever it is needed to restart/start again the Robot State Server.

3.2 Example programs

The following section contains basic example programs. Each program is intended for a specific bin picking application and it shows the correct usage of the robotic API.

These templates also contain demonstrative error handling. Please note that it serves only as an example and it is up to the user to define suitable routines for dealing with error situations.

3.2.1 Basic bin picking example

This program is a very basic example of a simple bin picking application. It connects to the vision controller, initializes one vision system, and in a loop, it requests scan, trajectory and executes the received trajectory.

Name: basic_application.pg (located in folder example_programs)

.PROGRAM main_basic ()
  ; *******************************************************************
  ;
  ; Program:      main_basic
  ; Comment:      Main function template with single vision system
  ; Author:       Photoneo s.r.o.
  ;
  ; Date:         30/6/2021
  ;
  ; *******************************************************************
  ;
  ;// Enable State Server to start on boot
  autostart.pc ON
  ;// Amend the Network settings (the IP address, changing the default port to a custom one requires setting the port in BPS network settings)
  bp_port = 11003
  vc_ip[1] = 192
  vc_ip[2] = 168
  vc_ip[3] = 0
  vc_ip[4] = 80
  ;// Connect to the Vision Controller
  CALL connect_to_vc (ret_val)
  ;// Check return value, abort in case of failure
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// Set Vision System ID
  vision_system_i = 1
  ;// Initialize the vision system with start/end bin picking poses
  CALL initialize_req (ret_val, #pho_start, #pho_end)
  ;// Check return value, abort in case of failure
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// Call gripper detach procedure
  CALL grip_detach
  ;// Set speed
  SPEED 10 ALWAYS
  ;// Move to Home pose in which the robot does not occlude the scanning area
  JMOVE #pho_home
  BREAK
  ;// Request the first scan, localization and path planning
  CALL scan_req (ret_val)
  ;// Check return value, abort in case of failure
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// Initial wait to enable the system to calculate trajectories
  TWAIT 10
  ;// MAIN LOOP
  WHILE (TRUE) DO
main_start:
    ;// Receive response from the scan request
    CALL wait_for_scan (ret_val)
    ;// Check return value, abort in case of failure
    IF (ret_val <> ok) THEN
      GOTO quit
    END
    ;// Request a trajectory
    CALL traj_req (ret_val)
    ;// Check return value, abort in case of failure
    IF (ret_val <> ok) THEN
      GOTO quit
    END
    ;// Receive response from the trajectory request
    CALL traj_recv (ret_val)
    ;// If the trajectory request was unsuccessful and
    ;// error PATH PLANNING FAILED or NO PART FOUND occurred
    IF (ret_val == planning_failed) OR (ret_val == no_part_found) THEN
      ;// Move back to Home pose
      JMOVE #pho_home
      BREAK
      ;// Request a new scan, localization and path planning
      CALL scan_req (ret_val)
      ;// Check return value, abort in case of failure
      IF (ret_val <> ok) THEN
        GOTO quit
      END
      ;// Go to the beginning of the MAIN LOOP
      GOTO main_start
    END
    ;// If the request was unsuccessful and other error occurred, abort
    IF (ret_val <> ok) THEN
      GOTO quit
    END
    ;// Move to the bin picking start pose
    JMOVE #pho_start
    ;// Execute bin picking routine
    CALL pick_part
    ;// Move back to Home pose
    JMOVE #pho_home
    BREAK
    ;// Request a new scan, localization and path planning
    CALL scan_req (ret_val)
    ;// Check return value, abort in case of failure
    IF (ret_val <> ok) THEN
      GOTO quit
    END
    ;// Call placing procedure here
  END
  ;// End of the MAIN LOOP
quit:
  ;// Disconnect from the Vision Controller
  CALL close_socket
.END

3.2.2 Multiple Vision Systems example

This program is an extension of the basic bin picking example. Instead of one, it initializes two vision systems and switches between them in each cycle.

Name: multiple_vision_systems.pg (located in folder example_programs)

.PROGRAM main_multi_vs ()
  ; *******************************************************************
  ;
  ; Program:      main_multi_vs
  ; Comment:      Main function template with multiple vision systems
  ; Author:       Photoneo s.r.o.
  ;
  ; Date:         30/6/2021
  ;
  ; *******************************************************************
  ;
  ;// Enable State Server to start on boot
  autostart.pc ON
  ;// Amend the Network settings (the IP address, changing the default port to a custom one requires setting the port in BPS network settings)
  bp_port = 11003
  vc_ip[1] = 192
  vc_ip[2] = 168
  vc_ip[3] = 0
  vc_ip[4] = 80
  ;// Connect to the Vision Controller
  CALL connect_to_vc (ret_val)
  ;// Check return value, abort in case of failure
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// Set Vision System ID of the first VS to be initialized
  vision_system_i = 1
  ;// Initialize the vision system with start/end bin picking poses
  CALL initialize_req (ret_val, #pho_start1, #pho_end1)
  ;// Check return value, abort in case of failure
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// Set Vision System ID of the second VS to be initialized
  vision_system_i = 2
  ;// Initialize the vision system with start/end bin picking poses
  CALL initialize_req (ret_val, #pho_start2, #pho_end2)
  ;// Check return value, abort in case of failure
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// Set Vision System ID of the VS for which the first scan will be requested
  vision_system_i = 1
  ;// Call gripper detach procedure
  CALL grip_detach
  ;// Set speed
  SPEED 10 ALWAYS
  ;// Move to Home pose in which the robot does not occlude the scanning area
  JMOVE #pho_home
  BREAK
  ;// Request the first scan, localization and path planning
  CALL scan_req (ret_val)
  ;// Check return value, abort in case of failure
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// Initial wait to enable the system to calculate trajectories
  TWAIT 10
  ;// MAIN LOOP
  WHILE (TRUE) DO
main_start:
    ;// Receive response from the scan request
    CALL wait_for_scan (ret_val)
    ;// Check return value, abort in case of failure
    IF (ret_val <> ok) THEN
      GOTO quit
    END
    ;// Request a trajectory
    CALL traj_req (ret_val)
    ;// Check return value, abort in case of failure
    IF (ret_val <> ok) THEN
      GOTO quit
    END
    ;// Receive response from the trajectory request
    CALL traj_recv (ret_val)
    ;// If the trajectory request was unsuccessful and
    ;// error PATH PLANNING FAILED or NO PART FOUND occurred
    IF (ret_val == planning_failed) OR (ret_val == no_part_found) THEN
      ;// Move back to Home pose
      JMOVE #pho_home
      BREAK
      ;// Request a new scan, localization and path planning
      CALL scan_req (ret_val)
      ;// Check return value, abort in case of failure
      IF (ret_val <> ok) THEN
        GOTO quit
      END
      ;// Go to the beginning of the MAIN LOOP
      GOTO main_start
    END
    ;// If the request was unsuccessful and other error occurred, abort
    IF (ret_val <> ok) THEN
      GOTO quit
    END
    ;// Move to the bin picking start pose
    ;// Different start pose for each vision system
    IF vision_system_i == 1 THEN
      JMOVE #pho_start1
    ELSE
      JMOVE #pho_start2
    END
    ;// Execute bin picking routine
    CALL pick_part
    ;// Move back to Home pose
    JMOVE #pho_home
    BREAK
    ;// Switch the Vision System ID
    IF vision_system_i == 1 THEN
      vision_system_i = 2
    ELSE
      vision_system_i = 1
    END
    ;// Request a new scan, localization and path planning
    CALL scan_req (ret_val)
    ;// Check return value, abort in case of failure
    IF (ret_val <> ok) THEN
      GOTO quit
    END
    ;// Call placing procedure here
  END
  ;// End of the MAIN LOOP
quit:
  ;// Disconnect from the Vision Controller
  CALL close_socket
.END

3.2.3 Change solution example

A single robotic cell can take part in several production processes. Handling of multiple parts concurrently is done by using multiple vision systems in one solution. When completely changing the production process it is more suitable to have separate dedicated solutions that can be deployed directly from the robot.

This program is an extension of the basic bin picking example. After a defined number of bin picking cycles, it sends a request to change the deployed solution.

Name: change_solution.pg (located in folder example_programs)

.PROGRAM main_change_sol ()
  ; *******************************************************************
  ;
  ; Program:      main_change_sol
  ; Comment:      Main function template with single vision system and changing
  ;               of solutions
  ; Author:       Photoneo s.r.o.
  ;
  ; Date:         30/6/2021
  ;
  ; *******************************************************************
  ;
  ;// Enable State Server to start on boot
  autostart.pc ON
  ;// Amend the Network settings (the IP address, changing the default port to a custom one requires setting the port in BPS network settings)
  bp_port = 11003
  vc_ip[1] = 192
  vc_ip[2] = 168
  vc_ip[3] = 0
  vc_ip[4] = 80
  ;// Connect to the Vision Controller
  CALL connect_to_vc (ret_val)
  ;// Check return value, abort in case of failure
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// Set IDs of solutions that will be changing
  sol_id1 = 5
  sol_id2 = 6
  ;// Set ID of current solution
  sol_id = sol_id1
  ;// Set threshold for number of picks, when reached, solution change will be requested
  max_picks = 10
reinit:
  ;// Initialize counter of picks
  pick_counter = 0
  ;// Set Vision System ID
  vision_system_i = 1
  ;// Initialize the vision system with start/end bin picking poses
  ;// Different start/end poses for each solution
  IF sol_id == sol_id1 THEN
    CALL initialize_req (ret_val, #pho_start1, #pho_end1)
  ELSE
    CALL initialize_req (ret_val, #pho_start2, #pho_end2)
  END
  ;// Check return value, abort in case of failure
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// Call gripper detach procedure
  CALL grip_detach
  ;// Set speed
  SPEED 10 ALWAYS
  ;// Move to Home pose in which the robot does not occlude the scanning area
  JMOVE #pho_home
  BREAK
  ;// Request the first scan, localization and path planning
  CALL scan_req (ret_val)
  ;// Check return value, abort in case of failure
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// Initial wait to enable the system to calculate trajectories
  TWAIT 10
  ;// MAIN LOOP
  WHILE (TRUE) DO
main_start:
    ;// Receive response from the scan request
    CALL wait_for_scan (ret_val)
    ;// Check return value, abort in case of failure
    IF (ret_val <> ok) THEN
      GOTO quit
    END
    ;// Request a trajectory
    CALL traj_req (ret_val)
    ;// Check return value, abort in case of failure
    IF (ret_val <> ok) THEN
      GOTO quit
    END
    ;// Receive response from the trajectory request
    CALL traj_recv (ret_val)
    ;// If the trajectory request was unsuccessful and
    ;// error PATH PLANNING FAILED or NO PART FOUND occurred
    IF (ret_val == planning_failed) OR (ret_val == no_part_found) THEN
      ;// Move back to Home pose
      JMOVE #pho_home
      BREAK
      ;// Request a new scan, localization and path planning
      CALL scan_req (ret_val)
      ;// Check return value, abort in case of failure
      IF (ret_val <> ok) THEN
        GOTO quit
      END
      ;// Go to the beginning of the MAIN LOOP
      GOTO main_start
    END
    ;// If the request was unsuccessful and other error occurred, abort
    IF (ret_val <> ok) THEN
      GOTO quit
    END
    ;// Move to the bin picking start pose
    ;// Different start pose for each solution
    IF sol_id == sol_id1 THEN
      JMOVE #pho_start1
    ELSE
      JMOVE #pho_start2
    END
    ;// Execute bin picking routine
    CALL pick_part
    ;// Increment counter of picks
    pick_counter = pick_counter + 1
    ;// Move back to Home pose
    JMOVE #pho_home
    BREAK
    ;// Request a new scan, localization and path planning
    CALL scan_req (ret_val)
    ;// Check return value, abort in case of failure
    IF (ret_val <> ok) THEN
      GOTO quit
    END
    ;// Call placing procedure here
    ;// If the threshold for number of picks has been reached, change solutions
    IF pick_counter == max_picks THEN
      ;// Receive response from the scan request
      CALL wait_for_scan (ret_val)
      ;// Check return value, abort in case of failure
      IF (ret_val <> ok) THEN
        GOTO quit
      END
      ;// Reset counter of picks
      pick_counter = 0
      ;// Set ID of solution that should be deployed
      IF sol_id == sol_id1 THEN
        sol_id = sol_id2
      ELSE
        sol_id = sol_id1
      END
      ;// Request change of solutions
      CALL change_sol_req (ret_val, sol_id)
      ;// Check return value, abort in case of failure
      IF (ret_val <> ok) THEN
        GOTO quit
      END
      ;// Go to start of the program (initialization of vision system)
      GOTO reinit
    END
  END
  ;// End of the MAIN LOOP
quit:
  ;// Disconnect from the Vision Controller
  CALL close_socket
.END

3.2.4 Calibration example

This program is a template for semi-automatic calibration.

Before running the program:

  • teach the calibration start pose through which the robot will move to the individual calibration poses

  • teach the individual calibration poses

  • start the calibration in the Bin Picking Studio

Now you can start the program. It will move to individual calibration poses and send the Add calibration point request when it reaches them. In between the calibration poses the robot will go through the calibration start pose. Once all the calibration points are successfully added, the program ends. If you are satisfied with the calibration result, save it in the Bin Picking Studio.

Name: calibration.pg (located in folder example_programs)

.PROGRAM main_calib ()
  ; *******************************************************************
  ;
  ; Program:      main_calib
  ; Comment:      Main function template with calibration routine
  ;
  ; Date:         30/6/2021
  ;
  ; *******************************************************************
  ;
  ;// Enable State Server to start on boot
  autostart.pc ON
  ;// Amend the Network settings (the IP address, changing the default port to a custom one requires setting the port in BPS network settings)
  bp_port = 11003
  vc_ip[1] = 192
  vc_ip[2] = 168
  vc_ip[3] = 0
  vc_ip[4] = 80
  ;// Connect to the Vision Controller
  CALL connect_to_vc (ret_val)
  ;// Check return value, abort in case of failure
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// 1. calibration point
  ;// Go to the pose from which the robot will move to the calibration poses
  JMOVE #default_pose
  ;// Go to the first calibration pose
  JMOVE #calib_1
  BREAK
  PRINT "BP_CLIENT: Adding the 1st calibration point"
  ;// When the pose is reached, call request to add the first calibration point
  CALL calib_add_req (ret_val)
  ;// Check return value, abort in case of failure
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// 2. calibration point
  JMOVE #default_pose
  JMOVE #calib_2
  BREAK
  PRINT "BP_CLIENT: Adding the 2nd calibration point"
  CALL calib_add_req (ret_val)
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// 3. calibration point
  JMOVE #default_pose
  JMOVE #calib_3
  BREAK
  PRINT "BP_CLIENT: Adding the 3rd calibration point"
  CALL calib_add_req (ret_val)
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// 4. calibration point
  JMOVE #default_pose
  JMOVE #calib_4
  BREAK
  PRINT "BP_CLIENT: Adding the 4th calibration point"
  CALL calib_add_req (ret_val)
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// 5. calibration point
  JMOVE #default_pose
  JMOVE #calib_5
  BREAK
  PRINT "BP_CLIENT: Adding the 5th calibration point"
  CALL calib_add_req (ret_val)
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// 6. calibration point
  JMOVE #default_pose
  JMOVE #calib_6
  BREAK
  PRINT "BP_CLIENT: Adding the 6th calibration point"
  CALL calib_add_req (ret_val)
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// 7. calibration point
  JMOVE #default_pose
  JMOVE #calib_7
  BREAK
  PRINT "BP_CLIENT: Adding the 7th calibration point"
  CALL calib_add_req (ret_val)
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// 8. calibration point
  JMOVE #default_pose
  JMOVE #calib_8
  BREAK
  PRINT "BP_CLIENT: Adding the 8th calibration point"
  CALL calib_add_req (ret_val)
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// 9. calibration point
  JMOVE #default_pose
  JMOVE #calib_9
  BREAK
  PRINT "BP_CLIENT: Adding the 9th calibration point"
  CALL calib_add_req (ret_val)
  IF (ret_val <> ok) THEN
    GOTO quit
  END
  ;// Return to the default pose
  JMOVE #default_pose
quit:
  IF (ret_val <> ok) THEN
    PRINT "BP_CLIENT: Error while adding the calibration point"
    PRINT "BP_CLIENT: Check BPS for more details"
  END
  ;// Disconnect from the Vision Controller
  CALL close_socket
  HALT
.END

3.3 Error handling

If an error occurs during the execution of the operation requested by the sent request the error is stored in the return variable .ret_val_X and the global variable error_msg. It is recommended to implement adequate error handling for your particular application after each synchronous request and response receiving procedure.

Error codes together with their description and troubleshooting can be found here.

The most important error codes are defined as constants in the procedure init_consts which is called every time the procedure Connect to Action Request Server is executed. These error codes are:

Error code

AS constant

No error (0)

ok = 0

Service error (1)

service_err = 1

Communication error (3)

comm_failure = 3

Bad data (4) [deprecated]

bad_data = 4

Timeout [5]

timeout = 5

Path planning failed (201)

planning_failed = 201

No object found (202)

no_part_found = 202

Vision system not initialized (203)

not_init = 203

Empty scene (218)

empty_scene = 218

Wrong bin picking configuration (255)

wrong_bp_config = 255


Note: Error Bad data (4) is not used anymore on Kawasaki.

Note: Example programs provide basic error handling.

4 Running the basic bin picking example program

4.1 Prerequisites

Before the Basic bin picking example can be run, the following requirements must be met:

  • A fully configured BPS solution with a single vision system must be prepared for deployment

  • The robot controller must be configured according to the chapter Robot controller setup of this integration guide

  • Bin Picking Studio network settings must be configured

  • Gripper procedures should be implemented (optional - if not implemented, the robot will not actually pick the object)

  • The placing procedure should be implemented

4.2 Bin picking routine execution settings

customer_definitions.pg contains procedures Trajectory X configuration (traj_X_params) which enable the user to specify the parameters of individual trajectories of the binpicking routine.
The procedures set speed/acceleration/deceleration/accuracy parameters for upcoming motion commands.
Procedure Execute bin picking routine **(pick_part) calls these **Trajectory X configuration procedures before trajectory execution based on ordering ID of trajectories.
By default, the speeds of the first 4 trajectories of the bin picking routine are configured (the default number of trajectories in a bin picking routine is 4 - as defined in the Grasping method of the BPS solution).

Adapt the values inside these procedures to meet your requirements. If adding custom path stages (trajectories), create an additional procedure Trajectory X configuration. Beware of the order of the trajectories so that the correct procedure is called.

4.3 Reteach the robot poses

A crucial step of bin picking configuration is the teaching of home, start, and end poses. The home position of the robot should be taught in such a way that the robot is outside the scanning area. The start position should be taught in such a way that the robot gripper is approximately above the center of the bin. The end position can be similar to the start position or slightly shifted towards the placing area. Do not define the end pose too far from the bin as this might affect the path planning (increase total planning time, cause planning errors, etc.).

The Basic bin picking example program uses the following poses:

#pho_home - Home position (defined as joint displacement values)

#pho_start - Start position (defined as joint displacement values)

#pho_end - End position (defined as joint displacement values)

4.4 Runtime

Deploy your BPS solution. The Action Request Client status on the Deployment page of the BPS should be **  DISCONNECTED  ** (from the Action Request Server).

The first step is to select the program which will be run. Click on the yellow program rectangle on the pendant touch screen:
image15
Select Directory to enter the program list:
image16
Find and select the main program:
image17
When the main program is prepared for launch, hold A key + press RUN/HOLD key on the pendant. RUN status should appear in the top right corner:
image18
Now turn on the motor power. Hold A key + MOTOR_ON/JOG key. You should hear that the motor brakes have been released and MOTOR status should appear right next to the RUN status in the top right corner.
image19
Start the main program on the robot controller. Hold A key + press CYCLE START/CONT key. The CYCLE status should appear green in the top right corner:
image20
The Action Request Client status on the Deployment page will change to the **  CONNECTED  ** state.
If you press Menu -> Keyboard on Teach Pendant, you should see text outputs as shown in the figure below signalizing that the Action Request Client is working properly.
image21
As soon as the trajectory to the first localized object is calculated, the robot should start executing motion.

NOTE: Ensure that you are ready to halt motion execution immediately. It is strongly recommended to reduce the speed to 10% of maximum during initial bin picking tests.

5 Migration guide

This chapter will walk you through the process of updating your robot module to newer version. It also documents program flow, API and other changes to help you make all necessary modifications in your current program without encountering any problems.

5.1 BPS 1.1.x -> BPS 1.2.x

NOTE: Migration between these versions does require robot module update as described in chapter **:ref:`5.6 <integration_guide_for_robots_by_kawasaki_5.6_Robot_module_update>`** as well as update of the main program according to changes in API.

Changes in API calls as well as new calls are described in the table below:

API call

Bin Picking Studio 1.1.x

Bin Picking Studio 1.2.x

Version compatibility

init_req()

Parameters ‘.$start_pose’ & ‘.$end_pose’ do not exist. Global variable ‘vision_system_id’ does not exist.

Parameters ‘.$start_pose’ & ‘.$end_pose’ are required. Global variable ‘vision_system_id’ specifies ID of the selected Vision System for the request call.

Changed.

scan_req()

Global variable ‘vision_system_id’ does not exist.

Global variable ‘vision_system_id’ specifies ID of the selected Vision System for the request call.

Changed.

traj_req()

Global variable ‘vision_system_id’ does not exist.

Global variable ‘vision_system_id’ specifies ID of the selected Vision System for the request call.

Changed.

customer_req()

Global variable ‘vision_system_id’ does not exist.

Global variable ‘vision_system_id’ specifies ID of the selected Vision System for the request call.

Changed.

pick_failed_req()

Not available.

Available. Lower preference of the object because it failed to be picked. It won’t be chosen to be picked in the next cycle.

New.

calib_start_req()

Not available.

Unsupported. For Photoneo internal use only.

New.

locate_bin_req()

Not available.

Unsupported. For Photoneo internal use only.

New.

change_sol_req()

Not available.

Unsupported. For Photoneo internal use only.

New.

Changes in variables as well as new variables are described in the table below:

Variable

Bin Picking Studio 1.1.x

Bin Picking Studio 1.2.x

Version compatibility

vision_system_id

Not available.

Available. ID of Vision System to be used in called requests. Change its value before calling a request for different Vision System.

New.

tp_invariance

Not available.

Available. ID of Tool point invariance used for currently picked object.

New.

gp_id

Not available.

Available. ID of Gripping point used for currently picked object.

New.

gp_invariance

Not available.

Available. ID of Gripping point invariance used for currently picked object.

New.

PHO_WRONG_BP_CONF

Not available.

Available. Value = 255 Occurs when the bin picking configuration is incorrect. After receiving this error check the Bin Picking Studio console for more detailed information.

New.

Other changes are described in the table below:

Subject

Bin Picking Studio 1.1.x

Bin Picking Studio 1.2.x

Version compatibility

Default port numbers

Action Request Server on Vision Controller: 11003
State server on Robot Controller: 11004
User has an option to configure these values.

Action Request Server on Vision Controller: 11003 State server on Robot Controller: 11004 User is recommended to use these default values - it is not possible to configure port values in Bin Picking Studio by the user. If you need to use specific port value please contact support@photoneo.com to help you with configuring port in Bin Picking Studio.

Changed.

5.2 BPS 1.2.x -> BPS 1.3.x

NOTE: Migration between these versions does require robot module update as described in chapter **:ref:`5.6 <integration_guide_for_robots_by_kawasaki_5.6_Robot_module_update>`**. The main program, however, does not require any changes.

Changes in API calls as well as new calls are described in the table below:

API call

Bin Picking Studio 1.2.x

Bin Picking Studio 1.3.x

Version compatibility

change_sol_req()

Unsupported. For Photoneo internal use only.

Supported. Request to change deployed solution.

Unchanged.

5.3 BPS 1.3.x -> BPS 1.4.x

NOTE: Migration between these versions does require robot module update as described in chapter **:ref:`5.6 <integration_guide_for_robots_by_kawasaki_5.6_Robot_module_update>`**. The main program, however, does not require any changes.

5.4 BPS 1.4.x -> BPS 1.5.x

NOTE: Migration between these versions does require robot module update as described in chapter **:ref:`5.6 <integration_guide_for_robots_by_kawasaki_5.6_Robot_module_update>`**. The main program, however, does not require any changes.

Changes in variables as well as new variables are described in the table below:

Variable

Bin Picking Studio 1.4.x

Bin Picking Studio 1.5.x

Version compatibility

[STRIKEOUT:EMPTY_SCENE]

Not available.

Available.
Value = 218
Error indicating that the scene (bin) is empty. Response to failed trajectory request.
Note: The error code is not defined in the robot module (photoneo_common.pg) as the other error codes.
Please check the return value of procedure traj_recv(ret_val) using value 218 directly.

New.

5.5 BPS 1.5.x -> BPS 1.6.x

NOTE: Migration between these versions does require robot module update as described in chapter **:ref:`5.6 <integration_guide_for_robots_by_kawasaki_5.6_Robot_module_update>`**. The main program, however, does not require any changes.

Please read the general Migration guide here. The table below summarizes changes specific to the Robot module for Kawasaki.

Variable

Bin Picking Studio 1.5.x

Bin Picking Studio 1.6.x

Version compatibility

Error code [2]
UNKNOWN REQUEST

Unused.

Removed.

Changed.

Error code [204] PART LOST

Unused.

Removed.

Changed.

5.6 Robot module update

Please follow these steps to update your current robot module to newer version compatible with Bin Picking Studio version you are using:

  1. Back up programs from module customer_definitions.pg you have customized. They contain your custom settings as well as gripper action procedures. For example you may have implemented program grip_attach()

  2. Remove all current programs except for your main program

  3. Load new modules: photoneo_common.pg and customer_definitions.pg

  4. Apply your modifications from old programs to the new ones

  5. Carefully read the API changes in the new version of the robot module and modify your current API calls in your main program accordingly (if necessary)

6 Troubleshooting

If you experience Open Socket Error as shown in the figure below, it means that the previous connection to the Bin Picking Studio has not been properly closed.
image22
Run the close_socket() program to terminate the previous session properly:
image23