Difference between revisions of "Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with ABB robots"

From 3D scanning Knowledge base - Photoneo wiki
Jump to: navigation, search
(4.6 Vision System ID)
 
(43 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
'''NOTE: Users are strongly recommended to read the  [http://wiki.photoneo.com/index.php/Binpicking_Tutorial:_Introduction_to_Robot_Interfaces general introduction to robot interfaces] prior to installing specific robot modules.'''
 +
 
== 1. Prerequisities ==
 
== 1. Prerequisities ==
  
Photoneo ABB Interface is intended for '''RoboTWareOS versions 5.13 and higher'''.  
+
Photoneo ABB Interface is compatible with '''RobotWareOS versions 5.13 and higher'''.  
  
In addition to compliant system version, following conditions must be met:
+
In addition to compatible system version, the following conditions must also be met:
  
 
- '''(616-6) PC Interface Module''' available
 
- '''(616-6) PC Interface Module''' available
Line 9: Line 11:
 
- '''(672-1) Multitasking Module''' available
 
- '''(672-1) Multitasking Module''' available
  
Browse to '''System Info -> System Properties -> Control Module -> Options''' to check if these options are available within your system:
+
Go to '''System Info -> System Properties -> Control Module -> Options''' to check if these options are available within your system:
  
[[File: Pendant options check.png]]
+
[[File: Pendant options check.png|frame|none|alt=Alt text| Figure 1.1]]
  
 
   
 
   
NOTE: Use of '''Robot Studio v.6.06''' (or higher version) is highly recommended for Photoneo ABB Interface setup.
+
NOTE: Use of '''Robot Studio v.6.06''' or higher is highly recommended for Photoneo ABB Interface setup.
  
 
== 2. ABB Controller setup ==
 
== 2. ABB Controller setup ==
  
Following tutorial gives a step by step guide how to configure your ABB IRC5 controller and install all necessary RAPID files to get the robot interface for Photoneo Binpicking Solution running.  
+
The following tutorial gives a step by step guide of how to configure your ABB IRC5 controller and install all necessary RAPID files you will need to get the robot interface for Photoneo Binpicking Studio up and running.  
  
 
This tutorial was originally written using the latest '''RobotWare v.6.06''', however it should be compatible with older versions with minor changes.   
 
This tutorial was originally written using the latest '''RobotWare v.6.06''', however it should be compatible with older versions with minor changes.   
Line 24: Line 26:
 
=== 2.1 Network configuration ===
 
=== 2.1 Network configuration ===
  
Turn on the IRC5 Controller, wait for Initialization Screen to appear, open '''Menu screen''' and select '''Control Panel''' option:
+
''NOTE: The network configuration procedure described below only works with RobotWareOS v.6 or higher. If you have an older version of RobotWareOS and need to change an IP address, please contact local ABB support.''
 +
 
 +
Turn on the IRC5 Controller, wait for the Initialization Screen to appear, open the '''Menu screen''' and select the '''Control Panel''' option:
 
   
 
   
  
[[File:ABB_pendant_menu_RW6.png]]
+
[[File:ABB_pendant_menu_RW6.png|frame|none|alt=Alt text| Figure 2.1]]
  
  
On the Control Panel pane, select '''Controller Settings:'''
+
In the Control Panel pane, select '''Controller Settings:'''
  
  
[[File:ABB_pendant_control_panel.png]]  
+
[[File:ABB_pendant_control_panel.png|frame|none|alt=Alt text| Figure 2.2]]
  
  
Select '''Settings''' and choose '''Network''' option:  
+
Select '''Settings''' and choose the '''Network''' option:  
  
  
[[File:ABB pendant network.png]]
+
[[File:ABB pendant network.png|frame|none|alt=Alt text| Figure 2.3]]
  
  
Network settings window should appear. Use the '''touch panel keypad''' to set an IP address of the IRC5 WAN port:
+
The Network Settings window should now appear. Use the '''Touch Panel Keypad''' to set the IP address of the IRC5 WAN port:
  
  
[[File:ABB pendant IP setup.png]]
+
[[File:ABB pendant IP setup.png|frame|none|alt=Alt text| Figure 2.4]]
  
  
Press '''OK button''' and restart the controller to apply new settings:
+
Choose '''OK button''' and restart the Controller to apply the new settings:
  
  
[[File:ABB pendant restart.png]]
+
[[File:ABB pendant restart.png|frame|none|alt=Alt text| Figure 2.5]]
  
  
Line 58: Line 62:
 
=== 3.1 Connect to IRC5 Controller from Robot Studio ===
 
=== 3.1 Connect to IRC5 Controller from Robot Studio ===
  
Set your local PC network settings to DHCP, plug Ethernet cable to '''Service Port''' of IRC5 Controller and launch Robot Studio.
+
Set your local PC network settings to DHCP, plug an Ethernet cable into the '''Service Port''' of the IRC5 Controller and launch Robot Studio.
  
For direct connection to Robot Controller, select '''Controller''' tab and '''One Click Connect''' option:  
+
For a direct connection to the Robot Controller, select the '''Controller''' tab and select the '''One Click Connect''' option:  
  
  
[[File:Robot studio connect.png]]
+
[[File:Robot studio connect.png|frame|none|alt=Alt text| Figure 3.1.1]]
  
 
=== 3.2 Transfer RAPID files ===
 
=== 3.2 Transfer RAPID files ===
  
As a first step in installation of Photoneo ABB Interface, you need to copy RAPID files from your PC to the Robot Controller
+
The first step in the installation of Photoneo ABB Interface is to copy the RAPID files from Photoneo ABB Module Archive which you received with Photoneo BP Studio to the Robot Controller.
  
You can use USB stick and copy files directly via pendant, however the most convenient way is to use Robot Studio File Transfer tool.  
+
You can copy the files directly from the USB stick using the Pendant, however the most convenient method to transfer the RAPID files is to use the Robot Studio File Transfer tool.  
  
Go to '''Controller''' tab and select '''File Transfer''' tool from the menu:
+
Go to the '''Controller''' tab and select the '''File Transfer''' tool from the menu:
  
  
[[File:Robot studio file transfer.png]]  
+
[[File:Robot studio file transfer.png|frame|none|alt=Alt text| Figure 3.2.1]]
  
  
Photoneo ABB Interface consists of '''four RAPID files''':
+
The Photoneo ABB Interface consists of '''four RAPID files''':
  
 
- '''MainModule.mod'''
 
- '''MainModule.mod'''
Line 87: Line 91:
 
- '''PhotoneoCommon.sys'''
 
- '''PhotoneoCommon.sys'''
  
All these files need to be transferred to the ''HOME:/Photoneo/'' folder created within the robot controller file system as shown by the figure below:
+
All of these files need to be transferred to the ''HOME:/Photoneo/'' folder created within the Robot Controller file system as is shown in the figure below:
  
  
[[File:Robot studio file transfer 2.png]]
+
[[File:Robot studio file transfer 2.png|frame|none|alt=Alt text| Figure 3.2.2]]
  
  
 
=== 3.3 Create State Server Task ===
 
=== 3.3 Create State Server Task ===
  
For correct functionality of State Server, open '''PhotoneoStateServer.mod''' and make sure that variables '''robot_task_id''' and '''pho_state_server_port''' are valid with respect to your system configuration.  
+
In order to ensure the full functionality of the State Server, open '''PhotoneoStateServer.mod''' and check that the '''robot_task_id''' and '''pho_state_server_port''' variables are valid with respect to your system configuration.  
 +
 
 +
(For example, multi axes systems use T_ROB1 and T_ROB2 tasks; your network configuration might prevent using port 11005 etc). If you are not comfortable about making these changes to your system, please stick to the default values.
 +
 
 +
 
 +
[[File:Robot studio state server config2.png|frame|none|alt=Alt text| Figure 3.3.1]]
 +
 
 +
 
 +
The next step in the setup is to create State Server Task. Select the '''Request Write Access''' option on the Controller tab in Robot Studio and the '''Grant Access''' option on the Pendant:
  
(For example multi axes systems use T_ROB1 and T_ROB2 tasks, your network configuration might prevent using port 11005 etc). Keep default values if you are not confident about these changes.
 
  
 +
[[File:ABB pendant grant access.png|frame|none|alt=Alt text| Figure 3.3.2]]
  
[[File:Robot studio state server config2.png]]
 
  
 +
The State Server Task which runs in the background and will report the current state of the robot to the Vision Controller.
  
As a next step we need to create State Server Task. State Server Task will run in background and will report current robot state to the Vision Controller.  
+
On the Left pane, select the '''Controller''' option, right click on the '''Task''' item in the list and select '''New Task...''':
  
On the Left pane, click '''Controller''' then right click on the '''Task''' item in the list and select '''New Task...''':
 
  
 +
[[File:Robot Studio Task Definition 2.png|frame|none|alt=Alt text| Figure 3.3.3]]
  
[[File:Robot Studio Task Definition 2.png]]
 
  
 +
The following dialogue should appear. Change the settings to those shown in the figure below:
  
Following dialog should appear. Change settings as shown in the figure below:
+
(''String to Copy & Paste:'' '''Task''': PHO_STATE_SERVER, '''Main Entry''': pho_state_server_main)
  
  
[[File:Robot studio task settings 3.png]]
+
[[File:Robot studio task settings 3.png|frame|none|alt=Alt text| Figure 3.3.4]]
  
 
=== 3.4 Automatic Loading of Modules ===
 
=== 3.4 Automatic Loading of Modules ===
  
Now we need to configure ABB system to automatically load '''StateServer.mod''' during the boot.
+
Now we need to configure the ABB system to automatically load '''StateServer.mod''' during the boot.
 +
 
 +
Right Click on '''Automatic Loading of Modules''' and select '''New Automatic Loading of Modules''' as shown in the figure below:
  
Right Click on '''Automatic Loading of Modules''' and Select '''New Automatic Loading of Modules''' as shown in the figure below:
 
  
 +
[[File:Robot studio loading modules.png|frame|none|alt=Alt text| Figure 3.4.1]]
  
[[File:Robot studio loading modules.png]]
 
  
 +
Configure the module for '''PhotoneoState Server.mod''' as is shown in the figure below:
 +
 +
(''String to Copy & Paste:'' '''File''': HOME://Photoneo/PhotoneoStateServer.mod)
  
Configure module for '''PhotoneoState Server.mod''' as shown in the figure below:
 
  
 +
[[File:Robot studio state server automatic loading.png|frame|none|alt=Alt text| Figure 3.4.2]]
  
[[File:Robot studio state server automatic loading.png]]
 
  
 
Repeat the same procedure for '''PhotoneoCommon.sys''' as a system module:
 
Repeat the same procedure for '''PhotoneoCommon.sys''' as a system module:
 +
 +
(''String to Copy & Paste:'' '''File''': HOME://Photoneo/PhotoneoCommon.sys)
  
  
[[File:Robot studio pho common.png]]
+
[[File:Robot studio pho common.png|frame|none|alt=Alt text| Figure 3.4.3]]
  
  
Repeat the same procedure also for '''CustomerDefinitions.mod''' containing user settings:
+
Also repeat the same procedure for '''CustomerDefinitions.mod''' containing user settings:
  
 +
(''String to Copy & Paste:'' '''File''': HOME://Photoneo/CustomerDefinitions.mod)
  
[[File:Robot studio customer definitions.png]]
+
 
 +
[[File:Robot studio customer definitions.png|frame|none|alt=Alt text| Figure 3.4.3]]
  
 
=== 3.5 Load Main Module ===
 
=== 3.5 Load Main Module ===
  
Now we are ready to manually load '''MainModule.mod''' to T_ROB1 task. You can load the '''MainModule.mod''' file from your PC or directly from the controller.  
+
We are now ready to manually load '''MainModule.mod''' to T_ROB1 task. You can load the '''MainModule.mod''' file from your PC or directly from the Controller.  
  
 
Right Click on '''T_ROB1''' task and select '''Load Module''' or '''Load Module From Controller''':
 
Right Click on '''T_ROB1''' task and select '''Load Module''' or '''Load Module From Controller''':
  
  
[[File:Robot studio load module.png]]
+
[[File:Robot studio load module.png|frame|none|alt=Alt text| Figure 3.5.1]]
  
  
This was the last step in Photoneo ABB Interface installation. Your RAPID left panel should now look like this:
+
Installation of the Photoneo ABB Interface is now complete. Your RAPID left panel should now look like this. Restart the Controller to apply all configuration changes:
  
  
[[File:Robot studio final panel2.png]]
+
[[File:Robot studio final panel2.png|frame|none|alt=Alt text| Figure 3.5.2]]
  
And now lets dig into RAPID code to configure and fine tune your bin picking sequence.
+
 
 +
At this point your Robot Controller is configured to work with Photoneo Binpicking Studio. However your RAPID code must be adopted to meet your application requirements - you need to reteach HOME, START and END poses, update part placing, application logic, etc. The following section of the tutorial provides basic examples of how this can be programmed as well as a detailed explanation of Photoneo RAPID API.  
  
 
== 4. RAPID ==
 
== 4. RAPID ==
Line 169: Line 189:
 
=== 4.1 RAPID API ===
 
=== 4.1 RAPID API ===
  
Following API describes functionality of requests provided by Photoneo ABB Interface. They are intended for high level control of bin picking sequence and usually called in MainModule.mod.   
+
Module '''PhotoneoCommon.sys''' contains API calls (requests) provided by Photoneo ABB Interface. These requests are intended for high level control of bin picking sequences and are usually called in module '''MainModule.mod'''.
 +
   
 
--------------------------------------------------------
 
--------------------------------------------------------
'''pho_request_init(jointtarget pho_start_bin_picking_pose, jointtarget pho_end_bin_piking_pose)''' - request to initialize bin picking application on the Vision Controller side. Start and End Pose defined by the operator on the RAPID side are transferred to the Vision Controller and used in the trajectory planning pipeline as a start and terminus points.   
+
'''pho_request_init(jointtarget pho_start_bin_picking_pose, jointtarget pho_end_bin_picking_pose)''' - request to initialize binpicking application from the Vision Controller side. Start and End Poses defined by the operator from the RAPID side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points.   
  
'''pho_wait_for_server()''' - function to establish connection to the Vision Controller. Blocking function, program does not continue until connection is established properly. If server running on Vision Controller side is not running or not responding, en error is raised and RAPID program is terminated.
+
'''pho_wait_for_server((string server_ip, \num port_number, \num wait_time, \switch sys_stop | switch sys_restart)''' - function to establish a connection to the Vision Controller. Blocking function; suspends the program until a proper connection is established. If the server running on the Vision Controller side is not running or does not respond, an error is raised and the RAPID program is terminated. We recommend ommiting optional parameter '''port_number''' (default value will be used). If you need to use specific port value please contact '''support@photoneo.com''' to help you with configuring port in Binpicking Studio.
  
'''pho_request_scan()''' - request to trigger next scan and localization. Non-blocking request, RAPID program continues immediately at next line
+
'''pho_request_scan(num vision_system_id)''' -   request to trigger the next scan and localization. Nonblocking request; the RAPID program continues immediately at the next line.
  
'''pho_wait_for_scan_completition()''' - function to wait for scan to be finished. Should be called after triggering the scan, but not immediately
+
'''pho_wait_for_scan_completition(\num wait_time)''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately.
  
'''pho_request_trajectory()''' - request to start trajectory planning for current goal. Non blocking function, RAPID program continues immediately at the next line
+
'''pho_request_trajectory(num vision_system_id)''' - request to start trajectory planning for current goal. Non-blocking function; the RAPID program continues immediately at the next line.
  
'''pho_receive_trajectory()''' - function to receive requested bin picking trajectory (consists sequence of trajectory and gripper operations). This is usually called inside pho_bin_picking() function by default. Blocking function - waits for motion data to be received.   
+
'''pho_receive_trajectory(\num wait_time)''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pho_bin_picking()'' function by default. Blocking function; waits for motion data to be received.   
  
'''pho_request_scan_and_traj()''' - function to trigger scan, localization and trajectory planning in a single shot. Blocking function, handy for initial bin picking experiments. For actual production it is more convenient to split this sequence into particular actions and call them accordingly (pho_request_scan & pho_request_trajectory).  
+
'''pho_request_calib_start (num vision_system_id)''' - request to start calibration. '''Currently unsupported. Prepared for future use.'''
  
'''pho_request_calib_add_point()''' - request to add calibration point - scan is triggered and calibration is recalculated. Blocking request, program does not continue until calibration result is recalculated and received by the robot controller.
+
'''pho_request_calib_add_point()''' - request to add calibration point - a scan is triggered and the calibration is recalculated. Blocking request; the program will not continue until the calibration result is recalculated and has been received by the Robot Controller. '''Currently unsupported. Prepared for future use.'''
  
'''pho_calib_set()''' - request to set current calibration result to the PhoXi Scanner
+
'''pho_request_calib_set()''' - request to set current calibration result to the PhoXi Scanner. '''Currently unsupported. Prepared for future use.'''
  
'''pho_calib_reset()''' - request to reset current calibration and remove all previously added points
+
'''pho_request_calib_reset()''' - request to reset current calibration and remove all previously added points. '''Currently unsupported. Prepared for future use.'''
  
'''pho_bin_picking()''' - request to execute bin picking operation. It usually receives requested trajectory and perform motion execution. Blocking function, program does not continue until the whole sequence is finished. Always make sure that robot is in '''pho_start_bin_picking_pose''' before calling this function.
+
'''pho_other_req (num data{*}, num size, num vision_system_id)''' - request used to send additional data to Vision Controller.
 +
 
 +
 
 +
'''pho_request_bin_locator (num vision_system_id) ''' - request to start localization of the bin containing parts to be picked. Bin CAD model position is adjusted in environment. '''Currently unsupported. Prepared for future use.'''
 +
 
 +
'''pho_request_send_pick_failed (num vision_system_id) ''' - notify Vision Controller about failed pick to lower preference of the part during object-to-pick selection process.
 +
 
 +
'''pho_request_change_solution (num solution_id)''' - request to change deployed solution.''' Currently unsupported. Prepared for future use.'''
 
--------------------------------------------------------
 
--------------------------------------------------------
  
 
=== 4.2 RAPID CONFIG ===
 
=== 4.2 RAPID CONFIG ===
  
'''CustomerDefinitions module''' enables user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision.  
+
'''CustomerDefinitions module''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments.  
 
--------------------------------------------------------
 
--------------------------------------------------------
- '''open_gripper()'''  - implement function for opening your gripper here   
+
- '''gripper_attach()'''  - implement function for attaching object to the gripper here   
  
- '''close_gripper()'''  - implement function for closing your gripper here
+
- '''gripper_detach()'''  - implement function for detaching object from gripper here
  
 
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)
 
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)
Line 214: Line 242:
 
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)
 
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)
  
- '''binpicking_settings()''' - specify speed and precision settings for bin picking trajectories. Adopt number of trajectories to meet your bin picking setup. (by default 4 trajectories are used)  
+
- '''binpicking_settings()''' - specify speed and precision settings for bin picking trajectories. Adopt the suitable number of trajectories to meet your bin picking setup. (the default setting is 4 trajectories)  
  
- '''pho_bin_picking_simple()''' - the very basic bin picking sequence (for experimental purposes)
+
- '''pho_bin_picking_simple()''' - a very basic bin picking sequence (for experimental purposes)
  
- '''pho_bin_picking()''' - standard bin picking sequence. It is flexible, operation based implementation which allows performing bin picking sequences, which consist of various numbers of operations. '''Do not edit !!!'''
+
- '''pho_bin_picking()''' - executes standard bin picking sequence which consist of various number of operations to be performed. Blocking function; the program does not continue until the whole sequence has finished. Always make sure that the robot is in '''start_bin_picking_jointtarget''' before calling this function '''(DO NOT EDIT!)'''
  
 
--------------------------------------------------------
 
--------------------------------------------------------
Line 224: Line 252:
 
=== 4.3 RAPID ERROR HANDLING ===  
 
=== 4.3 RAPID ERROR HANDLING ===  
  
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operation '''PHO_OCCURED_ERR''' flag is set to true. '''PHO_ERR_CODE''' variable contains code of specific error, which helps to identify the source of the problem.   
+
Photoneo ABB interface provides basic error handling. If an error occurs during bin picking operations, the '''PHO_OCCURED_ERR''' flag is set to true. The '''PHO_ERR_CODE''' variable contains the code of the specific error which will helps to identify the source of the problem.   
  
 
'''PHO_NO_ERR := 0''' - Service response from Vision Controller is valid  
 
'''PHO_NO_ERR := 0''' - Service response from Vision Controller is valid  
Line 237: Line 265:
  
 
'''PHO_TIMEOUT := 5''' - Communication failure due to socket timeout.
 
'''PHO_TIMEOUT := 5''' - Communication failure due to socket timeout.
 +
 +
'''PHO_UNKNOWN_ERR := 99''' - Unspecified internal error
  
 
'''PHO_PLANNING_FAILED := 201''' - Trajectory planning has failed
 
'''PHO_PLANNING_FAILED := 201''' - Trajectory planning has failed
Line 246: Line 276:
 
'''PHO_PART_LOST := 204''' - Part has been lost during motion execution
 
'''PHO_PART_LOST := 204''' - Part has been lost during motion execution
  
'''PHO_COLLISION_DETECT := 205''' - Collision has been detected
+
'''PHO_COLLISION_DETECT := 205''' - Collision has been detected.Available only when using non-standard
 +
module CollisionDetect.mod
  
'''PHO_UNKNOWN_ERR := 299''' - Unspecified internal error
+
'''PHO_WRONG_BP_CONFIG := 255''' - Wrong Binpicking configuration. For more details see Binpicking Studio
 +
console on Deployment Page
  
 +
=== 4.4 MAIN MODULE ===
  
=== 4.4 MAIN MODULE ===
+
The following section provides a detailed explanation of '''MainModule.mod''' - the module through which the user's application and Photoneo Bin Picking API are integrated together.  
  
Following section provides detail code explanation of '''MainModule.mod''' which user is request to edit to meet specific application requirements.
+
''NOTE: If you use a pre-generated program from Robot Studio simulation do not use MainModule.mod directly. The following description serves only as an example of how to use Photoneo RAPID API.''  
  
 
==== 4.4.1 main() ====
 
==== 4.4.1 main() ====
  
The '''main()''' procedure is just a selection of which sub-procedure is about to be executed. Comment bin picking if you want to execute calibration and vice versa for bin picking execution.  
+
The '''main()''' procedure is simply a selection of which particular sub-procedure is about to be executed. Comment '''bin_picking''' if you want to execute calibration comment '''calibration''' line if you want to execute bin picking. '''(NOTE: Calibration is currently unavailable).'''
  
[[File: RAPID main start.png]]
+
 
 +
 
 +
    MODULE MainModule
 +
 
 +
    ! Copyright (c) 2018 Photoneo s.r.o.
 +
    ! All rights reserved
 +
    ! Description: Main bin picking module
 +
    !
 +
    ! Home, start and end binpicking target variables
 +
    VAR robtarget home_pose;
 +
    VAR robtarget start_bin_picking_robtarget;
 +
    VAR robtarget end_bin_picking_robtarget;
 +
    VAR jointtarget start_bin_picking_jointtarget;
 +
    VAR jointtarget end_bin_picking_jointtarget;
 +
 +
    ! Error handling variables
 +
    VAR num err_counter;
 +
    CONST num MAX_ERR_COUNT := 2;
 +
   
 +
    PROC main()
 +
 
 +
      !calibration;  ! If bin picking is about to be executed comment this line
 +
      bin_picking;    ! If calibration is about to be executed comment this line
 +
   
 +
  ENDPROC
  
 
==== 4.4.2 bin_picking() ====
 
==== 4.4.2 bin_picking() ====
  
This is a basic bin picking template. '''The main program loop is defined here'''. User is expected to reteach bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part of the code to meet specific workcell and application requirements here.
+
This is a basic bin picking template. '''The main program loop is defined here'''. The user is can reteach bin picking start and end positions, set IP Address and Port of Vision Controller and adopt the placing part of the code to meet specific workcell and application requirements here.
 +
 
 +
    !                                        BIN PICKING
 +
    ! This is a basic bin picking template. The main program loop is defined here. User is expected to reteach  
 +
    ! bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part
 +
    ! of the code to meet specific workcell and application requirements here.  
 +
    !
 +
    PROC bin_picking()
 +
   
 +
    ! Clear error counter for err_handling procedure
 +
    err_counter := 0;
 +
   
 +
    PHO_ERR_CODE := PHO_PLANNING_FAILED;
 +
    !
 +
    ! RETEACH home position for your application
 +
    home_pose := [[99999.0, 99999.0, 99999.0],[0, 0, 0, 1],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
 +
    !
 +
    ! RETEACH bin picking start and end pose
 +
    start_bin_picking_robtarget := [[99999.0, 99999.0, 99999.0],[0, 0, 0, 1],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
 +
    end_bin_picking_robtarget := [[99999.0, 99999.0, 99999.0],[0, 0, 0, 1],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
 +
    !
 +
    ! Convert cartesian position to jointtarget
 +
    start_bin_picking_jointtarget := CalcJointT(start_bin_picking_robtarget, tool0);
 +
    end_bin_picking_jointtarget := CalcJointT(end_bin_picking_robtarget, tool0);
 +
    !
 +
    ! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed
 +
    pho_wait_for_server "192.168.1.6", 11004 ;
 +
    !   
 +
    ! Send bin picking initialization request to the Vision Controller,
 +
    ! start and end poses defined above will be used in trajectory planning pipeline
 +
    pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;
 +
    ! 
 +
    ! Move robot away from scanning area - reteach this position for your robot and workcell
 +
    MoveJ home_pose, v500, z30, tool0;
 +
    !
 +
    ! When robot is away from scanning area, trigger first scan and localization
 +
    pho_request_scan;
 +
    !
 +
    WHILE true DO
 +
        scan_again:
 +
        !==================== PHOTONEO BIN PICKING START ===========================
 +
        ! Wait until scanning is completed
 +
        pho_wait_for_scan_completion;
 +
        !
 +
        ! Handle errors if occured
 +
        IF (PHO_OCCURRED_ERR = TRUE) THEN           
 +
            err_handling;
 +
            GOTO scan_again;
 +
        ENDIF 
 +
        !
 +
        ! Trigger trajectory planning
 +
        pho_request_trajectory;
 +
        !
 +
        ! While trajectory is being calculated, move robot to bin picking start position
 +
        MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;
 +
        !
 +
        ! Execute bin picking application, calculated trajectory is received here
 +
        pho_bin_picking;     
 +
        !==================== PHOTONEO BIN PICKING END ===========================
 +
        !
 +
        ! Handle errors if occured
 +
        IF (PHO_OCCURRED_ERR = TRUE) THEN           
 +
            err_handling;
 +
            GOTO scan_again;
 +
        ELSE 
 +
            ! Clear error counter for err_handling procedure
 +
            err_counter := 0;
 +
            !
 +
            !==================== PLACING START==================================
 +
            ! Move robot from bin picking end position away from scanning area - reteach this position for your robot and workcell
 +
            ! MoveJ [[171.40,-618.92,669.19],[9.66315E-05,-0.862481,-0.50609,-2.74185E-05],[-1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v500, z30, tool0;
 +
            !
 +
            ! Triger next scan and localization, trajectory for next cycle is calculated while object is being placed
 +
            pho_request_scan;
 +
            !
 +
            ! Commands for actual part placing - reteach positions for your robot and workcell
 +
            ! MoveJ [[171.40,-618.92,669.19],[9.66315E-05,-0.862481,-0.50609,-2.74185E-05],[-1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v500, z30, tool0;
 +
            ! open_gripper;
 +
            ! MoveJ [[171.40,-618.92,669.19],[9.66315E-05,-0.862481,-0.50609,-2.74185E-05],[-1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v500, z30, tool0;         
 +
            !==================== PLACING END=================================== 
 +
        ENDIF       
 +
      ENDWHILE 
 +
    ENDPROC
  
[[File: RAPID bin picking.png]]
 
  
 
==== 4.4.3 calibration() ====
 
==== 4.4.3 calibration() ====
  
'''Reteach calibration positions''' and call '''pho_request_calib_add_point()''' request after reaching each calibration pose. It is recommended to run calibration in MANUAL mode step by step to have a full control over the process. Always make sure that robot does not collide with the workcell during transitions between specific waypoints.
+
'''NOTE: This feature is currently unavailable.'''
 +
 
 +
This procedure is used when you need to perform calibration from robot controller. Please note that recommended way of calibration is using Binpicking studio calibration wizard.
 +
To execute the calibration comment out '''bin_picking'''  task in procedure '''main()''' inside '''MainModule.mod''' and uncomment task '''calibration'''. Revert the changes after finishing calibration.
  
[[File: RAPID calibration.png]]
+
 
 +
'''Reteach calibration positions''' and call '''pho_request_calib_add_point()''' requests after reaching each calibration pose. Users are recommended to run calibration in MANUAL mode in order to have full control over the process. Always make sure that the robot does not collide with the workcell during transitions between specific waypoints.
 +
 
 +
    !                                        CALIBRATION
 +
    ! Reteach calibration positions and call add calibration point request after reaching each calibration pose
 +
    ! It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process.
 +
    ! Always make sure that robot does not collide with workcell during transitions between specific waypoints
 +
    PROC calibration()
 +
   
 +
        ! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed
 +
        pho_wait_for_server "192.168.1.6", 11004;
 +
        ! 
 +
        ! 1. calibration waypoint
 +
        MoveJ [[726.48,-170.77,397.89],[0.100326,-0.586168,0.431152,-0.678565],[-1,0,-2,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v100, fine, tool0;
 +
        pho_request_calib_add_point;
 +
        !
 +
        ! 2. calibration waypoint
 +
        MoveJ [[784.48,103.21,289.54],[0.015591,-0.569148,0.439403,-0.694804],[0,0,-2,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v100, fine, tool0;
 +
        pho_request_calib_add_point;
 +
        !
 +
        ! 3. calibration waypoint
 +
        MoveJ [[612.57,314.22,592.92],[0.191405,-0.613209,0.508347,-0.573517],[0,0,-2,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v100, fine, tool0;
 +
        pho_request_calib_add_point;
 +
        !
 +
        ! 4. calibration waypoint
 +
        MoveJ [[1007.35,-482.44,270.24],[0.566579,-0.514948,0.502784,0.40128],[-1,0,-2,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v100, fine, tool0;
 +
        pho_request_calib_add_point;
 +
        !
 +
        ! 5. calibration waypoint
 +
        MoveJ [[975.17,-513.44,199.63],[0.615751,-0.53949,0.418442,0.393329],[-1,0,-2,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v100, fine, tool0;
 +
        pho_request_calib_add_point;
 +
        !
 +
        ! 6. calibration waypoint
 +
        MoveJ [[813.58,-34.08,404.19],[0.317364,-0.830642,0.138416,-0.436068],[-1,1,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v100, fine, tool0;
 +
        pho_request_calib_add_point;
 +
        !
 +
        ! Finally set calibration result to the PhoXi Scanner
 +
        TPWrite "Setting calibration result to the PhoXi Scanner!";
 +
        pho_request_calib_set; 
 +
        TPWrite "Calibration complete!";
 +
        EXIT;
 +
   
 +
    ENDPROC
  
 
==== 4.4.4 err_handling() ====
 
==== 4.4.4 err_handling() ====
  
Several error situations might occur during bin picking procedure. Some of them are more serious some are less. For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if communication failure is detected, program is halted immediately. It is possible to adopt this behavior in this procedure if needed
+
Several error situations might occur during bin picking procedures. Some problems are more serious, some less. For example, if no part is found or the trajectory planning fails, the program simply attempts to repeat the whole sequence. However, if a communication failure is detected, the program is halted immediately. PHO_ERR_CODE contains the error state from the last response from the Vision Controller.
  
[[File: RAPID Error handling.png]]
+
    !                                        ERROR HANDLING
 +
    ! Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.
 +
    ! For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if
 +
    ! communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed
 +
    PROC err_handling()
 +
   
 +
        !--Release gripper if needed
 +
        !open_gripper;
 +
   
 +
        ! Move robot to home pose
 +
        MoveJ home_pose, v500, z30, tool0;
 +
   
 +
        !--Display error
 +
        TPWrite pho_err_info(PHO_ERR_CODE);
 +
   
 +
        IF err_counter >= MAX_ERR_COUNT THEN
 +
            ErrLog 4800, "Photoneo internal error", pho_err_info(PHO_ERR_CODE), "Please reboot the Vision controller and restart application"," ", " ";
 +
            EXIT;
 +
        ENDIF
 +
   
 +
        ! If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)
 +
        IF (PHO_ERR_CODE = PHO_PLANNING_FAILED OR PHO_ERR_CODE = PHO_NO_PART_FOUND) THEN       
 +
            TPWrite "NO PART FOUND OR PLANNING PATH FAILED";
 +
            pho_request_scan;
 +
   
 +
        ! If bin picking has not been initialized or service returned error response, reinitialize and trigger new scan (Adopt if needed)
 +
        ELSEIF(PHO_ERR_CODE = PHO_NOT_INITIALIZED) THEN
 +
                 
 +
            pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;
 +
            pho_request_scan;
 +
       
 +
        ! If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed)   
 +
        ELSEIF (PHO_ERR_CODE = PHO_SERVICE_ERR ) THEN
 +
   
 +
        Waittime 10;
 +
        pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;
 +
        pho_request_scan;
 +
       
 +
        ! In case of communication failure, rapid program is terminated immediatelly
 +
        ELSEIF (PHO_ERR_CODE = PHO_BAD_DATA OR PHO_ERR_CODE = PHO_TIMEOUT OR PHO_ERR_CODE = PHO_COM_FAILURE ) THEN
 +
            ErrLog 4800, "Photoneo internal error", "Communication failure!", "Please reboot the Vision controller"," "," ";
 +
            EXIT;
 +
   
 +
        ! Otherwise trigger next scan and try to continue
 +
        ELSE
 +
            pho_request_scan;
 +
        ENDIF
 +
   
 +
        err_counter := err_counter + 1;
 +
        ! reset error flag for next cycle
 +
        PHO_OCCURRED_ERR := FALSE;
 +
         
 +
    ENDPROC
  
 +
=== 4.5 Placing ===
 +
 +
For the purpose of orientated placing you can use information about picked object stored in following
 +
variables:
 +
 +
'''pho_tool_point_invariance''' - Tool invariance ID.
 +
'''pho_gripping_point_id ''' - Gripping point ID.
 +
'''pho_gripping_point_invariance ''' - Gripping point invariance ID.
 +
 +
=== 4.6 Vision System ID ===
 +
 +
Some requests need an argument '''vision_system_id''' that defines selected vision system. Provided value
 +
must be the same as the ID of wanted vision system in Binpicking Studio. Studio starts indexing the vision
 +
systems from 1, but you can choose your preferred ID.
 +
 +
[[File: VS page 8ClVplw.png|frame|none|alt=Alt text| Figure 4.1]]
 +
 +
In the following example we demonstrate basic usage of the main requests when using multiple vision
 +
systems.
 +
 +
''NOTE: You can define different start/end pose for each vision system''
 +
 +
 +
  !send bin picking initialization request to the Vision Controller (first vision system
 +
  pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget, 1;
 +
  !
 +
  !send bin picking initialization request to the Vision Controller (second vision system
 +
  pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget, 2;
 +
  !
 +
  !call scan request to start localization for first vision system
 +
  pho_request_scan 1;
 +
  !
 +
  !wait for scan completition
 +
  pho_wait_for_scan_completion;
 +
  !
 +
  !call trajectory request and move to start pose
 +
  pho_request_trajectory 1;
 +
  MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;
 +
  !
 +
  !receive trajectory and execute picking procedure
 +
  pho_receive_trajectory;
 +
  pho_bin_picking;
 +
  !
 +
 +
In next cycle you can call scan and trajectory requests for the second vision system or adapt program that
 +
better suits your needs.
  
 
== 5. Runtime ==
 
== 5. Runtime ==
  
 +
Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:
 +
 +
 +
[[File: waiting_for_server_2.png|frame|none|alt=Alt text| Figure 5.1]]
 +
 +
 +
Make sure that your solution on the Deployment page of Binpicking Studio is running and '''Binpicking Status''' is in '''Waiting for a connection''' state as shown in the figure below:
 +
 +
 +
[[File: ABB tutorial runtime waiting small.png|frame|none|alt=Alt text| Figure 5.2]]
 +
 +
 +
Open Main Menu, browse to '''Production Window''' and '''Set PP to Main''' - at the beginning of the main function:
 +
 +
 +
[[File: pp_to_main_2.png|frame|none|alt=Alt text| Figure 5.3]]
 +
 +
 +
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required:
 +
 +
 +
[[File: override_vel_2.png|frame|none|alt=Alt text| Figure 5.4]]
 +
 +
 +
Hit the '''Play''' button in AUTO mode or '''Enable + Play''' button in MANUAL mode and you should see the following application output:
  
  
 +
[[File: binpicking_connected.png|frame|none|alt=Alt text| Figure 5.5]]
  
  
TO EDIT:
+
You should notice that '''Binpicking Status''' has changed to the '''Connected''' state. It means that the Vision Controller has established a successful connection to the robot controller:
  
=== Appendix - Configuration of I/O ===
 
  
==== A.1 Preparation ====
+
[[File: ABB tutorial runtime running.png|frame|none|alt=Alt text| Figure 5.6]]
Finalize cabling (tall box on palette with controller), specifically '''XP1, XP13, XP2''' to the bottom side of controller, with their respective connectors on the base of robot.
 
  
==== A.2 Setting up I/O ====
 
Various links are accessible on panel inside cabinet. These signals are wired throught '''XS/XP13''' connector underneath the cabinet, throught connection in base of robot to '''R1(2).CP''' and '''R1(2).CS'''. '''XT6/6.1''' signals 1 to 4 are usually used to power your device (4x1mm2) with link to '''R1(2).CP''' and connectors '''XT5.1, XT5.2''' and '''XT5.3''' are used to provide signals for your accessories carried by robot with link to '''R1(2).CS'''.
 
  
==== A.3 Accessing signals in program ====
+
The robot should now start sending requests to the Vision Controller and execute bin picking movements.
Usually an I/O slave is included in robotic controller. If not install one inside cabinet and in '''Configuration - I/O System''' tab. Once completed a list of device’s '''Inputs/Outputs''' may appear in '''Signals''' tab. Configure them according to their specific purpose. A example of signal configuration is shown below:
 
  
[[File:Signals_tab_robot_studio.PNG]]
+
'''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.'''

Latest revision as of 09:36, 7 May 2019

NOTE: Users are strongly recommended to read the general introduction to robot interfaces prior to installing specific robot modules.

1. Prerequisities

Photoneo ABB Interface is compatible with RobotWareOS versions 5.13 and higher.

In addition to compatible system version, the following conditions must also be met:

- (616-6) PC Interface Module available

- (672-1) Multitasking Module available

Go to System Info -> System Properties -> Control Module -> Options to check if these options are available within your system:

Alt text
Figure 1.1


NOTE: Use of Robot Studio v.6.06 or higher is highly recommended for Photoneo ABB Interface setup.

2. ABB Controller setup

The following tutorial gives a step by step guide of how to configure your ABB IRC5 controller and install all necessary RAPID files you will need to get the robot interface for Photoneo Binpicking Studio up and running.

This tutorial was originally written using the latest RobotWare v.6.06, however it should be compatible with older versions with minor changes.

2.1 Network configuration

NOTE: The network configuration procedure described below only works with RobotWareOS v.6 or higher. If you have an older version of RobotWareOS and need to change an IP address, please contact local ABB support.

Turn on the IRC5 Controller, wait for the Initialization Screen to appear, open the Menu screen and select the Control Panel option:


Alt text
Figure 2.1


In the Control Panel pane, select Controller Settings:


Alt text
Figure 2.2


Select Settings and choose the Network option:


Alt text
Figure 2.3


The Network Settings window should now appear. Use the Touch Panel Keypad to set the IP address of the IRC5 WAN port:


Alt text
Figure 2.4


Choose OK button and restart the Controller to apply the new settings:


Alt text
Figure 2.5


3 Robot Studio Setup

3.1 Connect to IRC5 Controller from Robot Studio

Set your local PC network settings to DHCP, plug an Ethernet cable into the Service Port of the IRC5 Controller and launch Robot Studio.

For a direct connection to the Robot Controller, select the Controller tab and select the One Click Connect option:


Alt text
Figure 3.1.1

3.2 Transfer RAPID files

The first step in the installation of Photoneo ABB Interface is to copy the RAPID files from Photoneo ABB Module Archive which you received with Photoneo BP Studio to the Robot Controller.

You can copy the files directly from the USB stick using the Pendant, however the most convenient method to transfer the RAPID files is to use the Robot Studio File Transfer tool.

Go to the Controller tab and select the File Transfer tool from the menu:


Alt text
Figure 3.2.1


The Photoneo ABB Interface consists of four RAPID files:

- MainModule.mod

- CustomerDefinitions.mod

- PhotoneoStateServer.mod

- PhotoneoCommon.sys

All of these files need to be transferred to the HOME:/Photoneo/ folder created within the Robot Controller file system as is shown in the figure below:


Alt text
Figure 3.2.2


3.3 Create State Server Task

In order to ensure the full functionality of the State Server, open PhotoneoStateServer.mod and check that the robot_task_id and pho_state_server_port variables are valid with respect to your system configuration.

(For example, multi axes systems use T_ROB1 and T_ROB2 tasks; your network configuration might prevent using port 11005 etc). If you are not comfortable about making these changes to your system, please stick to the default values.


Alt text
Figure 3.3.1


The next step in the setup is to create State Server Task. Select the Request Write Access option on the Controller tab in Robot Studio and the Grant Access option on the Pendant:


Alt text
Figure 3.3.2


The State Server Task which runs in the background and will report the current state of the robot to the Vision Controller.

On the Left pane, select the Controller option, right click on the Task item in the list and select New Task...:


Alt text
Figure 3.3.3


The following dialogue should appear. Change the settings to those shown in the figure below:

(String to Copy & Paste: Task: PHO_STATE_SERVER, Main Entry: pho_state_server_main)


Alt text
Figure 3.3.4

3.4 Automatic Loading of Modules

Now we need to configure the ABB system to automatically load StateServer.mod during the boot.

Right Click on Automatic Loading of Modules and select New Automatic Loading of Modules as shown in the figure below:


Alt text
Figure 3.4.1


Configure the module for PhotoneoState Server.mod as is shown in the figure below:

(String to Copy & Paste: File: HOME://Photoneo/PhotoneoStateServer.mod)


Alt text
Figure 3.4.2


Repeat the same procedure for PhotoneoCommon.sys as a system module:

(String to Copy & Paste: File: HOME://Photoneo/PhotoneoCommon.sys)


Alt text
Figure 3.4.3


Also repeat the same procedure for CustomerDefinitions.mod containing user settings:

(String to Copy & Paste: File: HOME://Photoneo/CustomerDefinitions.mod)


Alt text
Figure 3.4.3

3.5 Load Main Module

We are now ready to manually load MainModule.mod to T_ROB1 task. You can load the MainModule.mod file from your PC or directly from the Controller.

Right Click on T_ROB1 task and select Load Module or Load Module From Controller:


Alt text
Figure 3.5.1


Installation of the Photoneo ABB Interface is now complete. Your RAPID left panel should now look like this. Restart the Controller to apply all configuration changes:


Alt text
Figure 3.5.2


At this point your Robot Controller is configured to work with Photoneo Binpicking Studio. However your RAPID code must be adopted to meet your application requirements - you need to reteach HOME, START and END poses, update part placing, application logic, etc. The following section of the tutorial provides basic examples of how this can be programmed as well as a detailed explanation of Photoneo RAPID API.

4. RAPID

Photoneo ABB interface was designed to be easily integrated into existing application written in RAPID code. It provides two means which influence the final robot behavior:

- RAPID API - set of RAPID requests (or procedures) used to control the bin picking sequence. Requests are defined in PhotoneoCommon module and used within MainModule

- RAPID CONFIG - CustomerDefinitions.mod holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition.

4.1 RAPID API

Module PhotoneoCommon.sys contains API calls (requests) provided by Photoneo ABB Interface. These requests are intended for high level control of bin picking sequences and are usually called in module MainModule.mod.


pho_request_init(jointtarget pho_start_bin_picking_pose, jointtarget pho_end_bin_picking_pose) - request to initialize binpicking application from the Vision Controller side. Start and End Poses defined by the operator from the RAPID side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points.

pho_wait_for_server((string server_ip, \num port_number, \num wait_time, \switch sys_stop | switch sys_restart) - function to establish a connection to the Vision Controller. Blocking function; suspends the program until a proper connection is established. If the server running on the Vision Controller side is not running or does not respond, an error is raised and the RAPID program is terminated. We recommend ommiting optional parameter port_number (default value will be used). If you need to use specific port value please contact support@photoneo.com to help you with configuring port in Binpicking Studio.

pho_request_scan(num vision_system_id) - request to trigger the next scan and localization. Nonblocking request; the RAPID program continues immediately at the next line.

pho_wait_for_scan_completition(\num wait_time) - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately.

pho_request_trajectory(num vision_system_id) - request to start trajectory planning for current goal. Non-blocking function; the RAPID program continues immediately at the next line.

pho_receive_trajectory(\num wait_time) - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside pho_bin_picking() function by default. Blocking function; waits for motion data to be received.

pho_request_calib_start (num vision_system_id) - request to start calibration. Currently unsupported. Prepared for future use.

pho_request_calib_add_point() - request to add calibration point - a scan is triggered and the calibration is recalculated. Blocking request; the program will not continue until the calibration result is recalculated and has been received by the Robot Controller. Currently unsupported. Prepared for future use.

pho_request_calib_set() - request to set current calibration result to the PhoXi Scanner. Currently unsupported. Prepared for future use.

pho_request_calib_reset() - request to reset current calibration and remove all previously added points. Currently unsupported. Prepared for future use.

pho_other_req (num data{*}, num size, num vision_system_id) - request used to send additional data to Vision Controller.


pho_request_bin_locator (num vision_system_id) - request to start localization of the bin containing parts to be picked. Bin CAD model position is adjusted in environment. Currently unsupported. Prepared for future use.

pho_request_send_pick_failed (num vision_system_id) - notify Vision Controller about failed pick to lower preference of the part during object-to-pick selection process.

pho_request_change_solution (num solution_id) - request to change deployed solution. Currently unsupported. Prepared for future use.


4.2 RAPID CONFIG

CustomerDefinitions module enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments.


- gripper_attach() - implement function for attaching object to the gripper here

- gripper_detach() - implement function for detaching object from gripper here

- gripper_user_1() - implement custom user gripper command (reserved for future use)

- gripper_user_2() - implement custom user gripper command (reserved for future use)

- gripper_user_3() - implement custom user gripper command (reserved for future use)

- gripper_user_4() - implement custom user gripper command (reserved for future use)

- gripper_user_5() - implement custom user gripper command (reserved for future use)

- gripper_user_6() - implement custom user gripper command (reserved for future use)

- binpicking_settings() - specify speed and precision settings for bin picking trajectories. Adopt the suitable number of trajectories to meet your bin picking setup. (the default setting is 4 trajectories)

- pho_bin_picking_simple() - a very basic bin picking sequence (for experimental purposes)

- pho_bin_picking() - executes standard bin picking sequence which consist of various number of operations to be performed. Blocking function; the program does not continue until the whole sequence has finished. Always make sure that the robot is in start_bin_picking_jointtarget before calling this function (DO NOT EDIT!)


4.3 RAPID ERROR HANDLING

Photoneo ABB interface provides basic error handling. If an error occurs during bin picking operations, the PHO_OCCURED_ERR flag is set to true. The PHO_ERR_CODE variable contains the code of the specific error which will helps to identify the source of the problem.

PHO_NO_ERR := 0 - Service response from Vision Controller is valid

PHO_SERVICE_ERR := 1 - Service response from Vision Controller is invalid.

PHO_UNKNOWN_REQ := 2 - The Vision Controller received an unknown request.

PHO_COM_FAILURE := 3 - Communication failure due to socket closure.

PHO_BAD_DATA := 4 - Data validation check has failed.

PHO_TIMEOUT := 5 - Communication failure due to socket timeout.

PHO_UNKNOWN_ERR := 99 - Unspecified internal error

PHO_PLANNING_FAILED := 201 - Trajectory planning has failed

PHO_NO_PART_FOUND := 202 - No part has been localized

PHO_NOT_INITIALIZED := 203 - Bin picking application has not been properly initialized on Vision Controller

PHO_PART_LOST := 204 - Part has been lost during motion execution

PHO_COLLISION_DETECT := 205 - Collision has been detected.Available only when using non-standard module CollisionDetect.mod

PHO_WRONG_BP_CONFIG := 255 - Wrong Binpicking configuration. For more details see Binpicking Studio console on Deployment Page

4.4 MAIN MODULE

The following section provides a detailed explanation of MainModule.mod - the module through which the user's application and Photoneo Bin Picking API are integrated together.

NOTE: If you use a pre-generated program from Robot Studio simulation do not use MainModule.mod directly. The following description serves only as an example of how to use Photoneo RAPID API.

4.4.1 main()

The main() procedure is simply a selection of which particular sub-procedure is about to be executed. Comment bin_picking if you want to execute calibration comment calibration line if you want to execute bin picking. (NOTE: Calibration is currently unavailable).


   MODULE MainModule
 
   ! Copyright (c) 2018 Photoneo s.r.o.
   ! All rights reserved
   ! Description: Main bin picking module
   !
   ! Home, start and end binpicking target variables
   VAR robtarget home_pose;
   VAR robtarget start_bin_picking_robtarget;
   VAR robtarget end_bin_picking_robtarget;
   VAR jointtarget start_bin_picking_jointtarget;
   VAR jointtarget end_bin_picking_jointtarget;

   ! Error handling variables
   VAR num err_counter;
   CONST num MAX_ERR_COUNT := 2;
   
   PROC main()
  
      !calibration;   ! If bin picking is about to be executed comment this line
      bin_picking;    ! If calibration is about to be executed comment this line
   
  ENDPROC

4.4.2 bin_picking()

This is a basic bin picking template. The main program loop is defined here. The user is can reteach bin picking start and end positions, set IP Address and Port of Vision Controller and adopt the placing part of the code to meet specific workcell and application requirements here.

    !                                         BIN PICKING
    ! This is a basic bin picking template. The main program loop is defined here. User is expected to reteach 
    ! bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part
    ! of the code to meet specific workcell and application requirements here. 
    !
    PROC bin_picking()
   
    ! Clear error counter for err_handling procedure
    err_counter := 0;
    
    PHO_ERR_CODE := PHO_PLANNING_FAILED;
    !	
    ! RETEACH home position for your application
    home_pose := [[99999.0, 99999.0, 99999.0],[0, 0, 0, 1],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    !
    ! RETEACH bin picking start and end pose
    start_bin_picking_robtarget := [[99999.0, 99999.0, 99999.0],[0, 0, 0, 1],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    end_bin_picking_robtarget := [[99999.0, 99999.0, 99999.0],[0, 0, 0, 1],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    !
    ! Convert cartesian position to jointtarget
    start_bin_picking_jointtarget := CalcJointT(start_bin_picking_robtarget, tool0);
    end_bin_picking_jointtarget := CalcJointT(end_bin_picking_robtarget, tool0);
    !
    ! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed 
    pho_wait_for_server "192.168.1.6", 11004 ;
    !     
    ! Send bin picking initialization request to the Vision Controller, 
    ! start and end poses defined above will be used in trajectory planning pipeline
    pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;
    !   
    ! Move robot away from scanning area - reteach this position for your robot and workcell
    MoveJ home_pose, v500, z30, tool0;
    ! 
    ! When robot is away from scanning area, trigger first scan and localization
    pho_request_scan;
    !
    WHILE true DO
        scan_again:		
        !==================== PHOTONEO BIN PICKING START ===========================
        ! Wait until scanning is completed
        pho_wait_for_scan_completion;
        !
        ! Handle errors if occured
        IF (PHO_OCCURRED_ERR = TRUE) THEN             
            err_handling;
            GOTO scan_again;
        ENDIF   
        !
        ! Trigger trajectory planning
        pho_request_trajectory;
        !
        ! While trajectory is being calculated, move robot to bin picking start position
        MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;
        !
        ! Execute bin picking application, calculated trajectory is received here
        pho_bin_picking;      
        !==================== PHOTONEO BIN PICKING END ===========================
        !
        ! Handle errors if occured
        IF (PHO_OCCURRED_ERR = TRUE) THEN             
            err_handling;
            GOTO scan_again;
        ELSE   
            ! Clear error counter for err_handling procedure
            err_counter := 0;
            !
            !==================== PLACING START==================================
            ! Move robot from bin picking end position away from scanning area - reteach this position for your robot and workcell
            ! MoveJ [[171.40,-618.92,669.19],[9.66315E-05,-0.862481,-0.50609,-2.74185E-05],[-1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v500, z30, tool0;
            !
            ! Triger next scan and localization, trajectory for next cycle is calculated while object is being placed 
            pho_request_scan;
            !
            ! Commands for actual part placing - reteach positions for your robot and workcell
            ! MoveJ [[171.40,-618.92,669.19],[9.66315E-05,-0.862481,-0.50609,-2.74185E-05],[-1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v500, z30, tool0;
            ! open_gripper;
            ! MoveJ [[171.40,-618.92,669.19],[9.66315E-05,-0.862481,-0.50609,-2.74185E-05],[-1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v500, z30, tool0;          
            !==================== PLACING END===================================  
        ENDIF        
      ENDWHILE   
    ENDPROC


4.4.3 calibration()

NOTE: This feature is currently unavailable.

This procedure is used when you need to perform calibration from robot controller. Please note that recommended way of calibration is using Binpicking studio calibration wizard. To execute the calibration comment out bin_picking task in procedure main() inside MainModule.mod and uncomment task calibration. Revert the changes after finishing calibration.


Reteach calibration positions and call pho_request_calib_add_point() requests after reaching each calibration pose. Users are recommended to run calibration in MANUAL mode in order to have full control over the process. Always make sure that the robot does not collide with the workcell during transitions between specific waypoints.

   !                                         CALIBRATION
   ! Reteach calibration positions and call add calibration point request after reaching each calibration pose
   ! It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. 
   ! Always make sure that robot does not collide with workcell during transitions between specific waypoints
   PROC calibration()
   
       ! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed 
       pho_wait_for_server "192.168.1.6", 11004;
       !   
       ! 1. calibration waypoint 
       MoveJ [[726.48,-170.77,397.89],[0.100326,-0.586168,0.431152,-0.678565],[-1,0,-2,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v100, fine, tool0;
       pho_request_calib_add_point;
       ! 
       ! 2. calibration waypoint
       MoveJ [[784.48,103.21,289.54],[0.015591,-0.569148,0.439403,-0.694804],[0,0,-2,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v100, fine, tool0;
       pho_request_calib_add_point;
       !
       ! 3. calibration waypoint
       MoveJ [[612.57,314.22,592.92],[0.191405,-0.613209,0.508347,-0.573517],[0,0,-2,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v100, fine, tool0;
       pho_request_calib_add_point;
       !
       ! 4. calibration waypoint
       MoveJ [[1007.35,-482.44,270.24],[0.566579,-0.514948,0.502784,0.40128],[-1,0,-2,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v100, fine, tool0;
       pho_request_calib_add_point;
       !
       ! 5. calibration waypoint
       MoveJ [[975.17,-513.44,199.63],[0.615751,-0.53949,0.418442,0.393329],[-1,0,-2,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v100, fine, tool0;
       pho_request_calib_add_point;
       !
       ! 6. calibration waypoint
       MoveJ [[813.58,-34.08,404.19],[0.317364,-0.830642,0.138416,-0.436068],[-1,1,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], v100, fine, tool0;
       pho_request_calib_add_point;
       !
       ! Finally set calibration result to the PhoXi Scanner
       TPWrite "Setting calibration result to the PhoXi Scanner!";
       pho_request_calib_set;  
       TPWrite "Calibration complete!";
       EXIT;
   
   ENDPROC

4.4.4 err_handling()

Several error situations might occur during bin picking procedures. Some problems are more serious, some less. For example, if no part is found or the trajectory planning fails, the program simply attempts to repeat the whole sequence. However, if a communication failure is detected, the program is halted immediately. PHO_ERR_CODE contains the error state from the last response from the Vision Controller.

   !                                         ERROR HANDLING
   ! Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.
   ! For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if 
   ! communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed
   PROC err_handling()
   
       !--Release gripper if needed
       !open_gripper;
   
       ! Move robot to home pose
       MoveJ home_pose, v500, z30, tool0;
   
       !--Display error
       TPWrite pho_err_info(PHO_ERR_CODE);
   
       IF err_counter >= MAX_ERR_COUNT THEN
           ErrLog 4800, "Photoneo internal error", pho_err_info(PHO_ERR_CODE), "Please reboot the Vision controller and restart application"," ", " ";
           EXIT;
       ENDIF
   
       ! If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)
       IF (PHO_ERR_CODE = PHO_PLANNING_FAILED OR PHO_ERR_CODE = PHO_NO_PART_FOUND) THEN        
           TPWrite "NO PART FOUND OR PLANNING PATH FAILED";
           pho_request_scan;
   
       ! If bin picking has not been initialized or service returned error response, reinitialize and trigger new scan (Adopt if needed)
       ELSEIF(PHO_ERR_CODE = PHO_NOT_INITIALIZED) THEN
                 
           pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;
           pho_request_scan;
        
       ! If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed)     
       ELSEIF (PHO_ERR_CODE = PHO_SERVICE_ERR ) THEN
   
       Waittime 10;
       pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;
       pho_request_scan;
        
       ! In case of communication failure, rapid program is terminated immediatelly
       ELSEIF (PHO_ERR_CODE = PHO_BAD_DATA OR PHO_ERR_CODE = PHO_TIMEOUT OR PHO_ERR_CODE = PHO_COM_FAILURE ) THEN
           ErrLog 4800, "Photoneo internal error", "Communication failure!", "Please reboot the Vision controller"," "," ";
           EXIT;
   
       ! Otherwise trigger next scan and try to continue
       ELSE
           pho_request_scan;
       ENDIF
   
       err_counter := err_counter + 1;
       ! reset error flag for next cycle
       PHO_OCCURRED_ERR := FALSE;
          
   ENDPROC

4.5 Placing

For the purpose of orientated placing you can use information about picked object stored in following variables:

pho_tool_point_invariance - Tool invariance ID. pho_gripping_point_id - Gripping point ID. pho_gripping_point_invariance - Gripping point invariance ID.

4.6 Vision System ID

Some requests need an argument vision_system_id that defines selected vision system. Provided value must be the same as the ID of wanted vision system in Binpicking Studio. Studio starts indexing the vision systems from 1, but you can choose your preferred ID.

Alt text
Figure 4.1

In the following example we demonstrate basic usage of the main requests when using multiple vision systems.

NOTE: You can define different start/end pose for each vision system


  !send bin picking initialization request to the Vision Controller (first vision system
  pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget, 1;
  !
  !send bin picking initialization request to the Vision Controller (second vision system
  pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget, 2;
  !
  !call scan request to start localization for first vision system
  pho_request_scan 1;
  !
  !wait for scan completition
  pho_wait_for_scan_completion;
  !
  !call trajectory request and move to start pose
  pho_request_trajectory 1;
  MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;
  !
  !receive trajectory and execute picking procedure
  pho_receive_trajectory;
  pho_bin_picking;
  !

In next cycle you can call scan and trajectory requests for the second vision system or adapt program that better suits your needs.

5. Runtime

Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:


Alt text
Figure 5.1


Make sure that your solution on the Deployment page of Binpicking Studio is running and Binpicking Status is in Waiting for a connection state as shown in the figure below:


Alt text
Figure 5.2


Open Main Menu, browse to Production Window and Set PP to Main - at the beginning of the main function:


Alt text
Figure 5.3


Choose if you want to run the application in AUTO or MANUAL mode and adopt the speed override if required:


Alt text
Figure 5.4


Hit the Play button in AUTO mode or Enable + Play button in MANUAL mode and you should see the following application output:


Alt text
Figure 5.5


You should notice that Binpicking Status has changed to the Connected state. It means that the Vision Controller has established a successful connection to the robot controller:


Alt text
Figure 5.6


The robot should now start sending requests to the Vision Controller and execute bin picking movements.

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.