Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with ABB robots

From 3D scanning Knowledge base - Photoneo wiki
Revision as of 12:13, 8 June 2018 by Durovsky (talk | contribs)

Jump to: navigation, search

NOTE: It is highly recommended to read 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:

Pendant options check.png


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:


ABB pendant menu RW6.png


In the Control Panel pane, select Controller Settings:


ABB pendant control panel.png


Select Settings and choose the Network option:


ABB pendant network.png


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


ABB pendant IP setup.png


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


ABB pendant restart.png


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:


Robot studio connect.png

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:


Robot studio file transfer.png


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:


Robot studio file transfer 2.png


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.


Robot studio state server config2.png


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:


ABB pendant grant access.png


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


Robot Studio Task Definition 2.png


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)


Robot studio task settings 3.png

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:


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)


Robot studio state server automatic loading.png

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

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


Robot studio pho common.png


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

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


Robot studio customer definitions.png

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:


Robot studio load module.png


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:


Robot studio final panel2.png


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

The following API describes the functionality of requests provided by Photoneo ABB Interface. These requests are intended for high level control of bin picking sequences and are usually called in MainModule.mod.


pho_request_init(jointtarget pho_start_bin_picking_pose, jointtarget pho_end_bin_piking_pose) - request to initialize bin picking 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 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.

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

pho_wait_for_scan_completition() - 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; the RAPID program continues immediately at the next line.

pho_receive_trajectory() - 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 specific actions and call them accordingly (pho_request_scan & pho_request_trajectory).

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.

pho_calib_set() - request to set current calibration result to the PhoXi Scanner

pho_calib_reset() - request to reset current calibration and remove all previously added points

pho_bin_picking() - request to execute bin picking operation. This usually receives the requested trajectory and performs motion execution. Blocking function; the program does not continue until the whole sequence is finished. Always make sure that the robot is in pho_start_bin_picking_pose before calling this function.


4.2 RAPID CONFIG

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

- close_gripper() - implement function for closing your 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() - standard bin picking sequence. This flexible, operation-based implementation allows performing bin picking sequences, which consist of various numbers of operations to be performed. 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_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

PHO_UNKNOWN_ERR := 299 - Unspecified internal error


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.


   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()

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

5. Runtime

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


Waiting for server 2.png


Make sure that the Bin Picking application on the Vision Controller side is running and Binpicking Status is in Waiting for a connection state:


ABB tutorial runtime waiting small.png


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


Pp to main 2.png


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


Override vel 2.png


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


Binpicking connected.png


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


ABB tutorial runtime running.png


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

NOTE: Make sure that you are ready to halt motion execution immediately. It is highly recommended to decrease the speed to 10% of maximum during initial bin picking tests.