http://wiki.photoneo.com/api.php?action=feedcontributions&user=Michald&feedformat=atom3D scanning Knowledge base - Photoneo wiki - User contributions [en]2024-03-29T13:42:06ZUser contributionsMediaWiki 1.27.0http://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=1433Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-11-28T11:37:25Z<p>Michald: /* 4.1 VAL3 API */</p>
<hr />
<div>'''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.'''<br />
<br />
== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial provides a step by step guide of how to configure your Stäubli CS9 controller and install the VAL3 files you will need to get the robot interface for Photoneo Bin Picking Studio up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
The first step of the setup is to configure the network interface. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png|frame|none|alt=Alt text| Figure 2.1.1]]<br />
<br />
<br />
As you can see in the figure below, two network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between the Staubli Robotics Suite and the robot controller.<br />
<br />
Input the J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png|frame|none|alt=Alt text| Figure 2.1.2]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
It is now time to launch Staubli Robotics Suite and start the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on the '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purposes of this tutorial we will use a '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png|frame|none|alt=Alt text| Figure 3.1.1]]<br />
<br />
<br />
If you are already connected to a real robot controller select '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png|frame|none|alt=Alt text| Figure 3.1.2]]<br />
<br />
<br />
In order to select a controller from the available targets, click the '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.1.3]]<br />
<br />
<br />
In the '''General Information''' section type input the '''J205 IP address''' of the robot controller.<br />
<br />
The Remote Connection section contains authorization information. Input the following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' and if everything works properly you should see the following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png|frame|none|alt=Alt text| Figure 3.1.4]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection has been established properly, you are ready to copy the VAL3 files containing the Photoneo Staubli interface to your project. <br />
<br />
The Photoneo Staubli interface consists of three folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from the Photoneo Staubli Module archive (.zip file) which you received with Photoneo Bin Picking Studio to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add the existing applications to the project.<br />
<br />
Expand '''Project_name''', right click on '''Controller_name''', select '''Open Application''' and load all three applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png|frame|none|alt=Alt text| Figure 3.2.1]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png|frame|none|alt=Alt text| Figure 3.2.2]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
The Cartesian origin of Staubli robots '''is different''' than the Cartesian origin of robot models used in the Photoneo Bin Picking Studio. In order to ensure successful calibration, an additional frame with a predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to the Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit the Z axis value according to the arm you are using for your application.<br />
<br />
<br />
[[File:fBaseLink.png|frame|none|alt=Alt text| Figure 3.3.1]]<br />
<br />
<br />
A table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png|frame|none|alt=Alt text| Figure 3.3.2]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
In order to ensure proper communication with the Vision Controller, two sockets (one server and one client) need to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's'''. In the IO table, right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png|frame|none|alt=Alt text| Figure 3.4.1]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and the vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.2]]<br />
<br />
<br />
Use the following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
<br />
'''Port:''' 11003<br />
<br />
'''Description:''' Photoneo Bin Picking Client<br />
<br />
'''Timeout:''' 3000<br />
<br />
'''End of String:''' 10<br />
<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Bin Picking Studio<br />
<br />
Click '''OK''' to apply the changes<br />
<br />
<br />
[[File:staubli_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
<br />
Now add '''Tcp_server''' with the following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
Click '''OK''' to apply the changes <br />
<br />
<br />
[[File:staubli_tcp_server.png|frame|none|alt=Alt text| Figure 3.4.4]]<br />
<br />
<br />
We now need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to the Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select the '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
You should now see that both variables are linked to physical IOs as is shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png|frame|none|alt=Alt text| Figure 3.4.5]]<br />
<br />
<br />
The initial steps of the SRS project configuration are now complete. '''Save the cell''' and you are ready to transfer the project files to the robot controller.<br />
<br />
=== 3.5 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.5.1]]<br />
<br />
<br />
If the connection between SRS and the robot controller has been set up properly, a '''transfer manager dialog''' window should now appear. <br />
<br />
We have made changes to the '''IO''' and '''VAL3 Applications''' so confirm that these items are checked before transferring files. <br />
<br />
<br />
[[File:SRS Staubli transfer.png|frame|none|alt=Alt text| Figure 3.5.2]]<br />
<br />
<br />
=== 3.6 Load Application ===<br />
<br />
If the project has been transferred to the robot controller successfully, it has to be loaded using the pendant. In the current version of the system, this is achieved using the "old menu" from the earlier versions of the controller. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png|frame|none|alt=Alt text| Figure 3.6.1]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli application manager.png|frame|none|alt=Alt text| Figure 3.6.2]]<br />
<br />
<br />
Return to the "color menu" by pressing the '''Home''' button. Now open the '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select the '''"V"''' letter on the widget as is shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png|frame|none|alt=Alt text| Figure 3.6.3]]<br />
<br />
<br />
You should see that '''main_application''' is now available in the application list. <br />
<br />
As a final step, we need to set main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png|frame|none|alt=Alt text| Figure 3.6.4]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Bin Picking Studio. However you should adapt the VAL3 code to meet the precise requirements of your application. This may involve '''reteaching HOME, START and END poses''', updating part placing or application logic, etc. The following section of the tutorial provides some basic examples of how this can be programmed as well as a detailed explanation of the Photoneo VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Staubli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init(joint x_jStartPose, joint x_jEndPose)''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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.<br />
<br />
''' bin_localization_request()''' - Only prepared for future<br />
<br />
''' set_request_timeout(num x_nTimeout)''' - Set a timeout to a request. This procedure should be call before calling of request. If timeout is reached, then will set error variable photoneo_common:nErrCode as photoneo:nERR_TIMEOUT.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for attaching object to gripper here <br />
<br />
- '''griper_detach()''' - implement function for detaching object to gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Bin Picking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png|frame|none|alt=Alt text| Figure 4.2.1]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo Bin Picking Studio provides basic error handling. If an error occurs during bin picking operations the '''photoneo_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application logic and object placing to meet specific workcell and application requirements.<br />
<br />
begin<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(jStartPose, flange, mNomSpeed)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
endIf <br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
<br />
// ==================== PLACING START==================================<br />
// Implement place procedures<br />
// Print received info data about orientation grasped part. This data you can use for orientation placing<br />
call photoneo_common:printLog("Tool inv id: "+toString("1",photoneo_common:nToolInvID),"CLIENT")<br />
call photoneo_common:printLog("Grip id: "+toString("1",photoneo_common:nGrippingPointID),"CLIENT") <br />
call photoneo_common:printLog("Grip inv id: "+toString("1",photoneo_common:nGrippingPointInvID),"CLIENT")<br />
//=====================================================================<br />
<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, VAL3 program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE or photoneo_common:nErrCode == photoneo_common:nERR_BAD_DATA or photoneo_common:nErrCode == photoneo_common:nERR_TIMEOUT)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
This procedure is useful only if you need make a calibration from robot controller. Better way is used Binpicking studio for calibration.<br />
<br />
In main_application in procedure '''start()''' comment '''PHOMAIN''' task in order to execute calibration procedure and uncomment '''PHOCALIB'''. If you will finish, then return back changes<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints. <br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send request to starting calibration<br />
call photoneo_common:calib_start_request()<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
Explore the calibration request:<br />
<br />
'''calib_start_request()''' - request to start calibration<br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during bin picking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
=== 4.5 Placing ===<br />
<br />
For orientation placing you can use information about grasped object. The informations are included in variables:<br />
<br />
'''photoneo_common:nToolInvID''' - Tool invariance ID.<br />
<br />
'''photoneo_common:nGrippingPointID''' - Gripping point ID.<br />
<br />
'''photoneo_common:nGrippingPointInvID''' - Gripping point invariance ID.<br />
<br />
=== 4.6 Multiple vision systems ===<br />
<br />
If you are using multiple vision system from Binpicking studio, then must be define vision system, which will be use in request. A vision system is defined in variable '''photoneo_common:nVisionSystemID'''. Before calling a request must be set vision system ID to the variable. Short example how to send initialize request to 2 vision system:<br />
<br />
// Send bin picking initialization request to the Vision Controller (First vision system)<br />
photoneo_common:nVisionSystemID = 0<br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Send bin picking initialization request to the Vision Controller (Second vision system)<br />
photoneo_common:nVisionSystemID = 1<br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the bin picking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection.<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png|frame|none|alt=Alt text| Figure 5.1]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: Staubli tutorial deployment small.png|frame|none|alt=Alt text| Figure 5.2]]<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png|frame|none|alt=Alt text| Figure 5.3]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first bin picking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png|frame|none|alt=Alt text| Figure 5.4]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=1432Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-11-28T11:36:22Z<p>Michald: /* 4.1 VAL3 API */</p>
<hr />
<div>'''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.'''<br />
<br />
== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial provides a step by step guide of how to configure your Stäubli CS9 controller and install the VAL3 files you will need to get the robot interface for Photoneo Bin Picking Studio up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
The first step of the setup is to configure the network interface. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png|frame|none|alt=Alt text| Figure 2.1.1]]<br />
<br />
<br />
As you can see in the figure below, two network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between the Staubli Robotics Suite and the robot controller.<br />
<br />
Input the J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png|frame|none|alt=Alt text| Figure 2.1.2]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
It is now time to launch Staubli Robotics Suite and start the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on the '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purposes of this tutorial we will use a '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png|frame|none|alt=Alt text| Figure 3.1.1]]<br />
<br />
<br />
If you are already connected to a real robot controller select '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png|frame|none|alt=Alt text| Figure 3.1.2]]<br />
<br />
<br />
In order to select a controller from the available targets, click the '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.1.3]]<br />
<br />
<br />
In the '''General Information''' section type input the '''J205 IP address''' of the robot controller.<br />
<br />
The Remote Connection section contains authorization information. Input the following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' and if everything works properly you should see the following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png|frame|none|alt=Alt text| Figure 3.1.4]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection has been established properly, you are ready to copy the VAL3 files containing the Photoneo Staubli interface to your project. <br />
<br />
The Photoneo Staubli interface consists of three folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from the Photoneo Staubli Module archive (.zip file) which you received with Photoneo Bin Picking Studio to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add the existing applications to the project.<br />
<br />
Expand '''Project_name''', right click on '''Controller_name''', select '''Open Application''' and load all three applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png|frame|none|alt=Alt text| Figure 3.2.1]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png|frame|none|alt=Alt text| Figure 3.2.2]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
The Cartesian origin of Staubli robots '''is different''' than the Cartesian origin of robot models used in the Photoneo Bin Picking Studio. In order to ensure successful calibration, an additional frame with a predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to the Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit the Z axis value according to the arm you are using for your application.<br />
<br />
<br />
[[File:fBaseLink.png|frame|none|alt=Alt text| Figure 3.3.1]]<br />
<br />
<br />
A table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png|frame|none|alt=Alt text| Figure 3.3.2]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
In order to ensure proper communication with the Vision Controller, two sockets (one server and one client) need to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's'''. In the IO table, right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png|frame|none|alt=Alt text| Figure 3.4.1]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and the vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.2]]<br />
<br />
<br />
Use the following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
<br />
'''Port:''' 11003<br />
<br />
'''Description:''' Photoneo Bin Picking Client<br />
<br />
'''Timeout:''' 3000<br />
<br />
'''End of String:''' 10<br />
<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Bin Picking Studio<br />
<br />
Click '''OK''' to apply the changes<br />
<br />
<br />
[[File:staubli_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
<br />
Now add '''Tcp_server''' with the following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
Click '''OK''' to apply the changes <br />
<br />
<br />
[[File:staubli_tcp_server.png|frame|none|alt=Alt text| Figure 3.4.4]]<br />
<br />
<br />
We now need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to the Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select the '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
You should now see that both variables are linked to physical IOs as is shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png|frame|none|alt=Alt text| Figure 3.4.5]]<br />
<br />
<br />
The initial steps of the SRS project configuration are now complete. '''Save the cell''' and you are ready to transfer the project files to the robot controller.<br />
<br />
=== 3.5 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.5.1]]<br />
<br />
<br />
If the connection between SRS and the robot controller has been set up properly, a '''transfer manager dialog''' window should now appear. <br />
<br />
We have made changes to the '''IO''' and '''VAL3 Applications''' so confirm that these items are checked before transferring files. <br />
<br />
<br />
[[File:SRS Staubli transfer.png|frame|none|alt=Alt text| Figure 3.5.2]]<br />
<br />
<br />
=== 3.6 Load Application ===<br />
<br />
If the project has been transferred to the robot controller successfully, it has to be loaded using the pendant. In the current version of the system, this is achieved using the "old menu" from the earlier versions of the controller. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png|frame|none|alt=Alt text| Figure 3.6.1]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli application manager.png|frame|none|alt=Alt text| Figure 3.6.2]]<br />
<br />
<br />
Return to the "color menu" by pressing the '''Home''' button. Now open the '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select the '''"V"''' letter on the widget as is shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png|frame|none|alt=Alt text| Figure 3.6.3]]<br />
<br />
<br />
You should see that '''main_application''' is now available in the application list. <br />
<br />
As a final step, we need to set main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png|frame|none|alt=Alt text| Figure 3.6.4]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Bin Picking Studio. However you should adapt the VAL3 code to meet the precise requirements of your application. This may involve '''reteaching HOME, START and END poses''', updating part placing or application logic, etc. The following section of the tutorial provides some basic examples of how this can be programmed as well as a detailed explanation of the Photoneo VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Staubli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init(joint x_jStartPose, joint x_jEndPose)''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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.<br />
<br />
''' bin_localization_request()''' - Only prepared for future<br />
<br />
''' set_request_timeout(num x_nTimeout)''' - Set a timeout to a request. This procedure should be call before calling of request. If timeout is reached, then will set error variable '''photoneo_common:nErrCode''' as '''photoneo:nERR_TIMEOUT'''.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for attaching object to gripper here <br />
<br />
- '''griper_detach()''' - implement function for detaching object to gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Bin Picking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png|frame|none|alt=Alt text| Figure 4.2.1]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo Bin Picking Studio provides basic error handling. If an error occurs during bin picking operations the '''photoneo_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application logic and object placing to meet specific workcell and application requirements.<br />
<br />
begin<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(jStartPose, flange, mNomSpeed)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
endIf <br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
<br />
// ==================== PLACING START==================================<br />
// Implement place procedures<br />
// Print received info data about orientation grasped part. This data you can use for orientation placing<br />
call photoneo_common:printLog("Tool inv id: "+toString("1",photoneo_common:nToolInvID),"CLIENT")<br />
call photoneo_common:printLog("Grip id: "+toString("1",photoneo_common:nGrippingPointID),"CLIENT") <br />
call photoneo_common:printLog("Grip inv id: "+toString("1",photoneo_common:nGrippingPointInvID),"CLIENT")<br />
//=====================================================================<br />
<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, VAL3 program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE or photoneo_common:nErrCode == photoneo_common:nERR_BAD_DATA or photoneo_common:nErrCode == photoneo_common:nERR_TIMEOUT)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
This procedure is useful only if you need make a calibration from robot controller. Better way is used Binpicking studio for calibration.<br />
<br />
In main_application in procedure '''start()''' comment '''PHOMAIN''' task in order to execute calibration procedure and uncomment '''PHOCALIB'''. If you will finish, then return back changes<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints. <br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send request to starting calibration<br />
call photoneo_common:calib_start_request()<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
Explore the calibration request:<br />
<br />
'''calib_start_request()''' - request to start calibration<br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during bin picking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
=== 4.5 Placing ===<br />
<br />
For orientation placing you can use information about grasped object. The informations are included in variables:<br />
<br />
'''photoneo_common:nToolInvID''' - Tool invariance ID.<br />
<br />
'''photoneo_common:nGrippingPointID''' - Gripping point ID.<br />
<br />
'''photoneo_common:nGrippingPointInvID''' - Gripping point invariance ID.<br />
<br />
=== 4.6 Multiple vision systems ===<br />
<br />
If you are using multiple vision system from Binpicking studio, then must be define vision system, which will be use in request. A vision system is defined in variable '''photoneo_common:nVisionSystemID'''. Before calling a request must be set vision system ID to the variable. Short example how to send initialize request to 2 vision system:<br />
<br />
// Send bin picking initialization request to the Vision Controller (First vision system)<br />
photoneo_common:nVisionSystemID = 0<br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Send bin picking initialization request to the Vision Controller (Second vision system)<br />
photoneo_common:nVisionSystemID = 1<br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the bin picking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection.<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png|frame|none|alt=Alt text| Figure 5.1]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: Staubli tutorial deployment small.png|frame|none|alt=Alt text| Figure 5.2]]<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png|frame|none|alt=Alt text| Figure 5.3]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first bin picking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png|frame|none|alt=Alt text| Figure 5.4]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=1431Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-11-28T11:30:54Z<p>Michald: /* 4.6 Multiple vision systems */</p>
<hr />
<div>'''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.'''<br />
<br />
== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial provides a step by step guide of how to configure your Stäubli CS9 controller and install the VAL3 files you will need to get the robot interface for Photoneo Bin Picking Studio up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
The first step of the setup is to configure the network interface. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png|frame|none|alt=Alt text| Figure 2.1.1]]<br />
<br />
<br />
As you can see in the figure below, two network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between the Staubli Robotics Suite and the robot controller.<br />
<br />
Input the J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png|frame|none|alt=Alt text| Figure 2.1.2]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
It is now time to launch Staubli Robotics Suite and start the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on the '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purposes of this tutorial we will use a '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png|frame|none|alt=Alt text| Figure 3.1.1]]<br />
<br />
<br />
If you are already connected to a real robot controller select '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png|frame|none|alt=Alt text| Figure 3.1.2]]<br />
<br />
<br />
In order to select a controller from the available targets, click the '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.1.3]]<br />
<br />
<br />
In the '''General Information''' section type input the '''J205 IP address''' of the robot controller.<br />
<br />
The Remote Connection section contains authorization information. Input the following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' and if everything works properly you should see the following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png|frame|none|alt=Alt text| Figure 3.1.4]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection has been established properly, you are ready to copy the VAL3 files containing the Photoneo Staubli interface to your project. <br />
<br />
The Photoneo Staubli interface consists of three folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from the Photoneo Staubli Module archive (.zip file) which you received with Photoneo Bin Picking Studio to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add the existing applications to the project.<br />
<br />
Expand '''Project_name''', right click on '''Controller_name''', select '''Open Application''' and load all three applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png|frame|none|alt=Alt text| Figure 3.2.1]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png|frame|none|alt=Alt text| Figure 3.2.2]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
The Cartesian origin of Staubli robots '''is different''' than the Cartesian origin of robot models used in the Photoneo Bin Picking Studio. In order to ensure successful calibration, an additional frame with a predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to the Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit the Z axis value according to the arm you are using for your application.<br />
<br />
<br />
[[File:fBaseLink.png|frame|none|alt=Alt text| Figure 3.3.1]]<br />
<br />
<br />
A table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png|frame|none|alt=Alt text| Figure 3.3.2]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
In order to ensure proper communication with the Vision Controller, two sockets (one server and one client) need to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's'''. In the IO table, right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png|frame|none|alt=Alt text| Figure 3.4.1]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and the vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.2]]<br />
<br />
<br />
Use the following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
<br />
'''Port:''' 11003<br />
<br />
'''Description:''' Photoneo Bin Picking Client<br />
<br />
'''Timeout:''' 3000<br />
<br />
'''End of String:''' 10<br />
<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Bin Picking Studio<br />
<br />
Click '''OK''' to apply the changes<br />
<br />
<br />
[[File:staubli_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
<br />
Now add '''Tcp_server''' with the following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
Click '''OK''' to apply the changes <br />
<br />
<br />
[[File:staubli_tcp_server.png|frame|none|alt=Alt text| Figure 3.4.4]]<br />
<br />
<br />
We now need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to the Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select the '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
You should now see that both variables are linked to physical IOs as is shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png|frame|none|alt=Alt text| Figure 3.4.5]]<br />
<br />
<br />
The initial steps of the SRS project configuration are now complete. '''Save the cell''' and you are ready to transfer the project files to the robot controller.<br />
<br />
=== 3.5 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.5.1]]<br />
<br />
<br />
If the connection between SRS and the robot controller has been set up properly, a '''transfer manager dialog''' window should now appear. <br />
<br />
We have made changes to the '''IO''' and '''VAL3 Applications''' so confirm that these items are checked before transferring files. <br />
<br />
<br />
[[File:SRS Staubli transfer.png|frame|none|alt=Alt text| Figure 3.5.2]]<br />
<br />
<br />
=== 3.6 Load Application ===<br />
<br />
If the project has been transferred to the robot controller successfully, it has to be loaded using the pendant. In the current version of the system, this is achieved using the "old menu" from the earlier versions of the controller. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png|frame|none|alt=Alt text| Figure 3.6.1]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli application manager.png|frame|none|alt=Alt text| Figure 3.6.2]]<br />
<br />
<br />
Return to the "color menu" by pressing the '''Home''' button. Now open the '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select the '''"V"''' letter on the widget as is shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png|frame|none|alt=Alt text| Figure 3.6.3]]<br />
<br />
<br />
You should see that '''main_application''' is now available in the application list. <br />
<br />
As a final step, we need to set main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png|frame|none|alt=Alt text| Figure 3.6.4]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Bin Picking Studio. However you should adapt the VAL3 code to meet the precise requirements of your application. This may involve '''reteaching HOME, START and END poses''', updating part placing or application logic, etc. The following section of the tutorial provides some basic examples of how this can be programmed as well as a detailed explanation of the Photoneo VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Staubli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init(joint x_jStartPose, joint x_jEndPose)''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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.<br />
<br />
''' bin_localization_request()''' - Only prepared for future<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for attaching object to gripper here <br />
<br />
- '''griper_detach()''' - implement function for detaching object to gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Bin Picking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png|frame|none|alt=Alt text| Figure 4.2.1]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo Bin Picking Studio provides basic error handling. If an error occurs during bin picking operations the '''photoneo_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application logic and object placing to meet specific workcell and application requirements.<br />
<br />
begin<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(jStartPose, flange, mNomSpeed)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
endIf <br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
<br />
// ==================== PLACING START==================================<br />
// Implement place procedures<br />
// Print received info data about orientation grasped part. This data you can use for orientation placing<br />
call photoneo_common:printLog("Tool inv id: "+toString("1",photoneo_common:nToolInvID),"CLIENT")<br />
call photoneo_common:printLog("Grip id: "+toString("1",photoneo_common:nGrippingPointID),"CLIENT") <br />
call photoneo_common:printLog("Grip inv id: "+toString("1",photoneo_common:nGrippingPointInvID),"CLIENT")<br />
//=====================================================================<br />
<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, VAL3 program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE or photoneo_common:nErrCode == photoneo_common:nERR_BAD_DATA or photoneo_common:nErrCode == photoneo_common:nERR_TIMEOUT)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
This procedure is useful only if you need make a calibration from robot controller. Better way is used Binpicking studio for calibration.<br />
<br />
In main_application in procedure '''start()''' comment '''PHOMAIN''' task in order to execute calibration procedure and uncomment '''PHOCALIB'''. If you will finish, then return back changes<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints. <br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send request to starting calibration<br />
call photoneo_common:calib_start_request()<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
Explore the calibration request:<br />
<br />
'''calib_start_request()''' - request to start calibration<br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during bin picking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
=== 4.5 Placing ===<br />
<br />
For orientation placing you can use information about grasped object. The informations are included in variables:<br />
<br />
'''photoneo_common:nToolInvID''' - Tool invariance ID.<br />
<br />
'''photoneo_common:nGrippingPointID''' - Gripping point ID.<br />
<br />
'''photoneo_common:nGrippingPointInvID''' - Gripping point invariance ID.<br />
<br />
=== 4.6 Multiple vision systems ===<br />
<br />
If you are using multiple vision system from Binpicking studio, then must be define vision system, which will be use in request. A vision system is defined in variable '''photoneo_common:nVisionSystemID'''. Before calling a request must be set vision system ID to the variable. Short example how to send initialize request to 2 vision system:<br />
<br />
// Send bin picking initialization request to the Vision Controller (First vision system)<br />
photoneo_common:nVisionSystemID = 0<br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Send bin picking initialization request to the Vision Controller (Second vision system)<br />
photoneo_common:nVisionSystemID = 1<br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the bin picking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection.<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png|frame|none|alt=Alt text| Figure 5.1]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: Staubli tutorial deployment small.png|frame|none|alt=Alt text| Figure 5.2]]<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png|frame|none|alt=Alt text| Figure 5.3]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first bin picking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png|frame|none|alt=Alt text| Figure 5.4]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=1430Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-11-28T11:30:42Z<p>Michald: /* 4.6 Multiple vision systems */</p>
<hr />
<div>'''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.'''<br />
<br />
== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial provides a step by step guide of how to configure your Stäubli CS9 controller and install the VAL3 files you will need to get the robot interface for Photoneo Bin Picking Studio up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
The first step of the setup is to configure the network interface. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png|frame|none|alt=Alt text| Figure 2.1.1]]<br />
<br />
<br />
As you can see in the figure below, two network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between the Staubli Robotics Suite and the robot controller.<br />
<br />
Input the J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png|frame|none|alt=Alt text| Figure 2.1.2]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
It is now time to launch Staubli Robotics Suite and start the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on the '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purposes of this tutorial we will use a '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png|frame|none|alt=Alt text| Figure 3.1.1]]<br />
<br />
<br />
If you are already connected to a real robot controller select '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png|frame|none|alt=Alt text| Figure 3.1.2]]<br />
<br />
<br />
In order to select a controller from the available targets, click the '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.1.3]]<br />
<br />
<br />
In the '''General Information''' section type input the '''J205 IP address''' of the robot controller.<br />
<br />
The Remote Connection section contains authorization information. Input the following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' and if everything works properly you should see the following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png|frame|none|alt=Alt text| Figure 3.1.4]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection has been established properly, you are ready to copy the VAL3 files containing the Photoneo Staubli interface to your project. <br />
<br />
The Photoneo Staubli interface consists of three folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from the Photoneo Staubli Module archive (.zip file) which you received with Photoneo Bin Picking Studio to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add the existing applications to the project.<br />
<br />
Expand '''Project_name''', right click on '''Controller_name''', select '''Open Application''' and load all three applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png|frame|none|alt=Alt text| Figure 3.2.1]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png|frame|none|alt=Alt text| Figure 3.2.2]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
The Cartesian origin of Staubli robots '''is different''' than the Cartesian origin of robot models used in the Photoneo Bin Picking Studio. In order to ensure successful calibration, an additional frame with a predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to the Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit the Z axis value according to the arm you are using for your application.<br />
<br />
<br />
[[File:fBaseLink.png|frame|none|alt=Alt text| Figure 3.3.1]]<br />
<br />
<br />
A table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png|frame|none|alt=Alt text| Figure 3.3.2]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
In order to ensure proper communication with the Vision Controller, two sockets (one server and one client) need to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's'''. In the IO table, right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png|frame|none|alt=Alt text| Figure 3.4.1]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and the vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.2]]<br />
<br />
<br />
Use the following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
<br />
'''Port:''' 11003<br />
<br />
'''Description:''' Photoneo Bin Picking Client<br />
<br />
'''Timeout:''' 3000<br />
<br />
'''End of String:''' 10<br />
<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Bin Picking Studio<br />
<br />
Click '''OK''' to apply the changes<br />
<br />
<br />
[[File:staubli_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
<br />
Now add '''Tcp_server''' with the following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
Click '''OK''' to apply the changes <br />
<br />
<br />
[[File:staubli_tcp_server.png|frame|none|alt=Alt text| Figure 3.4.4]]<br />
<br />
<br />
We now need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to the Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select the '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
You should now see that both variables are linked to physical IOs as is shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png|frame|none|alt=Alt text| Figure 3.4.5]]<br />
<br />
<br />
The initial steps of the SRS project configuration are now complete. '''Save the cell''' and you are ready to transfer the project files to the robot controller.<br />
<br />
=== 3.5 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.5.1]]<br />
<br />
<br />
If the connection between SRS and the robot controller has been set up properly, a '''transfer manager dialog''' window should now appear. <br />
<br />
We have made changes to the '''IO''' and '''VAL3 Applications''' so confirm that these items are checked before transferring files. <br />
<br />
<br />
[[File:SRS Staubli transfer.png|frame|none|alt=Alt text| Figure 3.5.2]]<br />
<br />
<br />
=== 3.6 Load Application ===<br />
<br />
If the project has been transferred to the robot controller successfully, it has to be loaded using the pendant. In the current version of the system, this is achieved using the "old menu" from the earlier versions of the controller. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png|frame|none|alt=Alt text| Figure 3.6.1]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli application manager.png|frame|none|alt=Alt text| Figure 3.6.2]]<br />
<br />
<br />
Return to the "color menu" by pressing the '''Home''' button. Now open the '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select the '''"V"''' letter on the widget as is shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png|frame|none|alt=Alt text| Figure 3.6.3]]<br />
<br />
<br />
You should see that '''main_application''' is now available in the application list. <br />
<br />
As a final step, we need to set main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png|frame|none|alt=Alt text| Figure 3.6.4]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Bin Picking Studio. However you should adapt the VAL3 code to meet the precise requirements of your application. This may involve '''reteaching HOME, START and END poses''', updating part placing or application logic, etc. The following section of the tutorial provides some basic examples of how this can be programmed as well as a detailed explanation of the Photoneo VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Staubli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init(joint x_jStartPose, joint x_jEndPose)''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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.<br />
<br />
''' bin_localization_request()''' - Only prepared for future<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for attaching object to gripper here <br />
<br />
- '''griper_detach()''' - implement function for detaching object to gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Bin Picking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png|frame|none|alt=Alt text| Figure 4.2.1]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo Bin Picking Studio provides basic error handling. If an error occurs during bin picking operations the '''photoneo_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application logic and object placing to meet specific workcell and application requirements.<br />
<br />
begin<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(jStartPose, flange, mNomSpeed)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
endIf <br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
<br />
// ==================== PLACING START==================================<br />
// Implement place procedures<br />
// Print received info data about orientation grasped part. This data you can use for orientation placing<br />
call photoneo_common:printLog("Tool inv id: "+toString("1",photoneo_common:nToolInvID),"CLIENT")<br />
call photoneo_common:printLog("Grip id: "+toString("1",photoneo_common:nGrippingPointID),"CLIENT") <br />
call photoneo_common:printLog("Grip inv id: "+toString("1",photoneo_common:nGrippingPointInvID),"CLIENT")<br />
//=====================================================================<br />
<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, VAL3 program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE or photoneo_common:nErrCode == photoneo_common:nERR_BAD_DATA or photoneo_common:nErrCode == photoneo_common:nERR_TIMEOUT)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
This procedure is useful only if you need make a calibration from robot controller. Better way is used Binpicking studio for calibration.<br />
<br />
In main_application in procedure '''start()''' comment '''PHOMAIN''' task in order to execute calibration procedure and uncomment '''PHOCALIB'''. If you will finish, then return back changes<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints. <br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send request to starting calibration<br />
call photoneo_common:calib_start_request()<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
Explore the calibration request:<br />
<br />
'''calib_start_request()''' - request to start calibration<br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during bin picking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
=== 4.5 Placing ===<br />
<br />
For orientation placing you can use information about grasped object. The informations are included in variables:<br />
<br />
'''photoneo_common:nToolInvID''' - Tool invariance ID.<br />
<br />
'''photoneo_common:nGrippingPointID''' - Gripping point ID.<br />
<br />
'''photoneo_common:nGrippingPointInvID''' - Gripping point invariance ID.<br />
<br />
=== 4.6 Multiple vision systems ===<br />
<br />
If you are using multiple vision system from Binpicking studio, then must be define vision system, which will be use in request. A vision system is defined in variable '''photoneo_common:nVisionSystemID'''. Before calling a request must be set vision system ID to the variable. Short example how to send initialize request to 2 vision system.<br />
<br />
// Send bin picking initialization request to the Vision Controller (First vision system)<br />
photoneo_common:nVisionSystemID = 0<br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Send bin picking initialization request to the Vision Controller (Second vision system)<br />
photoneo_common:nVisionSystemID = 1<br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the bin picking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection.<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png|frame|none|alt=Alt text| Figure 5.1]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: Staubli tutorial deployment small.png|frame|none|alt=Alt text| Figure 5.2]]<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png|frame|none|alt=Alt text| Figure 5.3]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first bin picking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png|frame|none|alt=Alt text| Figure 5.4]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=1429Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-11-28T11:30:32Z<p>Michald: /* 4.6 Multiple vision systems */</p>
<hr />
<div>'''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.'''<br />
<br />
== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial provides a step by step guide of how to configure your Stäubli CS9 controller and install the VAL3 files you will need to get the robot interface for Photoneo Bin Picking Studio up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
The first step of the setup is to configure the network interface. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png|frame|none|alt=Alt text| Figure 2.1.1]]<br />
<br />
<br />
As you can see in the figure below, two network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between the Staubli Robotics Suite and the robot controller.<br />
<br />
Input the J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png|frame|none|alt=Alt text| Figure 2.1.2]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
It is now time to launch Staubli Robotics Suite and start the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on the '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purposes of this tutorial we will use a '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png|frame|none|alt=Alt text| Figure 3.1.1]]<br />
<br />
<br />
If you are already connected to a real robot controller select '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png|frame|none|alt=Alt text| Figure 3.1.2]]<br />
<br />
<br />
In order to select a controller from the available targets, click the '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.1.3]]<br />
<br />
<br />
In the '''General Information''' section type input the '''J205 IP address''' of the robot controller.<br />
<br />
The Remote Connection section contains authorization information. Input the following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' and if everything works properly you should see the following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png|frame|none|alt=Alt text| Figure 3.1.4]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection has been established properly, you are ready to copy the VAL3 files containing the Photoneo Staubli interface to your project. <br />
<br />
The Photoneo Staubli interface consists of three folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from the Photoneo Staubli Module archive (.zip file) which you received with Photoneo Bin Picking Studio to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add the existing applications to the project.<br />
<br />
Expand '''Project_name''', right click on '''Controller_name''', select '''Open Application''' and load all three applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png|frame|none|alt=Alt text| Figure 3.2.1]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png|frame|none|alt=Alt text| Figure 3.2.2]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
The Cartesian origin of Staubli robots '''is different''' than the Cartesian origin of robot models used in the Photoneo Bin Picking Studio. In order to ensure successful calibration, an additional frame with a predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to the Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit the Z axis value according to the arm you are using for your application.<br />
<br />
<br />
[[File:fBaseLink.png|frame|none|alt=Alt text| Figure 3.3.1]]<br />
<br />
<br />
A table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png|frame|none|alt=Alt text| Figure 3.3.2]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
In order to ensure proper communication with the Vision Controller, two sockets (one server and one client) need to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's'''. In the IO table, right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png|frame|none|alt=Alt text| Figure 3.4.1]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and the vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.2]]<br />
<br />
<br />
Use the following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
<br />
'''Port:''' 11003<br />
<br />
'''Description:''' Photoneo Bin Picking Client<br />
<br />
'''Timeout:''' 3000<br />
<br />
'''End of String:''' 10<br />
<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Bin Picking Studio<br />
<br />
Click '''OK''' to apply the changes<br />
<br />
<br />
[[File:staubli_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
<br />
Now add '''Tcp_server''' with the following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
Click '''OK''' to apply the changes <br />
<br />
<br />
[[File:staubli_tcp_server.png|frame|none|alt=Alt text| Figure 3.4.4]]<br />
<br />
<br />
We now need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to the Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select the '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
You should now see that both variables are linked to physical IOs as is shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png|frame|none|alt=Alt text| Figure 3.4.5]]<br />
<br />
<br />
The initial steps of the SRS project configuration are now complete. '''Save the cell''' and you are ready to transfer the project files to the robot controller.<br />
<br />
=== 3.5 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.5.1]]<br />
<br />
<br />
If the connection between SRS and the robot controller has been set up properly, a '''transfer manager dialog''' window should now appear. <br />
<br />
We have made changes to the '''IO''' and '''VAL3 Applications''' so confirm that these items are checked before transferring files. <br />
<br />
<br />
[[File:SRS Staubli transfer.png|frame|none|alt=Alt text| Figure 3.5.2]]<br />
<br />
<br />
=== 3.6 Load Application ===<br />
<br />
If the project has been transferred to the robot controller successfully, it has to be loaded using the pendant. In the current version of the system, this is achieved using the "old menu" from the earlier versions of the controller. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png|frame|none|alt=Alt text| Figure 3.6.1]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli application manager.png|frame|none|alt=Alt text| Figure 3.6.2]]<br />
<br />
<br />
Return to the "color menu" by pressing the '''Home''' button. Now open the '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select the '''"V"''' letter on the widget as is shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png|frame|none|alt=Alt text| Figure 3.6.3]]<br />
<br />
<br />
You should see that '''main_application''' is now available in the application list. <br />
<br />
As a final step, we need to set main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png|frame|none|alt=Alt text| Figure 3.6.4]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Bin Picking Studio. However you should adapt the VAL3 code to meet the precise requirements of your application. This may involve '''reteaching HOME, START and END poses''', updating part placing or application logic, etc. The following section of the tutorial provides some basic examples of how this can be programmed as well as a detailed explanation of the Photoneo VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Staubli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init(joint x_jStartPose, joint x_jEndPose)''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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.<br />
<br />
''' bin_localization_request()''' - Only prepared for future<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for attaching object to gripper here <br />
<br />
- '''griper_detach()''' - implement function for detaching object to gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Bin Picking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png|frame|none|alt=Alt text| Figure 4.2.1]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo Bin Picking Studio provides basic error handling. If an error occurs during bin picking operations the '''photoneo_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application logic and object placing to meet specific workcell and application requirements.<br />
<br />
begin<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(jStartPose, flange, mNomSpeed)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
endIf <br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
<br />
// ==================== PLACING START==================================<br />
// Implement place procedures<br />
// Print received info data about orientation grasped part. This data you can use for orientation placing<br />
call photoneo_common:printLog("Tool inv id: "+toString("1",photoneo_common:nToolInvID),"CLIENT")<br />
call photoneo_common:printLog("Grip id: "+toString("1",photoneo_common:nGrippingPointID),"CLIENT") <br />
call photoneo_common:printLog("Grip inv id: "+toString("1",photoneo_common:nGrippingPointInvID),"CLIENT")<br />
//=====================================================================<br />
<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, VAL3 program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE or photoneo_common:nErrCode == photoneo_common:nERR_BAD_DATA or photoneo_common:nErrCode == photoneo_common:nERR_TIMEOUT)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
This procedure is useful only if you need make a calibration from robot controller. Better way is used Binpicking studio for calibration.<br />
<br />
In main_application in procedure '''start()''' comment '''PHOMAIN''' task in order to execute calibration procedure and uncomment '''PHOCALIB'''. If you will finish, then return back changes<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints. <br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send request to starting calibration<br />
call photoneo_common:calib_start_request()<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
Explore the calibration request:<br />
<br />
'''calib_start_request()''' - request to start calibration<br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during bin picking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
=== 4.5 Placing ===<br />
<br />
For orientation placing you can use information about grasped object. The informations are included in variables:<br />
<br />
'''photoneo_common:nToolInvID''' - Tool invariance ID.<br />
<br />
'''photoneo_common:nGrippingPointID''' - Gripping point ID.<br />
<br />
'''photoneo_common:nGrippingPointInvID''' - Gripping point invariance ID.<br />
<br />
=== 4.6 Multiple vision systems ===<br />
<br />
If you are using multiple vision system from Binpicking studio, then must be define vision system, which will be use in request. A vision system is defined in variable '''photoneo_common:nVisionSystemID'''. Before calling a request must be set vision system ID to the variable. Short example how to send initialize request to 2 vision system.<br />
<br />
// Send bin picking initialization request to the Vision Controller (First vision system)<br />
photoneo_common:nVisionSystemID = 0<br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Send bin picking initialization request to the Vision Controller (Second vision system)<br />
photoneo_common:nVisionSystemID = 1<br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the bin picking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection.<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png|frame|none|alt=Alt text| Figure 5.1]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: Staubli tutorial deployment small.png|frame|none|alt=Alt text| Figure 5.2]]<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png|frame|none|alt=Alt text| Figure 5.3]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first bin picking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png|frame|none|alt=Alt text| Figure 5.4]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=1428Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-11-28T10:54:19Z<p>Michald: /* 4.1 VAL3 API */</p>
<hr />
<div>'''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.'''<br />
<br />
== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial provides a step by step guide of how to configure your Stäubli CS9 controller and install the VAL3 files you will need to get the robot interface for Photoneo Bin Picking Studio up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
The first step of the setup is to configure the network interface. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png|frame|none|alt=Alt text| Figure 2.1.1]]<br />
<br />
<br />
As you can see in the figure below, two network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between the Staubli Robotics Suite and the robot controller.<br />
<br />
Input the J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png|frame|none|alt=Alt text| Figure 2.1.2]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
It is now time to launch Staubli Robotics Suite and start the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on the '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purposes of this tutorial we will use a '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png|frame|none|alt=Alt text| Figure 3.1.1]]<br />
<br />
<br />
If you are already connected to a real robot controller select '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png|frame|none|alt=Alt text| Figure 3.1.2]]<br />
<br />
<br />
In order to select a controller from the available targets, click the '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.1.3]]<br />
<br />
<br />
In the '''General Information''' section type input the '''J205 IP address''' of the robot controller.<br />
<br />
The Remote Connection section contains authorization information. Input the following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' and if everything works properly you should see the following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png|frame|none|alt=Alt text| Figure 3.1.4]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection has been established properly, you are ready to copy the VAL3 files containing the Photoneo Staubli interface to your project. <br />
<br />
The Photoneo Staubli interface consists of three folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from the Photoneo Staubli Module archive (.zip file) which you received with Photoneo Bin Picking Studio to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add the existing applications to the project.<br />
<br />
Expand '''Project_name''', right click on '''Controller_name''', select '''Open Application''' and load all three applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png|frame|none|alt=Alt text| Figure 3.2.1]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png|frame|none|alt=Alt text| Figure 3.2.2]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
The Cartesian origin of Staubli robots '''is different''' than the Cartesian origin of robot models used in the Photoneo Bin Picking Studio. In order to ensure successful calibration, an additional frame with a predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to the Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit the Z axis value according to the arm you are using for your application.<br />
<br />
<br />
[[File:fBaseLink.png|frame|none|alt=Alt text| Figure 3.3.1]]<br />
<br />
<br />
A table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png|frame|none|alt=Alt text| Figure 3.3.2]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
In order to ensure proper communication with the Vision Controller, two sockets (one server and one client) need to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's'''. In the IO table, right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png|frame|none|alt=Alt text| Figure 3.4.1]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and the vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.2]]<br />
<br />
<br />
Use the following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
<br />
'''Port:''' 11003<br />
<br />
'''Description:''' Photoneo Bin Picking Client<br />
<br />
'''Timeout:''' 3000<br />
<br />
'''End of String:''' 10<br />
<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Bin Picking Studio<br />
<br />
Click '''OK''' to apply the changes<br />
<br />
<br />
[[File:staubli_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
<br />
Now add '''Tcp_server''' with the following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
Click '''OK''' to apply the changes <br />
<br />
<br />
[[File:staubli_tcp_server.png|frame|none|alt=Alt text| Figure 3.4.4]]<br />
<br />
<br />
We now need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to the Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select the '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
You should now see that both variables are linked to physical IOs as is shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png|frame|none|alt=Alt text| Figure 3.4.5]]<br />
<br />
<br />
The initial steps of the SRS project configuration are now complete. '''Save the cell''' and you are ready to transfer the project files to the robot controller.<br />
<br />
=== 3.5 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.5.1]]<br />
<br />
<br />
If the connection between SRS and the robot controller has been set up properly, a '''transfer manager dialog''' window should now appear. <br />
<br />
We have made changes to the '''IO''' and '''VAL3 Applications''' so confirm that these items are checked before transferring files. <br />
<br />
<br />
[[File:SRS Staubli transfer.png|frame|none|alt=Alt text| Figure 3.5.2]]<br />
<br />
<br />
=== 3.6 Load Application ===<br />
<br />
If the project has been transferred to the robot controller successfully, it has to be loaded using the pendant. In the current version of the system, this is achieved using the "old menu" from the earlier versions of the controller. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png|frame|none|alt=Alt text| Figure 3.6.1]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli application manager.png|frame|none|alt=Alt text| Figure 3.6.2]]<br />
<br />
<br />
Return to the "color menu" by pressing the '''Home''' button. Now open the '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select the '''"V"''' letter on the widget as is shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png|frame|none|alt=Alt text| Figure 3.6.3]]<br />
<br />
<br />
You should see that '''main_application''' is now available in the application list. <br />
<br />
As a final step, we need to set main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png|frame|none|alt=Alt text| Figure 3.6.4]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Bin Picking Studio. However you should adapt the VAL3 code to meet the precise requirements of your application. This may involve '''reteaching HOME, START and END poses''', updating part placing or application logic, etc. The following section of the tutorial provides some basic examples of how this can be programmed as well as a detailed explanation of the Photoneo VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Staubli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init(joint x_jStartPose, joint x_jEndPose)''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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.<br />
<br />
''' bin_localization_request()''' - Only prepared for future<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for attaching object to gripper here <br />
<br />
- '''griper_detach()''' - implement function for detaching object to gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Bin Picking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png|frame|none|alt=Alt text| Figure 4.2.1]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo Bin Picking Studio provides basic error handling. If an error occurs during bin picking operations the '''photoneo_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application logic and object placing to meet specific workcell and application requirements.<br />
<br />
begin<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(jStartPose, flange, mNomSpeed)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
endIf <br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
<br />
// ==================== PLACING START==================================<br />
// Implement place procedures<br />
// Print received info data about orientation grasped part. This data you can use for orientation placing<br />
call photoneo_common:printLog("Tool inv id: "+toString("1",photoneo_common:nToolInvID),"CLIENT")<br />
call photoneo_common:printLog("Grip id: "+toString("1",photoneo_common:nGrippingPointID),"CLIENT") <br />
call photoneo_common:printLog("Grip inv id: "+toString("1",photoneo_common:nGrippingPointInvID),"CLIENT")<br />
//=====================================================================<br />
<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, VAL3 program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE or photoneo_common:nErrCode == photoneo_common:nERR_BAD_DATA or photoneo_common:nErrCode == photoneo_common:nERR_TIMEOUT)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
This procedure is useful only if you need make a calibration from robot controller. Better way is used Binpicking studio for calibration.<br />
<br />
In main_application in procedure '''start()''' comment '''PHOMAIN''' task in order to execute calibration procedure and uncomment '''PHOCALIB'''. If you will finish, then return back changes<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints. <br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send request to starting calibration<br />
call photoneo_common:calib_start_request()<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
Explore the calibration request:<br />
<br />
'''calib_start_request()''' - request to start calibration<br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during bin picking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
=== 4.5 Placing ===<br />
<br />
For orientation placing you can use information about grasped object. The informations are included in variables:<br />
<br />
'''photoneo_common:nToolInvID''' - Tool invariance ID.<br />
<br />
'''photoneo_common:nGrippingPointID''' - Gripping point ID.<br />
<br />
'''photoneo_common:nGrippingPointInvID''' - Gripping point invariance ID.<br />
<br />
=== 4.6 Multiple vision systems ===<br />
<br />
If you are using multiple vision system from Binpicking studio, then must be define vision system, which will be use in request.<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the bin picking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection.<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png|frame|none|alt=Alt text| Figure 5.1]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: Staubli tutorial deployment small.png|frame|none|alt=Alt text| Figure 5.2]]<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png|frame|none|alt=Alt text| Figure 5.3]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first bin picking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png|frame|none|alt=Alt text| Figure 5.4]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=1427Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-11-28T10:48:54Z<p>Michald: /* 4.4.3 calibration() */</p>
<hr />
<div>'''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.'''<br />
<br />
== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial provides a step by step guide of how to configure your Stäubli CS9 controller and install the VAL3 files you will need to get the robot interface for Photoneo Bin Picking Studio up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
The first step of the setup is to configure the network interface. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png|frame|none|alt=Alt text| Figure 2.1.1]]<br />
<br />
<br />
As you can see in the figure below, two network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between the Staubli Robotics Suite and the robot controller.<br />
<br />
Input the J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png|frame|none|alt=Alt text| Figure 2.1.2]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
It is now time to launch Staubli Robotics Suite and start the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on the '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purposes of this tutorial we will use a '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png|frame|none|alt=Alt text| Figure 3.1.1]]<br />
<br />
<br />
If you are already connected to a real robot controller select '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png|frame|none|alt=Alt text| Figure 3.1.2]]<br />
<br />
<br />
In order to select a controller from the available targets, click the '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.1.3]]<br />
<br />
<br />
In the '''General Information''' section type input the '''J205 IP address''' of the robot controller.<br />
<br />
The Remote Connection section contains authorization information. Input the following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' and if everything works properly you should see the following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png|frame|none|alt=Alt text| Figure 3.1.4]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection has been established properly, you are ready to copy the VAL3 files containing the Photoneo Staubli interface to your project. <br />
<br />
The Photoneo Staubli interface consists of three folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from the Photoneo Staubli Module archive (.zip file) which you received with Photoneo Bin Picking Studio to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add the existing applications to the project.<br />
<br />
Expand '''Project_name''', right click on '''Controller_name''', select '''Open Application''' and load all three applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png|frame|none|alt=Alt text| Figure 3.2.1]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png|frame|none|alt=Alt text| Figure 3.2.2]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
The Cartesian origin of Staubli robots '''is different''' than the Cartesian origin of robot models used in the Photoneo Bin Picking Studio. In order to ensure successful calibration, an additional frame with a predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to the Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit the Z axis value according to the arm you are using for your application.<br />
<br />
<br />
[[File:fBaseLink.png|frame|none|alt=Alt text| Figure 3.3.1]]<br />
<br />
<br />
A table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png|frame|none|alt=Alt text| Figure 3.3.2]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
In order to ensure proper communication with the Vision Controller, two sockets (one server and one client) need to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's'''. In the IO table, right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png|frame|none|alt=Alt text| Figure 3.4.1]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and the vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.2]]<br />
<br />
<br />
Use the following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
<br />
'''Port:''' 11003<br />
<br />
'''Description:''' Photoneo Bin Picking Client<br />
<br />
'''Timeout:''' 3000<br />
<br />
'''End of String:''' 10<br />
<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Bin Picking Studio<br />
<br />
Click '''OK''' to apply the changes<br />
<br />
<br />
[[File:staubli_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
<br />
Now add '''Tcp_server''' with the following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
Click '''OK''' to apply the changes <br />
<br />
<br />
[[File:staubli_tcp_server.png|frame|none|alt=Alt text| Figure 3.4.4]]<br />
<br />
<br />
We now need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to the Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select the '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
You should now see that both variables are linked to physical IOs as is shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png|frame|none|alt=Alt text| Figure 3.4.5]]<br />
<br />
<br />
The initial steps of the SRS project configuration are now complete. '''Save the cell''' and you are ready to transfer the project files to the robot controller.<br />
<br />
=== 3.5 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.5.1]]<br />
<br />
<br />
If the connection between SRS and the robot controller has been set up properly, a '''transfer manager dialog''' window should now appear. <br />
<br />
We have made changes to the '''IO''' and '''VAL3 Applications''' so confirm that these items are checked before transferring files. <br />
<br />
<br />
[[File:SRS Staubli transfer.png|frame|none|alt=Alt text| Figure 3.5.2]]<br />
<br />
<br />
=== 3.6 Load Application ===<br />
<br />
If the project has been transferred to the robot controller successfully, it has to be loaded using the pendant. In the current version of the system, this is achieved using the "old menu" from the earlier versions of the controller. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png|frame|none|alt=Alt text| Figure 3.6.1]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli application manager.png|frame|none|alt=Alt text| Figure 3.6.2]]<br />
<br />
<br />
Return to the "color menu" by pressing the '''Home''' button. Now open the '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select the '''"V"''' letter on the widget as is shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png|frame|none|alt=Alt text| Figure 3.6.3]]<br />
<br />
<br />
You should see that '''main_application''' is now available in the application list. <br />
<br />
As a final step, we need to set main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png|frame|none|alt=Alt text| Figure 3.6.4]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Bin Picking Studio. However you should adapt the VAL3 code to meet the precise requirements of your application. This may involve '''reteaching HOME, START and END poses''', updating part placing or application logic, etc. The following section of the tutorial provides some basic examples of how this can be programmed as well as a detailed explanation of the Photoneo VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Staubli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init(joint x_jStartPose, joint x_jEndPose)''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for attaching object to gripper here <br />
<br />
- '''griper_detach()''' - implement function for detaching object to gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Bin Picking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png|frame|none|alt=Alt text| Figure 4.2.1]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo Bin Picking Studio provides basic error handling. If an error occurs during bin picking operations the '''photoneo_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application logic and object placing to meet specific workcell and application requirements.<br />
<br />
begin<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(jStartPose, flange, mNomSpeed)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
endIf <br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
<br />
// ==================== PLACING START==================================<br />
// Implement place procedures<br />
// Print received info data about orientation grasped part. This data you can use for orientation placing<br />
call photoneo_common:printLog("Tool inv id: "+toString("1",photoneo_common:nToolInvID),"CLIENT")<br />
call photoneo_common:printLog("Grip id: "+toString("1",photoneo_common:nGrippingPointID),"CLIENT") <br />
call photoneo_common:printLog("Grip inv id: "+toString("1",photoneo_common:nGrippingPointInvID),"CLIENT")<br />
//=====================================================================<br />
<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, VAL3 program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE or photoneo_common:nErrCode == photoneo_common:nERR_BAD_DATA or photoneo_common:nErrCode == photoneo_common:nERR_TIMEOUT)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
This procedure is useful only if you need make a calibration from robot controller. Better way is used Binpicking studio for calibration.<br />
<br />
In main_application in procedure '''start()''' comment '''PHOMAIN''' task in order to execute calibration procedure and uncomment '''PHOCALIB'''. If you will finish, then return back changes<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints. <br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send request to starting calibration<br />
call photoneo_common:calib_start_request()<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
Explore the calibration request:<br />
<br />
'''calib_start_request()''' - request to start calibration<br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during bin picking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
=== 4.5 Placing ===<br />
<br />
For orientation placing you can use information about grasped object. The informations are included in variables:<br />
<br />
'''photoneo_common:nToolInvID''' - Tool invariance ID.<br />
<br />
'''photoneo_common:nGrippingPointID''' - Gripping point ID.<br />
<br />
'''photoneo_common:nGrippingPointInvID''' - Gripping point invariance ID.<br />
<br />
=== 4.6 Multiple vision systems ===<br />
<br />
If you are using multiple vision system from Binpicking studio, then must be define vision system, which will be use in request.<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the bin picking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection.<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png|frame|none|alt=Alt text| Figure 5.1]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: Staubli tutorial deployment small.png|frame|none|alt=Alt text| Figure 5.2]]<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png|frame|none|alt=Alt text| Figure 5.3]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first bin picking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png|frame|none|alt=Alt text| Figure 5.4]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=1426Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-11-28T10:35:07Z<p>Michald: /* 4.5 Placing */</p>
<hr />
<div>'''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.'''<br />
<br />
== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial provides a step by step guide of how to configure your Stäubli CS9 controller and install the VAL3 files you will need to get the robot interface for Photoneo Bin Picking Studio up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
The first step of the setup is to configure the network interface. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png|frame|none|alt=Alt text| Figure 2.1.1]]<br />
<br />
<br />
As you can see in the figure below, two network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between the Staubli Robotics Suite and the robot controller.<br />
<br />
Input the J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png|frame|none|alt=Alt text| Figure 2.1.2]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
It is now time to launch Staubli Robotics Suite and start the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on the '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purposes of this tutorial we will use a '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png|frame|none|alt=Alt text| Figure 3.1.1]]<br />
<br />
<br />
If you are already connected to a real robot controller select '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png|frame|none|alt=Alt text| Figure 3.1.2]]<br />
<br />
<br />
In order to select a controller from the available targets, click the '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.1.3]]<br />
<br />
<br />
In the '''General Information''' section type input the '''J205 IP address''' of the robot controller.<br />
<br />
The Remote Connection section contains authorization information. Input the following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' and if everything works properly you should see the following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png|frame|none|alt=Alt text| Figure 3.1.4]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection has been established properly, you are ready to copy the VAL3 files containing the Photoneo Staubli interface to your project. <br />
<br />
The Photoneo Staubli interface consists of three folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from the Photoneo Staubli Module archive (.zip file) which you received with Photoneo Bin Picking Studio to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add the existing applications to the project.<br />
<br />
Expand '''Project_name''', right click on '''Controller_name''', select '''Open Application''' and load all three applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png|frame|none|alt=Alt text| Figure 3.2.1]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png|frame|none|alt=Alt text| Figure 3.2.2]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
The Cartesian origin of Staubli robots '''is different''' than the Cartesian origin of robot models used in the Photoneo Bin Picking Studio. In order to ensure successful calibration, an additional frame with a predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to the Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit the Z axis value according to the arm you are using for your application.<br />
<br />
<br />
[[File:fBaseLink.png|frame|none|alt=Alt text| Figure 3.3.1]]<br />
<br />
<br />
A table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png|frame|none|alt=Alt text| Figure 3.3.2]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
In order to ensure proper communication with the Vision Controller, two sockets (one server and one client) need to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's'''. In the IO table, right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png|frame|none|alt=Alt text| Figure 3.4.1]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and the vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.2]]<br />
<br />
<br />
Use the following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
<br />
'''Port:''' 11003<br />
<br />
'''Description:''' Photoneo Bin Picking Client<br />
<br />
'''Timeout:''' 3000<br />
<br />
'''End of String:''' 10<br />
<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Bin Picking Studio<br />
<br />
Click '''OK''' to apply the changes<br />
<br />
<br />
[[File:staubli_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
<br />
Now add '''Tcp_server''' with the following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
Click '''OK''' to apply the changes <br />
<br />
<br />
[[File:staubli_tcp_server.png|frame|none|alt=Alt text| Figure 3.4.4]]<br />
<br />
<br />
We now need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to the Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select the '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
You should now see that both variables are linked to physical IOs as is shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png|frame|none|alt=Alt text| Figure 3.4.5]]<br />
<br />
<br />
The initial steps of the SRS project configuration are now complete. '''Save the cell''' and you are ready to transfer the project files to the robot controller.<br />
<br />
=== 3.5 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.5.1]]<br />
<br />
<br />
If the connection between SRS and the robot controller has been set up properly, a '''transfer manager dialog''' window should now appear. <br />
<br />
We have made changes to the '''IO''' and '''VAL3 Applications''' so confirm that these items are checked before transferring files. <br />
<br />
<br />
[[File:SRS Staubli transfer.png|frame|none|alt=Alt text| Figure 3.5.2]]<br />
<br />
<br />
=== 3.6 Load Application ===<br />
<br />
If the project has been transferred to the robot controller successfully, it has to be loaded using the pendant. In the current version of the system, this is achieved using the "old menu" from the earlier versions of the controller. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png|frame|none|alt=Alt text| Figure 3.6.1]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli application manager.png|frame|none|alt=Alt text| Figure 3.6.2]]<br />
<br />
<br />
Return to the "color menu" by pressing the '''Home''' button. Now open the '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select the '''"V"''' letter on the widget as is shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png|frame|none|alt=Alt text| Figure 3.6.3]]<br />
<br />
<br />
You should see that '''main_application''' is now available in the application list. <br />
<br />
As a final step, we need to set main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png|frame|none|alt=Alt text| Figure 3.6.4]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Bin Picking Studio. However you should adapt the VAL3 code to meet the precise requirements of your application. This may involve '''reteaching HOME, START and END poses''', updating part placing or application logic, etc. The following section of the tutorial provides some basic examples of how this can be programmed as well as a detailed explanation of the Photoneo VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Staubli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init(joint x_jStartPose, joint x_jEndPose)''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for attaching object to gripper here <br />
<br />
- '''griper_detach()''' - implement function for detaching object to gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Bin Picking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png|frame|none|alt=Alt text| Figure 4.2.1]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo Bin Picking Studio provides basic error handling. If an error occurs during bin picking operations the '''photoneo_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application logic and object placing to meet specific workcell and application requirements.<br />
<br />
begin<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(jStartPose, flange, mNomSpeed)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
endIf <br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
<br />
// ==================== PLACING START==================================<br />
// Implement place procedures<br />
// Print received info data about orientation grasped part. This data you can use for orientation placing<br />
call photoneo_common:printLog("Tool inv id: "+toString("1",photoneo_common:nToolInvID),"CLIENT")<br />
call photoneo_common:printLog("Grip id: "+toString("1",photoneo_common:nGrippingPointID),"CLIENT") <br />
call photoneo_common:printLog("Grip inv id: "+toString("1",photoneo_common:nGrippingPointInvID),"CLIENT")<br />
//=====================================================================<br />
<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, VAL3 program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE or photoneo_common:nErrCode == photoneo_common:nERR_BAD_DATA or photoneo_common:nErrCode == photoneo_common:nERR_TIMEOUT)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
This procedure is useful only if you need make a calibration from robot controller. Better way is used Binpicking studio for calibration.<br />
<br />
In main_application in procedure '''start()''' comment '''PHOMAIN''' task in order to execute calibration procedure and uncomment '''PHOCALIB'''. If you will finish, then return back changes<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints. <br />
<br />
TODO pridat start calibration<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
// It it recommended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
Explore the calibration request:<br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during bin picking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
=== 4.5 Placing ===<br />
<br />
For orientation placing you can use information about grasped object. The informations are included in variables:<br />
<br />
'''photoneo_common:nToolInvID''' - Tool invariance ID.<br />
<br />
'''photoneo_common:nGrippingPointID''' - Gripping point ID.<br />
<br />
'''photoneo_common:nGrippingPointInvID''' - Gripping point invariance ID.<br />
<br />
=== 4.6 Multiple vision systems ===<br />
<br />
If you are using multiple vision system from Binpicking studio, then must be define vision system, which will be use in request.<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the bin picking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection.<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png|frame|none|alt=Alt text| Figure 5.1]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: Staubli tutorial deployment small.png|frame|none|alt=Alt text| Figure 5.2]]<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png|frame|none|alt=Alt text| Figure 5.3]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first bin picking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png|frame|none|alt=Alt text| Figure 5.4]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=1425Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-11-28T10:31:57Z<p>Michald: /* 4.4.2 main() */</p>
<hr />
<div>'''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.'''<br />
<br />
== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial provides a step by step guide of how to configure your Stäubli CS9 controller and install the VAL3 files you will need to get the robot interface for Photoneo Bin Picking Studio up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
The first step of the setup is to configure the network interface. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png|frame|none|alt=Alt text| Figure 2.1.1]]<br />
<br />
<br />
As you can see in the figure below, two network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between the Staubli Robotics Suite and the robot controller.<br />
<br />
Input the J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png|frame|none|alt=Alt text| Figure 2.1.2]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
It is now time to launch Staubli Robotics Suite and start the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on the '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purposes of this tutorial we will use a '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png|frame|none|alt=Alt text| Figure 3.1.1]]<br />
<br />
<br />
If you are already connected to a real robot controller select '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png|frame|none|alt=Alt text| Figure 3.1.2]]<br />
<br />
<br />
In order to select a controller from the available targets, click the '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.1.3]]<br />
<br />
<br />
In the '''General Information''' section type input the '''J205 IP address''' of the robot controller.<br />
<br />
The Remote Connection section contains authorization information. Input the following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' and if everything works properly you should see the following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png|frame|none|alt=Alt text| Figure 3.1.4]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection has been established properly, you are ready to copy the VAL3 files containing the Photoneo Staubli interface to your project. <br />
<br />
The Photoneo Staubli interface consists of three folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from the Photoneo Staubli Module archive (.zip file) which you received with Photoneo Bin Picking Studio to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add the existing applications to the project.<br />
<br />
Expand '''Project_name''', right click on '''Controller_name''', select '''Open Application''' and load all three applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png|frame|none|alt=Alt text| Figure 3.2.1]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png|frame|none|alt=Alt text| Figure 3.2.2]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
The Cartesian origin of Staubli robots '''is different''' than the Cartesian origin of robot models used in the Photoneo Bin Picking Studio. In order to ensure successful calibration, an additional frame with a predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to the Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit the Z axis value according to the arm you are using for your application.<br />
<br />
<br />
[[File:fBaseLink.png|frame|none|alt=Alt text| Figure 3.3.1]]<br />
<br />
<br />
A table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png|frame|none|alt=Alt text| Figure 3.3.2]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
In order to ensure proper communication with the Vision Controller, two sockets (one server and one client) need to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's'''. In the IO table, right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png|frame|none|alt=Alt text| Figure 3.4.1]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and the vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.2]]<br />
<br />
<br />
Use the following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
<br />
'''Port:''' 11003<br />
<br />
'''Description:''' Photoneo Bin Picking Client<br />
<br />
'''Timeout:''' 3000<br />
<br />
'''End of String:''' 10<br />
<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Bin Picking Studio<br />
<br />
Click '''OK''' to apply the changes<br />
<br />
<br />
[[File:staubli_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
<br />
Now add '''Tcp_server''' with the following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
Click '''OK''' to apply the changes <br />
<br />
<br />
[[File:staubli_tcp_server.png|frame|none|alt=Alt text| Figure 3.4.4]]<br />
<br />
<br />
We now need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to the Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select the '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
You should now see that both variables are linked to physical IOs as is shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png|frame|none|alt=Alt text| Figure 3.4.5]]<br />
<br />
<br />
The initial steps of the SRS project configuration are now complete. '''Save the cell''' and you are ready to transfer the project files to the robot controller.<br />
<br />
=== 3.5 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.5.1]]<br />
<br />
<br />
If the connection between SRS and the robot controller has been set up properly, a '''transfer manager dialog''' window should now appear. <br />
<br />
We have made changes to the '''IO''' and '''VAL3 Applications''' so confirm that these items are checked before transferring files. <br />
<br />
<br />
[[File:SRS Staubli transfer.png|frame|none|alt=Alt text| Figure 3.5.2]]<br />
<br />
<br />
=== 3.6 Load Application ===<br />
<br />
If the project has been transferred to the robot controller successfully, it has to be loaded using the pendant. In the current version of the system, this is achieved using the "old menu" from the earlier versions of the controller. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png|frame|none|alt=Alt text| Figure 3.6.1]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli application manager.png|frame|none|alt=Alt text| Figure 3.6.2]]<br />
<br />
<br />
Return to the "color menu" by pressing the '''Home''' button. Now open the '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select the '''"V"''' letter on the widget as is shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png|frame|none|alt=Alt text| Figure 3.6.3]]<br />
<br />
<br />
You should see that '''main_application''' is now available in the application list. <br />
<br />
As a final step, we need to set main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png|frame|none|alt=Alt text| Figure 3.6.4]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Bin Picking Studio. However you should adapt the VAL3 code to meet the precise requirements of your application. This may involve '''reteaching HOME, START and END poses''', updating part placing or application logic, etc. The following section of the tutorial provides some basic examples of how this can be programmed as well as a detailed explanation of the Photoneo VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Staubli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init(joint x_jStartPose, joint x_jEndPose)''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for attaching object to gripper here <br />
<br />
- '''griper_detach()''' - implement function for detaching object to gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Bin Picking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png|frame|none|alt=Alt text| Figure 4.2.1]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo Bin Picking Studio provides basic error handling. If an error occurs during bin picking operations the '''photoneo_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application logic and object placing to meet specific workcell and application requirements.<br />
<br />
begin<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server() <br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request(jStartPose, jEndPose)<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(jStartPose, flange, mNomSpeed)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
endIf <br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
<br />
// ==================== PLACING START==================================<br />
// Implement place procedures<br />
// Print received info data about orientation grasped part. This data you can use for orientation placing<br />
call photoneo_common:printLog("Tool inv id: "+toString("1",photoneo_common:nToolInvID),"CLIENT")<br />
call photoneo_common:printLog("Grip id: "+toString("1",photoneo_common:nGrippingPointID),"CLIENT") <br />
call photoneo_common:printLog("Grip inv id: "+toString("1",photoneo_common:nGrippingPointInvID),"CLIENT")<br />
//=====================================================================<br />
<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, VAL3 program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE or photoneo_common:nErrCode == photoneo_common:nERR_BAD_DATA or photoneo_common:nErrCode == photoneo_common:nERR_TIMEOUT)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
This procedure is useful only if you need make a calibration from robot controller. Better way is used Binpicking studio for calibration.<br />
<br />
In main_application in procedure '''start()''' comment '''PHOMAIN''' task in order to execute calibration procedure and uncomment '''PHOCALIB'''. If you will finish, then return back changes<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints. <br />
<br />
TODO pridat start calibration<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
// It it recommended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
Explore the calibration request:<br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during bin picking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
=== 4.5 Placing ===<br />
<br />
For orientation placing you can use information about grasped object. The informations are included in variables:<br />
<br />
TODO dorobit<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
=== 4.6 Multiple vision systems ===<br />
<br />
If you are using multiple vision system from Binpicking studio, then must be define vision system, which will be use in request.<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the bin picking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection.<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png|frame|none|alt=Alt text| Figure 5.1]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: Staubli tutorial deployment small.png|frame|none|alt=Alt text| Figure 5.2]]<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png|frame|none|alt=Alt text| Figure 5.3]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first bin picking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png|frame|none|alt=Alt text| Figure 5.4]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=1424Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-11-28T10:16:51Z<p>Michald: /* 4. VAL3 */</p>
<hr />
<div>'''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.'''<br />
<br />
== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial provides a step by step guide of how to configure your Stäubli CS9 controller and install the VAL3 files you will need to get the robot interface for Photoneo Bin Picking Studio up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
The first step of the setup is to configure the network interface. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png|frame|none|alt=Alt text| Figure 2.1.1]]<br />
<br />
<br />
As you can see in the figure below, two network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between the Staubli Robotics Suite and the robot controller.<br />
<br />
Input the J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png|frame|none|alt=Alt text| Figure 2.1.2]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
It is now time to launch Staubli Robotics Suite and start the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on the '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purposes of this tutorial we will use a '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png|frame|none|alt=Alt text| Figure 3.1.1]]<br />
<br />
<br />
If you are already connected to a real robot controller select '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png|frame|none|alt=Alt text| Figure 3.1.2]]<br />
<br />
<br />
In order to select a controller from the available targets, click the '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.1.3]]<br />
<br />
<br />
In the '''General Information''' section type input the '''J205 IP address''' of the robot controller.<br />
<br />
The Remote Connection section contains authorization information. Input the following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' and if everything works properly you should see the following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png|frame|none|alt=Alt text| Figure 3.1.4]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection has been established properly, you are ready to copy the VAL3 files containing the Photoneo Staubli interface to your project. <br />
<br />
The Photoneo Staubli interface consists of three folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from the Photoneo Staubli Module archive (.zip file) which you received with Photoneo Bin Picking Studio to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add the existing applications to the project.<br />
<br />
Expand '''Project_name''', right click on '''Controller_name''', select '''Open Application''' and load all three applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png|frame|none|alt=Alt text| Figure 3.2.1]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png|frame|none|alt=Alt text| Figure 3.2.2]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
The Cartesian origin of Staubli robots '''is different''' than the Cartesian origin of robot models used in the Photoneo Bin Picking Studio. In order to ensure successful calibration, an additional frame with a predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to the Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit the Z axis value according to the arm you are using for your application.<br />
<br />
<br />
[[File:fBaseLink.png|frame|none|alt=Alt text| Figure 3.3.1]]<br />
<br />
<br />
A table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png|frame|none|alt=Alt text| Figure 3.3.2]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
In order to ensure proper communication with the Vision Controller, two sockets (one server and one client) need to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's'''. In the IO table, right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png|frame|none|alt=Alt text| Figure 3.4.1]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and the vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.2]]<br />
<br />
<br />
Use the following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
<br />
'''Port:''' 11003<br />
<br />
'''Description:''' Photoneo Bin Picking Client<br />
<br />
'''Timeout:''' 3000<br />
<br />
'''End of String:''' 10<br />
<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Bin Picking Studio<br />
<br />
Click '''OK''' to apply the changes<br />
<br />
<br />
[[File:staubli_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
<br />
Now add '''Tcp_server''' with the following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
Click '''OK''' to apply the changes <br />
<br />
<br />
[[File:staubli_tcp_server.png|frame|none|alt=Alt text| Figure 3.4.4]]<br />
<br />
<br />
We now need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to the Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select the '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
You should now see that both variables are linked to physical IOs as is shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png|frame|none|alt=Alt text| Figure 3.4.5]]<br />
<br />
<br />
The initial steps of the SRS project configuration are now complete. '''Save the cell''' and you are ready to transfer the project files to the robot controller.<br />
<br />
=== 3.5 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.5.1]]<br />
<br />
<br />
If the connection between SRS and the robot controller has been set up properly, a '''transfer manager dialog''' window should now appear. <br />
<br />
We have made changes to the '''IO''' and '''VAL3 Applications''' so confirm that these items are checked before transferring files. <br />
<br />
<br />
[[File:SRS Staubli transfer.png|frame|none|alt=Alt text| Figure 3.5.2]]<br />
<br />
<br />
=== 3.6 Load Application ===<br />
<br />
If the project has been transferred to the robot controller successfully, it has to be loaded using the pendant. In the current version of the system, this is achieved using the "old menu" from the earlier versions of the controller. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png|frame|none|alt=Alt text| Figure 3.6.1]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli application manager.png|frame|none|alt=Alt text| Figure 3.6.2]]<br />
<br />
<br />
Return to the "color menu" by pressing the '''Home''' button. Now open the '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select the '''"V"''' letter on the widget as is shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png|frame|none|alt=Alt text| Figure 3.6.3]]<br />
<br />
<br />
You should see that '''main_application''' is now available in the application list. <br />
<br />
As a final step, we need to set main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png|frame|none|alt=Alt text| Figure 3.6.4]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Bin Picking Studio. However you should adapt the VAL3 code to meet the precise requirements of your application. This may involve '''reteaching HOME, START and END poses''', updating part placing or application logic, etc. The following section of the tutorial provides some basic examples of how this can be programmed as well as a detailed explanation of the Photoneo VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Staubli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init(joint x_jStartPose, joint x_jEndPose)''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for attaching object to gripper here <br />
<br />
- '''griper_detach()''' - implement function for detaching object to gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Bin Picking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png|frame|none|alt=Alt text| Figure 4.2.1]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo Bin Picking Studio provides basic error handling. If an error occurs during bin picking operations the '''photoneo_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application logic and object placing to meet specific workcell and application requirements.<br />
<br />
begin<br />
//-------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// This is a basic bin picking template. The main program loop is defined here.<br />
// Adopt application login and placing procedure here to meet your application requirements<br />
//-------------------------------------------------------------------------------------------------------<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
while true<br />
<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START ==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
//==================== PLACING END ================================== <br />
else<br />
<br />
//====================== ERROR HANDLING START ======================= <br />
// In case of communication failure, main_application is terminated immediately<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
//====================== ERROR HANDLING END ========================= <br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
This procedure is useful only if you need make a calibration from robot controller. Better way is used Binpicking studio for calibration.<br />
<br />
In main_application in procedure '''start()''' comment '''PHOMAIN''' task in order to execute calibration procedure and uncomment '''PHOCALIB'''. If you will finish, then return back changes<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints. <br />
<br />
TODO pridat start calibration<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
// It it recommended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
Explore the calibration request:<br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during bin picking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
=== 4.5 Placing ===<br />
<br />
For orientation placing you can use information about grasped object. The informations are included in variables:<br />
<br />
TODO dorobit<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
=== 4.6 Multiple vision systems ===<br />
<br />
If you are using multiple vision system from Binpicking studio, then must be define vision system, which will be use in request.<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the bin picking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection.<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png|frame|none|alt=Alt text| Figure 5.1]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: Staubli tutorial deployment small.png|frame|none|alt=Alt text| Figure 5.2]]<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png|frame|none|alt=Alt text| Figure 5.3]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first bin picking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png|frame|none|alt=Alt text| Figure 5.4]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_ABB_robots&diff=1409Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with ABB robots2018-11-27T12:52:14Z<p>Michald: /* 4.1 RAPID API */</p>
<hr />
<div>'''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.'''<br />
<br />
== 1. Prerequisities ==<br />
<br />
Photoneo ABB Interface is compatible with '''RobotWareOS versions 5.13 and higher'''. <br />
<br />
In addition to compatible system version, the following conditions must also be met:<br />
<br />
- '''(616-6) PC Interface Module''' available<br />
<br />
- '''(672-1) Multitasking Module''' available<br />
<br />
Go to '''System Info -> System Properties -> Control Module -> Options''' to check if these options are available within your system:<br />
<br />
[[File: Pendant options check.png|frame|none|alt=Alt text| Figure 1.1]]<br />
<br />
<br />
NOTE: Use of '''Robot Studio v.6.06''' or higher is highly recommended for Photoneo ABB Interface setup.<br />
<br />
== 2. ABB Controller setup ==<br />
<br />
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. <br />
<br />
This tutorial was originally written using the latest '''RobotWare v.6.06''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
''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.'' <br />
<br />
Turn on the IRC5 Controller, wait for the Initialization Screen to appear, open the '''Menu screen''' and select the '''Control Panel''' option:<br />
<br />
<br />
[[File:ABB_pendant_menu_RW6.png|frame|none|alt=Alt text| Figure 2.1]]<br />
<br />
<br />
In the Control Panel pane, select '''Controller Settings:'''<br />
<br />
<br />
[[File:ABB_pendant_control_panel.png|frame|none|alt=Alt text| Figure 2.2]]<br />
<br />
<br />
Select '''Settings''' and choose the '''Network''' option: <br />
<br />
<br />
[[File:ABB pendant network.png|frame|none|alt=Alt text| Figure 2.3]]<br />
<br />
<br />
The Network Settings window should now appear. Use the '''Touch Panel Keypad''' to set the IP address of the IRC5 WAN port:<br />
<br />
<br />
[[File:ABB pendant IP setup.png|frame|none|alt=Alt text| Figure 2.4]]<br />
<br />
<br />
Choose '''OK button''' and restart the Controller to apply the new settings:<br />
<br />
<br />
[[File:ABB pendant restart.png|frame|none|alt=Alt text| Figure 2.5]]<br />
<br />
<br />
== 3 Robot Studio Setup ==<br />
<br />
=== 3.1 Connect to IRC5 Controller from Robot Studio ===<br />
<br />
Set your local PC network settings to DHCP, plug an Ethernet cable into the '''Service Port''' of the IRC5 Controller and launch Robot Studio.<br />
<br />
For a direct connection to the Robot Controller, select the '''Controller''' tab and select the '''One Click Connect''' option: <br />
<br />
<br />
[[File:Robot studio connect.png|frame|none|alt=Alt text| Figure 3.1.1]]<br />
<br />
=== 3.2 Transfer RAPID files ===<br />
<br />
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.<br />
<br />
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. <br />
<br />
Go to the '''Controller''' tab and select the '''File Transfer''' tool from the menu:<br />
<br />
<br />
[[File:Robot studio file transfer.png|frame|none|alt=Alt text| Figure 3.2.1]]<br />
<br />
<br />
The Photoneo ABB Interface consists of '''four RAPID files''':<br />
<br />
- '''MainModule.mod'''<br />
<br />
- '''CustomerDefinitions.mod'''<br />
<br />
- '''PhotoneoStateServer.mod'''<br />
<br />
- '''PhotoneoCommon.sys'''<br />
<br />
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:<br />
<br />
<br />
[[File:Robot studio file transfer 2.png|frame|none|alt=Alt text| Figure 3.2.2]]<br />
<br />
<br />
=== 3.3 Create State Server Task ===<br />
<br />
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. <br />
<br />
(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. <br />
<br />
<br />
[[File:Robot studio state server config2.png|frame|none|alt=Alt text| Figure 3.3.1]]<br />
<br />
<br />
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:<br />
<br />
<br />
[[File:ABB pendant grant access.png|frame|none|alt=Alt text| Figure 3.3.2]]<br />
<br />
<br />
The State Server Task which runs in the background and will report the current state of the robot to the Vision Controller. <br />
<br />
On the Left pane, select the '''Controller''' option, right click on the '''Task''' item in the list and select '''New Task...''':<br />
<br />
<br />
[[File:Robot Studio Task Definition 2.png|frame|none|alt=Alt text| Figure 3.3.3]]<br />
<br />
<br />
The following dialogue should appear. Change the settings to those shown in the figure below: <br />
<br />
(''String to Copy & Paste:'' '''Task''': PHO_STATE_SERVER, '''Main Entry''': pho_state_server_main)<br />
<br />
<br />
[[File:Robot studio task settings 3.png|frame|none|alt=Alt text| Figure 3.3.4]]<br />
<br />
=== 3.4 Automatic Loading of Modules ===<br />
<br />
Now we need to configure the ABB system to automatically load '''StateServer.mod''' during the boot.<br />
<br />
Right Click on '''Automatic Loading of Modules''' and select '''New Automatic Loading of Modules''' as shown in the figure below: <br />
<br />
<br />
[[File:Robot studio loading modules.png|frame|none|alt=Alt text| Figure 3.4.1]]<br />
<br />
<br />
Configure the module for '''PhotoneoState Server.mod''' as is shown in the figure below:<br />
<br />
(''String to Copy & Paste:'' '''File''': HOME://Photoneo/PhotoneoStateServer.mod)<br />
<br />
<br />
[[File:Robot studio state server automatic loading.png|frame|none|alt=Alt text| Figure 3.4.2]]<br />
<br />
<br />
Repeat the same procedure for '''PhotoneoCommon.sys''' as a system module:<br />
<br />
(''String to Copy & Paste:'' '''File''': HOME://Photoneo/PhotoneoCommon.sys)<br />
<br />
<br />
[[File:Robot studio pho common.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
<br />
Also repeat the same procedure for '''CustomerDefinitions.mod''' containing user settings:<br />
<br />
(''String to Copy & Paste:'' '''File''': HOME://Photoneo/CustomerDefinitions.mod)<br />
<br />
<br />
[[File:Robot studio customer definitions.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
=== 3.5 Load Main Module ===<br />
<br />
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. <br />
<br />
Right Click on '''T_ROB1''' task and select '''Load Module''' or '''Load Module From Controller''':<br />
<br />
<br />
[[File:Robot studio load module.png|frame|none|alt=Alt text| Figure 3.5.1]]<br />
<br />
<br />
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:<br />
<br />
<br />
[[File:Robot studio final panel2.png|frame|none|alt=Alt text| Figure 3.5.2]]<br />
<br />
<br />
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. <br />
<br />
== 4. RAPID ==<br />
<br />
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: <br />
<br />
- '''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 <br />
<br />
- '''RAPID CONFIG''' - '''CustomerDefinitions.mod''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 RAPID API ===<br />
<br />
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. <br />
--------------------------------------------------------<br />
'''pho_request_init(jointtarget pho_start_bin_picking_pose, jointtarget pho_end_bin_picking_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. <br />
<br />
'''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. <br />
<br />
'''pho_request_scan()''' - request to trigger the next scan and localization. Non-blocking request; the RAPID program continues immediately at the next line.<br />
<br />
'''pho_wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''pho_request_trajectory()''' - request to start trajectory planning for current goal. Non-blocking function; the RAPID program continues immediately at the next line.<br />
<br />
'''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. <br />
<br />
'''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). <br />
<br />
'''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.<br />
<br />
'''pho_calib_set()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''pho_calib_reset()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''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.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 RAPID CONFIG ===<br />
<br />
'''CustomerDefinitions module''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for attaching object to the gripper here <br />
<br />
- '''gripper_detach()''' - implement function for detaching object from gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''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) <br />
<br />
- '''pho_bin_picking_simple()''' - a very basic bin picking sequence (for experimental purposes)<br />
<br />
- '''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 !!!'''<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 RAPID ERROR HANDLING === <br />
<br />
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. <br />
<br />
'''PHO_NO_ERR := 0''' - Service response from Vision Controller is valid <br />
<br />
'''PHO_SERVICE_ERR := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''PHO_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''PHO_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''PHO_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''PHO_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''PHO_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''PHO_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''PHO_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''PHO_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''PHO_COLLISION_DETECT := 205''' - Collision has been detected<br />
<br />
'''PHO_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 MAIN MODULE ===<br />
<br />
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. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
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. <br />
<br />
<br />
<br />
MODULE MainModule<br />
<br />
! Copyright (c) 2018 Photoneo s.r.o.<br />
! All rights reserved<br />
! Description: Main bin picking module<br />
!<br />
! Home, start and end binpicking target variables<br />
VAR robtarget home_pose;<br />
VAR robtarget start_bin_picking_robtarget;<br />
VAR robtarget end_bin_picking_robtarget;<br />
VAR jointtarget start_bin_picking_jointtarget;<br />
VAR jointtarget end_bin_picking_jointtarget;<br />
<br />
! Error handling variables<br />
VAR num err_counter;<br />
CONST num MAX_ERR_COUNT := 2;<br />
<br />
PROC main()<br />
<br />
!calibration; ! If bin picking is about to be executed comment this line<br />
bin_picking; ! If calibration is about to be executed comment this line<br />
<br />
ENDPROC <br />
<br />
==== 4.4.2 bin_picking() ====<br />
<br />
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.<br />
<br />
! BIN PICKING<br />
! This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
! bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
! of the code to meet specific workcell and application requirements here. <br />
!<br />
PROC bin_picking()<br />
<br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
<br />
PHO_ERR_CODE := PHO_PLANNING_FAILED;<br />
! <br />
! RETEACH home position for your application<br />
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]];<br />
!<br />
! RETEACH bin picking start and end pose<br />
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]];<br />
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]];<br />
!<br />
! Convert cartesian position to jointtarget<br />
start_bin_picking_jointtarget := CalcJointT(start_bin_picking_robtarget, tool0);<br />
end_bin_picking_jointtarget := CalcJointT(end_bin_picking_robtarget, tool0);<br />
!<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004 ;<br />
! <br />
! Send bin picking initialization request to the Vision Controller, <br />
! start and end poses defined above will be used in trajectory planning pipeline<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
! <br />
! Move robot away from scanning area - reteach this position for your robot and workcell<br />
MoveJ home_pose, v500, z30, tool0;<br />
! <br />
! When robot is away from scanning area, trigger first scan and localization<br />
pho_request_scan;<br />
!<br />
WHILE true DO<br />
scan_again: <br />
!==================== PHOTONEO BIN PICKING START ===========================<br />
! Wait until scanning is completed<br />
pho_wait_for_scan_completion;<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ENDIF <br />
!<br />
! Trigger trajectory planning<br />
pho_request_trajectory;<br />
!<br />
! While trajectory is being calculated, move robot to bin picking start position<br />
MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;<br />
!<br />
! Execute bin picking application, calculated trajectory is received here<br />
pho_bin_picking; <br />
!==================== PHOTONEO BIN PICKING END ===========================<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ELSE <br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
!<br />
!==================== PLACING START==================================<br />
! Move robot from bin picking end position away from scanning area - reteach this position for your robot and workcell<br />
! 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;<br />
!<br />
! Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
pho_request_scan;<br />
!<br />
! Commands for actual part placing - reteach positions for your robot and workcell<br />
! 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;<br />
! open_gripper;<br />
! 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; <br />
!==================== PLACING END=================================== <br />
ENDIF <br />
ENDWHILE <br />
ENDPROC<br />
<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
! CALIBRATION<br />
! Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
! It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
! Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
PROC calibration()<br />
<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004;<br />
! <br />
! 1. calibration waypoint <br />
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;<br />
pho_request_calib_add_point;<br />
! <br />
! 2. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 3. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 4. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 5. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 6. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! Finally set calibration result to the PhoXi Scanner<br />
TPWrite "Setting calibration result to the PhoXi Scanner!";<br />
pho_request_calib_set; <br />
TPWrite "Calibration complete!";<br />
EXIT;<br />
<br />
ENDPROC<br />
<br />
==== 4.4.4 err_handling() ====<br />
<br />
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. <br />
<br />
! ERROR HANDLING<br />
! Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
! For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
! communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
PROC err_handling()<br />
<br />
!--Release gripper if needed<br />
!open_gripper;<br />
<br />
! Move robot to home pose<br />
MoveJ home_pose, v500, z30, tool0;<br />
<br />
!--Display error<br />
TPWrite pho_err_info(PHO_ERR_CODE);<br />
<br />
IF err_counter >= MAX_ERR_COUNT THEN<br />
ErrLog 4800, "Photoneo internal error", pho_err_info(PHO_ERR_CODE), "Please reboot the Vision controller and restart application"," ", " ";<br />
EXIT;<br />
ENDIF<br />
<br />
! If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
IF (PHO_ERR_CODE = PHO_PLANNING_FAILED OR PHO_ERR_CODE = PHO_NO_PART_FOUND) THEN <br />
TPWrite "NO PART FOUND OR PLANNING PATH FAILED";<br />
pho_request_scan;<br />
<br />
! If bin picking has not been initialized or service returned error response, reinitialize and trigger new scan (Adopt if needed)<br />
ELSEIF(PHO_ERR_CODE = PHO_NOT_INITIALIZED) THEN<br />
<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
ELSEIF (PHO_ERR_CODE = PHO_SERVICE_ERR ) THEN<br />
<br />
Waittime 10;<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! In case of communication failure, rapid program is terminated immediatelly<br />
ELSEIF (PHO_ERR_CODE = PHO_BAD_DATA OR PHO_ERR_CODE = PHO_TIMEOUT OR PHO_ERR_CODE = PHO_COM_FAILURE ) THEN<br />
ErrLog 4800, "Photoneo internal error", "Communication failure!", "Please reboot the Vision controller"," "," ";<br />
EXIT;<br />
<br />
! Otherwise trigger next scan and try to continue<br />
ELSE<br />
pho_request_scan;<br />
ENDIF<br />
<br />
err_counter := err_counter + 1;<br />
! reset error flag for next cycle<br />
PHO_OCCURRED_ERR := FALSE;<br />
<br />
ENDPROC<br />
<br />
== 5. Runtime ==<br />
<br />
Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File: waiting_for_server_2.png|frame|none|alt=Alt text| Figure 5.1]]<br />
<br />
<br />
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:<br />
<br />
<br />
[[File: ABB tutorial runtime waiting small.png|frame|none|alt=Alt text| Figure 5.2]]<br />
<br />
<br />
Open Main Menu, browse to '''Production Window''' and '''Set PP to Main''' - at the beginning of the main function:<br />
<br />
<br />
[[File: pp_to_main_2.png|frame|none|alt=Alt text| Figure 5.3]]<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required:<br />
<br />
<br />
[[File: override_vel_2.png|frame|none|alt=Alt text| Figure 5.4]]<br />
<br />
<br />
Hit the '''Play''' button in AUTO mode or '''Enable + Play''' button in MANUAL mode and you should see the following application output:<br />
<br />
<br />
[[File: binpicking_connected.png|frame|none|alt=Alt text| Figure 5.5]]<br />
<br />
<br />
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:<br />
<br />
<br />
[[File: ABB tutorial runtime running.png|frame|none|alt=Alt text| Figure 5.6]]<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=1408Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-11-27T12:33:09Z<p>Michald: /* 4.1 VAL3 API */</p>
<hr />
<div>'''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.'''<br />
<br />
== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial provides a step by step guide of how to configure your Stäubli CS9 controller and install the VAL3 files you will need to get the robot interface for Photoneo Bin Picking Studio up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
The first step of the setup is to configure the network interface. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png|frame|none|alt=Alt text| Figure 2.1.1]]<br />
<br />
<br />
As you can see in the figure below, two network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between the Staubli Robotics Suite and the robot controller.<br />
<br />
Input the J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png|frame|none|alt=Alt text| Figure 2.1.2]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
It is now time to launch Staubli Robotics Suite and start the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on the '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purposes of this tutorial we will use a '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png|frame|none|alt=Alt text| Figure 3.1.1]]<br />
<br />
<br />
If you are already connected to a real robot controller select '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png|frame|none|alt=Alt text| Figure 3.1.2]]<br />
<br />
<br />
In order to select a controller from the available targets, click the '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.1.3]]<br />
<br />
<br />
In the '''General Information''' section type input the '''J205 IP address''' of the robot controller.<br />
<br />
The Remote Connection section contains authorization information. Input the following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' and if everything works properly you should see the following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png|frame|none|alt=Alt text| Figure 3.1.4]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection has been established properly, you are ready to copy the VAL3 files containing the Photoneo Staubli interface to your project. <br />
<br />
The Photoneo Staubli interface consists of three folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from the Photoneo Staubli Module archive (.zip file) which you received with Photoneo Bin Picking Studio to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add the existing applications to the project.<br />
<br />
Expand '''Project_name''', right click on '''Controller_name''', select '''Open Application''' and load all three applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png|frame|none|alt=Alt text| Figure 3.2.1]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png|frame|none|alt=Alt text| Figure 3.2.2]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
The Cartesian origin of Staubli robots '''is different''' than the Cartesian origin of robot models used in the Photoneo Bin Picking Studio. In order to ensure successful calibration, an additional frame with a predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to the Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit the Z axis value according to the arm you are using for your application.<br />
<br />
<br />
[[File:fBaseLink.png|frame|none|alt=Alt text| Figure 3.3.1]]<br />
<br />
<br />
A table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png|frame|none|alt=Alt text| Figure 3.3.2]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
In order to ensure proper communication with the Vision Controller, two sockets (one server and one client) need to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's'''. In the IO table, right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png|frame|none|alt=Alt text| Figure 3.4.1]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and the vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.2]]<br />
<br />
<br />
Use the following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
<br />
'''Port:''' 11003<br />
<br />
'''Description:''' Photoneo Bin Picking Client<br />
<br />
'''Timeout:''' 3000<br />
<br />
'''End of String:''' 10<br />
<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Bin Picking Studio<br />
<br />
Click '''OK''' to apply the changes<br />
<br />
<br />
[[File:staubli_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
<br />
Now add '''Tcp_server''' with the following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
Click '''OK''' to apply the changes <br />
<br />
<br />
[[File:staubli_tcp_server.png|frame|none|alt=Alt text| Figure 3.4.4]]<br />
<br />
<br />
We now need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to the Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select the '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
You should now see that both variables are linked to physical IOs as is shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png|frame|none|alt=Alt text| Figure 3.4.5]]<br />
<br />
<br />
The initial steps of the SRS project configuration are now complete. '''Save the cell''' and you are ready to transfer the project files to the robot controller.<br />
<br />
=== 3.5 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.5.1]]<br />
<br />
<br />
If the connection between SRS and the robot controller has been set up properly, a '''transfer manager dialog''' window should now appear. <br />
<br />
We have made changes to the '''IO''' and '''VAL3 Applications''' so confirm that these items are checked before transferring files. <br />
<br />
<br />
[[File:SRS Staubli transfer.png|frame|none|alt=Alt text| Figure 3.5.2]]<br />
<br />
<br />
=== 3.6 Load Application ===<br />
<br />
If the project has been transferred to the robot controller successfully, it has to be loaded using the pendant. In the current version of the system, this is achieved using the "old menu" from the earlier versions of the controller. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png|frame|none|alt=Alt text| Figure 3.6.1]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli application manager.png|frame|none|alt=Alt text| Figure 3.6.2]]<br />
<br />
<br />
Return to the "color menu" by pressing the '''Home''' button. Now open the '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select the '''"V"''' letter on the widget as is shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png|frame|none|alt=Alt text| Figure 3.6.3]]<br />
<br />
<br />
You should see that '''main_application''' is now available in the application list. <br />
<br />
As a final step, we need to set main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png|frame|none|alt=Alt text| Figure 3.6.4]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Bin Picking Studio. However you should adapt the VAL3 code to meet the precise requirements of your application. This may involve '''reteaching HOME, START and END poses''', updating part placing or application logic, etc. The following section of the tutorial provides some basic examples of how this can be programmed as well as a detailed explanation of the Photoneo VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init(joint x_jStartPose, joint x_jEndPose)''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for attaching object to gripper here <br />
<br />
- '''griper_detach()''' - implement function for detaching object to gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Bin Picking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png|frame|none|alt=Alt text| Figure 4.2.1]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo Bin Picking Studio provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adoat application logic and object placing to meet specific workcell and application requirements.<br />
<br />
begin<br />
//-------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// This is a basic bin picking template. The main program loop is defined here.<br />
// Adopt application login and placing procedure here to meet your application requirements<br />
//-------------------------------------------------------------------------------------------------------<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
while true<br />
<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START ==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
//==================== PLACING END ================================== <br />
else<br />
<br />
//====================== ERROR HANDLING START ======================= <br />
// In case of communication failure, main_application is terminated immediately<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
//====================== ERROR HANDLING END ========================= <br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
// It it recommended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during bin picking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the bin picking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection.<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png|frame|none|alt=Alt text| Figure 5.1]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: Staubli tutorial deployment small.png|frame|none|alt=Alt text| Figure 5.2]]<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png|frame|none|alt=Alt text| Figure 5.3]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first bin picking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png|frame|none|alt=Alt text| Figure 5.4]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=1407Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-11-27T12:28:19Z<p>Michald: /* 3 Staubli Robotics Suite */</p>
<hr />
<div>'''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.'''<br />
<br />
== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial provides a step by step guide of how to configure your Stäubli CS9 controller and install the VAL3 files you will need to get the robot interface for Photoneo Bin Picking Studio up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
The first step of the setup is to configure the network interface. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png|frame|none|alt=Alt text| Figure 2.1.1]]<br />
<br />
<br />
As you can see in the figure below, two network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between the Staubli Robotics Suite and the robot controller.<br />
<br />
Input the J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png|frame|none|alt=Alt text| Figure 2.1.2]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
It is now time to launch Staubli Robotics Suite and start the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on the '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purposes of this tutorial we will use a '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png|frame|none|alt=Alt text| Figure 3.1.1]]<br />
<br />
<br />
If you are already connected to a real robot controller select '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png|frame|none|alt=Alt text| Figure 3.1.2]]<br />
<br />
<br />
In order to select a controller from the available targets, click the '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.1.3]]<br />
<br />
<br />
In the '''General Information''' section type input the '''J205 IP address''' of the robot controller.<br />
<br />
The Remote Connection section contains authorization information. Input the following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' and if everything works properly you should see the following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png|frame|none|alt=Alt text| Figure 3.1.4]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection has been established properly, you are ready to copy the VAL3 files containing the Photoneo Staubli interface to your project. <br />
<br />
The Photoneo Staubli interface consists of three folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from the Photoneo Staubli Module archive (.zip file) which you received with Photoneo Bin Picking Studio to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add the existing applications to the project.<br />
<br />
Expand '''Project_name''', right click on '''Controller_name''', select '''Open Application''' and load all three applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png|frame|none|alt=Alt text| Figure 3.2.1]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png|frame|none|alt=Alt text| Figure 3.2.2]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
The Cartesian origin of Staubli robots '''is different''' than the Cartesian origin of robot models used in the Photoneo Bin Picking Studio. In order to ensure successful calibration, an additional frame with a predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to the Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit the Z axis value according to the arm you are using for your application.<br />
<br />
<br />
[[File:fBaseLink.png|frame|none|alt=Alt text| Figure 3.3.1]]<br />
<br />
<br />
A table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png|frame|none|alt=Alt text| Figure 3.3.2]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
In order to ensure proper communication with the Vision Controller, two sockets (one server and one client) need to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's'''. In the IO table, right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png|frame|none|alt=Alt text| Figure 3.4.1]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and the vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.2]]<br />
<br />
<br />
Use the following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
<br />
'''Port:''' 11003<br />
<br />
'''Description:''' Photoneo Bin Picking Client<br />
<br />
'''Timeout:''' 3000<br />
<br />
'''End of String:''' 10<br />
<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Bin Picking Studio<br />
<br />
Click '''OK''' to apply the changes<br />
<br />
<br />
[[File:staubli_tcp_client.png|frame|none|alt=Alt text| Figure 3.4.3]]<br />
<br />
<br />
Now add '''Tcp_server''' with the following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
Click '''OK''' to apply the changes <br />
<br />
<br />
[[File:staubli_tcp_server.png|frame|none|alt=Alt text| Figure 3.4.4]]<br />
<br />
<br />
We now need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to the Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select the '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
You should now see that both variables are linked to physical IOs as is shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png|frame|none|alt=Alt text| Figure 3.4.5]]<br />
<br />
<br />
The initial steps of the SRS project configuration are now complete. '''Save the cell''' and you are ready to transfer the project files to the robot controller.<br />
<br />
=== 3.5 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png|frame|none|alt=Alt text| Figure 3.5.1]]<br />
<br />
<br />
If the connection between SRS and the robot controller has been set up properly, a '''transfer manager dialog''' window should now appear. <br />
<br />
We have made changes to the '''IO''' and '''VAL3 Applications''' so confirm that these items are checked before transferring files. <br />
<br />
<br />
[[File:SRS Staubli transfer.png|frame|none|alt=Alt text| Figure 3.5.2]]<br />
<br />
<br />
=== 3.6 Load Application ===<br />
<br />
If the project has been transferred to the robot controller successfully, it has to be loaded using the pendant. In the current version of the system, this is achieved using the "old menu" from the earlier versions of the controller. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png|frame|none|alt=Alt text| Figure 3.6.1]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli application manager.png|frame|none|alt=Alt text| Figure 3.6.2]]<br />
<br />
<br />
Return to the "color menu" by pressing the '''Home''' button. Now open the '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select the '''"V"''' letter on the widget as is shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png|frame|none|alt=Alt text| Figure 3.6.3]]<br />
<br />
<br />
You should see that '''main_application''' is now available in the application list. <br />
<br />
As a final step, we need to set main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png|frame|none|alt=Alt text| Figure 3.6.4]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Bin Picking Studio. However you should adapt the VAL3 code to meet the precise requirements of your application. This may involve '''reteaching HOME, START and END poses''', updating part placing or application logic, etc. The following section of the tutorial provides some basic examples of how this can be programmed as well as a detailed explanation of the Photoneo VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.5''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for attaching object to gripper here <br />
<br />
- '''griper_detach()''' - implement function for detaching object to gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Bin Picking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png|frame|none|alt=Alt text| Figure 4.2.1]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo Bin Picking Studio provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adoat application logic and object placing to meet specific workcell and application requirements.<br />
<br />
begin<br />
//-------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// This is a basic bin picking template. The main program loop is defined here.<br />
// Adopt application login and placing procedure here to meet your application requirements<br />
//-------------------------------------------------------------------------------------------------------<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
while true<br />
<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START ==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
//==================== PLACING END ================================== <br />
else<br />
<br />
//====================== ERROR HANDLING START ======================= <br />
// In case of communication failure, main_application is terminated immediately<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
//====================== ERROR HANDLING END ========================= <br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
// It it recommended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during bin picking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the bin picking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection.<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png|frame|none|alt=Alt text| Figure 5.1]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: Staubli tutorial deployment small.png|frame|none|alt=Alt text| Figure 5.2]]<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png|frame|none|alt=Alt text| Figure 5.3]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first bin picking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png|frame|none|alt=Alt text| Figure 5.4]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=631Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-05-09T14:01:30Z<p>Michald: /* 3.5 Binpicking Start and End poses */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 files you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
As a first step we will configure network interfaces. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png]]<br />
<br />
<br />
As you can see in the figure below, 2 network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with the third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between Staubli Robotics Suite and Robot controller.<br />
<br />
Adopt J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
Now it is time to launch Staubli Robotics Suite and start with the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purpose of writing this tutorial we will use '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
<br />
If you are already connected to a real robot controller select option '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
<br />
In order to select a controller from available targets, click on '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
<br />
In the '''General Information''' section type '''J205 IP address''' of robot controller.<br />
<br />
Remote Connection section contains authorization information. Type following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' button and if everything works properly you should see following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection was established properly, you are ready to copy VAL3 files containing Photoneo Staubli interface to your project. <br />
<br />
Photoneo Staubli interface consists of 3 folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from Photoneo-Staubli USB Stick which you received with Photoneo BP solution to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add existing applications to the project.<br />
<br />
Expand '''Project_name''', next right click on '''Controller_name''', choose '''Open Application''' and load all 3 applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
Cartesian origin of Staubli robots '''is different''' than Cartesian origin of robot models used in Photoneo Binpicking System. In order to enable successful calibration, an additional frame with predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit value of Z axis.<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
<br />
Table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
For a proper communication with the Vision Controller two sockets (one server and one client) needs to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's''' button. In the table below right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
<br />
Use following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
'''Port:''' 11003<br />
'''Description:''' Photoneo Binpicking Client<br />
'''Timeout:''' 3000<br />
'''End of String:''' 10<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Binpicking Studio<br />
<br />
And click '''OK''' to apply changes<br />
<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
<br />
Now add '''Tcp_server''' with following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
And click '''OK''' to apply changes <br />
<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Now we need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
As a result you should see that both variables are linked to physical IOs as shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png]]<br />
<br />
=== 3.5 Binpicking Start and End poses ===<br />
<br />
An inevitable step of binpicking configuration is the configuration of bin picking home, start, and end poses. <br />
<br />
Using Cell Explorer switch to Data tab and edit 3 jointRx variables - '''jStartPose''', '''jEndPose''', '''jHomePose''' (jHomePose you should find in the main_application) <br />
<br />
Set joint values of JStartPose, jEndPose and jHomePose to meet your application requirements. <br />
<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
<br />
This was the last step of the initial SRS project configuration. '''Save the cell''' and you are ready to transfer files project to the robot controller.<br />
<br />
=== 3.6 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
<br />
If connection between SRS and robot controller was established properly, a '''transfer manager dialog''' window should appear. <br />
<br />
We have done changes to '''IO''' and '''VAL3 Applications''' so make sure that these items are checked before transferring files. <br />
<br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.7 Load Application ===<br />
<br />
If project has been transferred to the robot controller successfully, it has to be loaded using pendant. With the current system version this is achieved using the "old menu" from previous controller version. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli BP tutorial old menu.jpg]]<br />
<br />
<br />
Return back to the "color menu" by pressing '''Home''' button. Now open '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select '''"V"''' letter on the widget as shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png]]<br />
<br />
<br />
You should see '''main_application''' is now available in the application list. <br />
<br />
As the last step, we need to make main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However you should adopt VAL3 code to meet your application requirements better - you might 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.5''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for opening your gripper here <br />
<br />
- '''griper_detach()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Binpicking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application login and placing part of the code to meet specific workcell and application requirements.<br />
<br />
begin<br />
//-------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// This is a basic bin picking template. The main program loop is defined here.<br />
// Adopt application login and placing procedure here to meet your application requirements<br />
//-------------------------------------------------------------------------------------------------------<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
while true<br />
<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START ==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
//==================== PLACING END ================================== <br />
else<br />
<br />
//====================== ERROR HANDLING START ======================= <br />
// In case of communication failure, main_application is terminated immediately<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
//====================== ERROR HANDLING END ========================= <br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
// It it recommended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during binpicking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the binpicking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first binpicking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=630Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-05-09T14:00:23Z<p>Michald: /* 3.4 Socket configuration */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 files you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
As a first step we will configure network interfaces. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png]]<br />
<br />
<br />
As you can see in the figure below, 2 network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with the third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between Staubli Robotics Suite and Robot controller.<br />
<br />
Adopt J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
Now it is time to launch Staubli Robotics Suite and start with the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purpose of writing this tutorial we will use '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
<br />
If you are already connected to a real robot controller select option '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
<br />
In order to select a controller from available targets, click on '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
<br />
In the '''General Information''' section type '''J205 IP address''' of robot controller.<br />
<br />
Remote Connection section contains authorization information. Type following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' button and if everything works properly you should see following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection was established properly, you are ready to copy VAL3 files containing Photoneo Staubli interface to your project. <br />
<br />
Photoneo Staubli interface consists of 3 folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from Photoneo-Staubli USB Stick which you received with Photoneo BP solution to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add existing applications to the project.<br />
<br />
Expand '''Project_name''', next right click on '''Controller_name''', choose '''Open Application''' and load all 3 applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
Cartesian origin of Staubli robots '''is different''' than Cartesian origin of robot models used in Photoneo Binpicking System. In order to enable successful calibration, an additional frame with predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit value of Z axis.<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
<br />
Table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
For a proper communication with the Vision Controller two sockets (one server and one client) needs to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's''' button. In the table below right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
<br />
Use following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
'''Port:''' 11003<br />
'''Description:''' Photoneo Binpicking Client<br />
'''Timeout:''' 3000<br />
'''End of String:''' 10<br />
'''Server IP:''' IP address of Vision Controller, which choosen in the Photoneo Binpicking Studio<br />
<br />
And click '''OK''' to apply changes<br />
<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
<br />
Now add '''Tcp_server''' with following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
And click '''OK''' to apply changes <br />
<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Now we need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to Data tab and check two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
As a result you should see that both variables are linked to physical IOs as shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png]]<br />
<br />
=== 3.5 Binpicking Start and End poses ===<br />
<br />
An inevitable step of binpicking configuration is the configuration of bin picking home, start, and end poses. <br />
<br />
Using Cell Explorer switch to Data tab and create 3 jointRx variables - '''jStartPose''', '''jEndPose''', '''jHomePose''' (Be careful about naming) <br />
<br />
Set joint values of JStartPose, jEndPose and jHomePose to meet your application requirements. <br />
<br />
jHomePose you should find in the main_application<br />
<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
<br />
This was the last step of the initial SRS project configuration. '''Save the cell''' and you are ready to transfer files project to the robot controller.<br />
<br />
=== 3.6 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
<br />
If connection between SRS and robot controller was established properly, a '''transfer manager dialog''' window should appear. <br />
<br />
We have done changes to '''IO''' and '''VAL3 Applications''' so make sure that these items are checked before transferring files. <br />
<br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.7 Load Application ===<br />
<br />
If project has been transferred to the robot controller successfully, it has to be loaded using pendant. With the current system version this is achieved using the "old menu" from previous controller version. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli BP tutorial old menu.jpg]]<br />
<br />
<br />
Return back to the "color menu" by pressing '''Home''' button. Now open '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select '''"V"''' letter on the widget as shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png]]<br />
<br />
<br />
You should see '''main_application''' is now available in the application list. <br />
<br />
As the last step, we need to make main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However you should adopt VAL3 code to meet your application requirements better - you might 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.5''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for opening your gripper here <br />
<br />
- '''griper_detach()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Binpicking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application login and placing part of the code to meet specific workcell and application requirements.<br />
<br />
begin<br />
//-------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// This is a basic bin picking template. The main program loop is defined here.<br />
// Adopt application login and placing procedure here to meet your application requirements<br />
//-------------------------------------------------------------------------------------------------------<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
while true<br />
<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START ==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
//==================== PLACING END ================================== <br />
else<br />
<br />
//====================== ERROR HANDLING START ======================= <br />
// In case of communication failure, main_application is terminated immediately<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
//====================== ERROR HANDLING END ========================= <br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
// It it recommended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during binpicking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the binpicking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first binpicking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=629Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-05-09T13:28:31Z<p>Michald: /* 3.3 Create fBaseLink */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 files you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
As a first step we will configure network interfaces. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png]]<br />
<br />
<br />
As you can see in the figure below, 2 network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with the third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between Staubli Robotics Suite and Robot controller.<br />
<br />
Adopt J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
Now it is time to launch Staubli Robotics Suite and start with the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purpose of writing this tutorial we will use '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
<br />
If you are already connected to a real robot controller select option '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
<br />
In order to select a controller from available targets, click on '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
<br />
In the '''General Information''' section type '''J205 IP address''' of robot controller.<br />
<br />
Remote Connection section contains authorization information. Type following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' button and if everything works properly you should see following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection was established properly, you are ready to copy VAL3 files containing Photoneo Staubli interface to your project. <br />
<br />
Photoneo Staubli interface consists of 3 folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from Photoneo-Staubli USB Stick which you received with Photoneo BP solution to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add existing applications to the project.<br />
<br />
Expand '''Project_name''', next right click on '''Controller_name''', choose '''Open Application''' and load all 3 applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png]]<br />
<br />
=== 3.3 Edit fBaseLink ===<br />
<br />
Cartesian origin of Staubli robots '''is different''' than Cartesian origin of robot models used in Photoneo Binpicking System. In order to enable successful calibration, an additional frame with predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to Data tab, under controller expand '''photoneo_common'''->'''frame''' and double click on '''fBaseLink'''. Edit value of Z axis.<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
<br />
Table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png]]<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
For a proper communication with the Vision Controller two sockets (one server and one client) needs to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's''' button. In the table below right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
<br />
Use following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
'''Port:''' 11003<br />
'''Description:''' Photoneo Binpicking Client<br />
'''Timeout:''' 3000<br />
'''End of String:''' 10<br />
'''Server IP:''' IP address of Vision Controller<br />
<br />
And click '''OK''' to apply changes<br />
<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
<br />
Now add '''Tcp_server''' with following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
And click '''OK''' to apply changes <br />
<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Now we need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to Data tab and create two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
As a result you should see that both variables are linked to physical IOs as shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png]]<br />
<br />
<br />
=== 3.5 Binpicking Start and End poses ===<br />
<br />
An inevitable step of binpicking configuration is the configuration of bin picking home, start, and end poses. <br />
<br />
Using Cell Explorer switch to Data tab and create 3 jointRx variables - '''jStartPose''', '''jEndPose''', '''jHomePose''' (Be careful about naming) <br />
<br />
Set joint values of JStartPose, jEndPose and jHomePose to meet your application requirements. <br />
<br />
jHomePose you should find in the main_application<br />
<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
<br />
This was the last step of the initial SRS project configuration. '''Save the cell''' and you are ready to transfer files project to the robot controller.<br />
<br />
=== 3.6 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
<br />
If connection between SRS and robot controller was established properly, a '''transfer manager dialog''' window should appear. <br />
<br />
We have done changes to '''IO''' and '''VAL3 Applications''' so make sure that these items are checked before transferring files. <br />
<br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.7 Load Application ===<br />
<br />
If project has been transferred to the robot controller successfully, it has to be loaded using pendant. With the current system version this is achieved using the "old menu" from previous controller version. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli BP tutorial old menu.jpg]]<br />
<br />
<br />
Return back to the "color menu" by pressing '''Home''' button. Now open '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select '''"V"''' letter on the widget as shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png]]<br />
<br />
<br />
You should see '''main_application''' is now available in the application list. <br />
<br />
As the last step, we need to make main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However you should adopt VAL3 code to meet your application requirements better - you might 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.5''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for opening your gripper here <br />
<br />
- '''griper_detach()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Binpicking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application login and placing part of the code to meet specific workcell and application requirements.<br />
<br />
begin<br />
//-------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// This is a basic bin picking template. The main program loop is defined here.<br />
// Adopt application login and placing procedure here to meet your application requirements<br />
//-------------------------------------------------------------------------------------------------------<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
while true<br />
<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START ==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
//==================== PLACING END ================================== <br />
else<br />
<br />
//====================== ERROR HANDLING START ======================= <br />
// In case of communication failure, main_application is terminated immediately<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
//====================== ERROR HANDLING END ========================= <br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
// It it recommended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during binpicking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the binpicking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first binpicking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=628Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-05-09T13:21:54Z<p>Michald: /* 3.2 Copy VAL3 applications */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 files you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
As a first step we will configure network interfaces. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png]]<br />
<br />
<br />
As you can see in the figure below, 2 network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with the third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between Staubli Robotics Suite and Robot controller.<br />
<br />
Adopt J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
Now it is time to launch Staubli Robotics Suite and start with the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purpose of writing this tutorial we will use '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
<br />
If you are already connected to a real robot controller select option '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
<br />
In order to select a controller from available targets, click on '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
<br />
In the '''General Information''' section type '''J205 IP address''' of robot controller.<br />
<br />
Remote Connection section contains authorization information. Type following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' button and if everything works properly you should see following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection was established properly, you are ready to copy VAL3 files containing Photoneo Staubli interface to your project. <br />
<br />
Photoneo Staubli interface consists of 3 folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from Photoneo-Staubli USB Stick which you received with Photoneo BP solution to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add existing applications to the project.<br />
<br />
Expand '''Project_name''', next right click on '''Controller_name''', choose '''Open Application''' and load all 3 applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png]]<br />
<br />
=== 3.3 Create fBaseLink ===<br />
<br />
Cartesian origin of Staubli robots '''is different''' than Cartesian origin of robot models used in Photoneo Binpicking System. In order to enable successful calibration, an additional frame with predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to Data tab, right click on '''photoneo_common''' -> '''New Data''' and choose '''Frame'''. Make sure that frame name is set to '''fBaseLink''' otherwise you will experience errors during startup. <br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
<br />
Table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png]]<br />
<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
For a proper communication with the Vision Controller two sockets (one server and one client) needs to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's''' button. In the table below right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
<br />
Use following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
'''Port:''' 11003<br />
'''Description:''' Photoneo Binpicking Client<br />
'''Timeout:''' 3000<br />
'''End of String:''' 10<br />
'''Server IP:''' IP address of Vision Controller<br />
<br />
And click '''OK''' to apply changes<br />
<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
<br />
Now add '''Tcp_server''' with following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
And click '''OK''' to apply changes <br />
<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Now we need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to Data tab and create two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
As a result you should see that both variables are linked to physical IOs as shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png]]<br />
<br />
<br />
=== 3.5 Binpicking Start and End poses ===<br />
<br />
An inevitable step of binpicking configuration is the configuration of bin picking home, start, and end poses. <br />
<br />
Using Cell Explorer switch to Data tab and create 3 jointRx variables - '''jStartPose''', '''jEndPose''', '''jHomePose''' (Be careful about naming) <br />
<br />
Set joint values of JStartPose, jEndPose and jHomePose to meet your application requirements. <br />
<br />
jHomePose you should find in the main_application<br />
<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
<br />
This was the last step of the initial SRS project configuration. '''Save the cell''' and you are ready to transfer files project to the robot controller.<br />
<br />
=== 3.6 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
<br />
If connection between SRS and robot controller was established properly, a '''transfer manager dialog''' window should appear. <br />
<br />
We have done changes to '''IO''' and '''VAL3 Applications''' so make sure that these items are checked before transferring files. <br />
<br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.7 Load Application ===<br />
<br />
If project has been transferred to the robot controller successfully, it has to be loaded using pendant. With the current system version this is achieved using the "old menu" from previous controller version. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli BP tutorial old menu.jpg]]<br />
<br />
<br />
Return back to the "color menu" by pressing '''Home''' button. Now open '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select '''"V"''' letter on the widget as shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png]]<br />
<br />
<br />
You should see '''main_application''' is now available in the application list. <br />
<br />
As the last step, we need to make main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However you should adopt VAL3 code to meet your application requirements better - you might 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.5''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for opening your gripper here <br />
<br />
- '''griper_detach()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Binpicking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application login and placing part of the code to meet specific workcell and application requirements.<br />
<br />
begin<br />
//-------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// This is a basic bin picking template. The main program loop is defined here.<br />
// Adopt application login and placing procedure here to meet your application requirements<br />
//-------------------------------------------------------------------------------------------------------<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
while true<br />
<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START ==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
//==================== PLACING END ================================== <br />
else<br />
<br />
//====================== ERROR HANDLING START ======================= <br />
// In case of communication failure, main_application is terminated immediately<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
//====================== ERROR HANDLING END ========================= <br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
// It it recommended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during binpicking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the binpicking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first binpicking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=627Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-05-09T13:19:29Z<p>Michald: /* 2.1 Network configuration */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 files you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
As a first step we will configure network interfaces. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png]]<br />
<br />
<br />
As you can see in the figure below, 2 network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with the third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between Staubli Robotics Suite and Robot controller.<br />
<br />
Adopt J205 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png]]<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
Now it is time to launch Staubli Robotics Suite and start with the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purpose of writing this tutorial we will use '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
<br />
If you are already connected to a real robot controller select option '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
<br />
In order to select a controller from available targets, click on '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
<br />
In the '''General Information''' section type '''J205 IP address''' of robot controller.<br />
<br />
Remote Connection section contains authorization information. Type following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' button and if everything works properly you should see following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection was established properly, you are ready to copy VAL3 files containing Photoneo Staubli interface to your project. <br />
<br />
Photoneo Staubli interface consists of 3 folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from Photoneo-Staubli USB Stick which you received with Photoneo BP solution to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add existing applications to the project.<br />
<br />
Right click on '''Project_name''' -> '''Controller_name''' -> '''Open Application''' and load all 3 applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png]]<br />
<br />
<br />
=== 3.3 Create fBaseLink ===<br />
<br />
Cartesian origin of Staubli robots '''is different''' than Cartesian origin of robot models used in Photoneo Binpicking System. In order to enable successful calibration, an additional frame with predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to Data tab, right click on '''photoneo_common''' -> '''New Data''' and choose '''Frame'''. Make sure that frame name is set to '''fBaseLink''' otherwise you will experience errors during startup. <br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
<br />
Table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png]]<br />
<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
For a proper communication with the Vision Controller two sockets (one server and one client) needs to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's''' button. In the table below right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
<br />
Use following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
'''Port:''' 11003<br />
'''Description:''' Photoneo Binpicking Client<br />
'''Timeout:''' 3000<br />
'''End of String:''' 10<br />
'''Server IP:''' IP address of Vision Controller<br />
<br />
And click '''OK''' to apply changes<br />
<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
<br />
Now add '''Tcp_server''' with following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
And click '''OK''' to apply changes <br />
<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Now we need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to Data tab and create two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
As a result you should see that both variables are linked to physical IOs as shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png]]<br />
<br />
<br />
=== 3.5 Binpicking Start and End poses ===<br />
<br />
An inevitable step of binpicking configuration is the configuration of bin picking home, start, and end poses. <br />
<br />
Using Cell Explorer switch to Data tab and create 3 jointRx variables - '''jStartPose''', '''jEndPose''', '''jHomePose''' (Be careful about naming) <br />
<br />
Set joint values of JStartPose, jEndPose and jHomePose to meet your application requirements. <br />
<br />
jHomePose you should find in the main_application<br />
<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
<br />
This was the last step of the initial SRS project configuration. '''Save the cell''' and you are ready to transfer files project to the robot controller.<br />
<br />
=== 3.6 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
<br />
If connection between SRS and robot controller was established properly, a '''transfer manager dialog''' window should appear. <br />
<br />
We have done changes to '''IO''' and '''VAL3 Applications''' so make sure that these items are checked before transferring files. <br />
<br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.7 Load Application ===<br />
<br />
If project has been transferred to the robot controller successfully, it has to be loaded using pendant. With the current system version this is achieved using the "old menu" from previous controller version. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli BP tutorial old menu.jpg]]<br />
<br />
<br />
Return back to the "color menu" by pressing '''Home''' button. Now open '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select '''"V"''' letter on the widget as shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png]]<br />
<br />
<br />
You should see '''main_application''' is now available in the application list. <br />
<br />
As the last step, we need to make main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However you should adopt VAL3 code to meet your application requirements better - you might 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.5''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for opening your gripper here <br />
<br />
- '''griper_detach()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Binpicking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application login and placing part of the code to meet specific workcell and application requirements.<br />
<br />
begin<br />
//-------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// This is a basic bin picking template. The main program loop is defined here.<br />
// Adopt application login and placing procedure here to meet your application requirements<br />
//-------------------------------------------------------------------------------------------------------<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
while true<br />
<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START ==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
//==================== PLACING END ================================== <br />
else<br />
<br />
//====================== ERROR HANDLING START ======================= <br />
// In case of communication failure, main_application is terminated immediately<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
//====================== ERROR HANDLING END ========================= <br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
// It it recommended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during binpicking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the binpicking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first binpicking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=582Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-17T09:52:54Z<p>Michald: /* 3.5 Binpicking Start and End poses */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface was developed using the latest '''CS9 controler''' version s8.4.2Cs9BS1099. <br />
<br />
It should be compatible with older CS8 controllers with several (mostly UI related) changes. <br />
<br />
''NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.''<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 files you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
As a first step we will configure network interfaces. <br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png]]<br />
<br />
<br />
As you can see in the figure below, 2 network interfaces are available. <br />
<br />
'''- J204''' is usually used for communication with the third party devices, in this case with the Vision Controller. <br />
<br />
'''- J205''' is usually designated for file transfers between Staubli Robotics Suite and Robot controller.<br />
<br />
Adopt J204 IP address to meet your network configuration. <br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png]] <br />
<br />
<br />
== 3 Staubli Robotics Suite ==<br />
<br />
Now it is time to launch Staubli Robotics Suite and start with the SRS project configuration.<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Start by creating a new project. Click on '''Home''' tab -> '''New''' -> '''New cell wizard'''. <br />
<br />
Type the project name and select the project location. For the purpose of writing this tutorial we will use '''TX2_40''' arm and '''Photoneo_binpicking''' as a project name. <br />
<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
<br />
If you are already connected to a real robot controller select option '''Add a local controller from a remote controller'''. <br />
<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
<br />
In order to select a controller from available targets, click on '''"..."''' button<br />
<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
<br />
In the '''General Information''' section type '''J205 IP address''' of robot controller.<br />
<br />
Remote Connection section contains authorization information. Type following credentials for accessing controller: <br />
<br />
'''User Name:''' maintenance.<br />
<br />
'''Password:''' spec_cal<br />
<br />
Port : '''5653'''<br />
<br />
Hit '''OK''' button and if everything works properly you should see following dialog window:<br />
<br />
<br />
[[File:Staubli BP tutorial transfer.png]]<br />
<br />
<br />
=== 3.2 Copy VAL3 applications ===<br />
<br />
If connection was established properly, you are ready to copy VAL3 files containing Photoneo Staubli interface to your project. <br />
<br />
Photoneo Staubli interface consists of 3 folders - '''photoneo_common''', '''customer_definitions''' and '''main_application'''. <br />
<br />
Copy these folders from Photoneo-Staubli USB Stick which you received with Photoneo BP solution to the '''usrapp''' folder of your project '''(Project_name\Controller_name\usr\usrapp\ )'''.<br />
<br />
Now open Cell Explorer in Staubli Robotics Suite and add existing applications to the project.<br />
<br />
Right click on '''Project_name''' -> '''Controller_name''' -> '''Open Application''' and load all 3 applications (select '''.pjx''' files). <br />
<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
The resulting project structure is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial cell explorer.png]]<br />
<br />
<br />
=== 3.3 Create fBaseLink ===<br />
<br />
Cartesian origin of Staubli robots '''is different''' than Cartesian origin of robot models used in Photoneo Binpicking System. In order to enable successful calibration, an additional frame with predefined offset in Z axis must be created. <br />
<br />
In Cell Explorer, switch to Data tab, right click on '''photoneo_common''' -> '''New Data''' and choose '''Frame'''. Make sure that frame name is set to '''fBaseLink''' otherwise you will experience errors during startup. <br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
<br />
Table of offsets for specific robot models is shown in the figure below:<br />
<br />
<br />
[[File:Staubli BP tutorial Offset Table.png]]<br />
<br />
<br />
=== 3.4 Socket configuration ===<br />
<br />
For a proper communication with the Vision Controller two sockets (one server and one client) needs to be configured.<br />
<br />
On the '''Home''' tab click on '''Physical IO's''' button. In the table below right click on '''Sockets''' -> '''Edit Board'''<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
<br />
First add '''Tcp_client''' which is used for transfering bin picking requests and responses between robot and vision controller.<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
<br />
Use following values:<br />
<br />
'''Name:''' PhotoneoClient<br />
'''Port:''' 11003<br />
'''Description:''' Photoneo Binpicking Client<br />
'''Timeout:''' 3000<br />
'''End of String:''' 10<br />
'''Server IP:''' IP address of Vision Controller<br />
<br />
And click '''OK''' to apply changes<br />
<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
<br />
Now add '''Tcp_server''' with following values:<br />
<br />
'''Name:''' PhotoneoStateServer<br />
'''Port:''' 11004<br />
'''Description:''' Photoneo State Server<br />
'''Timeout:''' 0<br />
'''End of String:''' 10<br />
<br />
And click '''OK''' to apply changes <br />
<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Now we need to create two '''sio''' variables and link them with existing sockets. <br />
<br />
Using Cell Explorer switch to Data tab and create two '''sio''' variables - '''sPHOCLIENT''' and '''sPHOSTATE'''. <br />
<br />
In order to link sio variables with existing sockets, double click on '''sPHOCLIENT''' and select '''Sockets\PhotoneoClient''' socket in the '''IO field'''. <br />
<br />
Repeat the same procedure with '''sPHOSTATE''' and '''Sockets\PhotoneoStateServer'''. <br />
<br />
As a result you should see that both variables are linked to physical IOs as shown in the picture below:<br />
<br />
<br />
[[File:socket_link.png]]<br />
<br />
<br />
=== 3.5 Binpicking Start and End poses ===<br />
<br />
An inevitable step of binpicking configuration is the configuration of bin picking home, start, and end poses. <br />
<br />
Using Cell Explorer switch to Data tab and create 3 jointRx variables - '''jStartPose''', '''jEndPose''', '''jHomePose''' (Be careful about naming) <br />
<br />
Set joint values of JStartPose, jEndPose and jHomePose to meet your application requirements. <br />
<br />
jHomePose you should find in the main_application<br />
<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
<br />
This was the last step of the initial SRS project configuration. '''Save the cell''' and you are ready to transfer files project to the robot controller.<br />
<br />
=== 3.6 Transfer files ===<br />
<br />
On the Home tab click on the '''Transfer Manager''' button and select target robot controller.<br />
<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
<br />
If connection between SRS and robot controller was established properly, a '''transfer manager dialog''' window should appear. <br />
<br />
We have done changes to '''IO''' and '''VAL3 Applications''' so make sure that these items are checked before transferring files. <br />
<br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.7 Load Application ===<br />
<br />
If project has been transferred to the robot controller successfully, it has to be loaded using pendant. With the current system version this is achieved using the "old menu" from previous controller version. <br />
<br />
Start by clicking the button shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP Tutorial pendant.png]]<br />
<br />
<br />
In the old menu select '''Application manager''' -> '''Val3 applications''' -> '''main_application''' -> '''F6''' (open)<br />
<br />
<br />
[[File:Staubli BP tutorial old menu.jpg]]<br />
<br />
<br />
Return back to the "color menu" by pressing '''Home''' button. Now open '''VAL3 Applications''' menu. <br />
<br />
Click the bottom label and select '''"V"''' letter on the widget as shown in the picture below:<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png]]<br />
<br />
<br />
You should see '''main_application''' is now available in the application list. <br />
<br />
As the last step, we need to make main_application to '''start automatically'''. Click main_application and set '''autostart''' mode. <br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However you should adopt VAL3 code to meet your application requirements better - you might 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in '''photoneo_common''' application and used within '''main_module''' application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
<br />
--------------------------------------------------------<br />
<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.5''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - optional function to check if a connection to the Vision Controller has been established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for opening your gripper here <br />
<br />
- '''griper_detach()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
- '''customer_definitions:mPickingSpeed''' which is type '''mdesc''' is used to define speed and path approximations for '''Picking Path Stages''' as defined in Photoneo Binpicking Web Interface. Define trajectory speed and precision of '''Approach trajectory''' on the first line, for a '''Grasp trajectory''' on the second line and so on ... See the table below for better understanding:<br />
<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
==== 4.4.1 start() ====<br />
<br />
The '''start()''' procedure is simply a selection of which particular task is about to be executed.<br />
<br />
Comment '''PHOMAIN''' task in order to execute calibration procedure or comment '''PHOCALIB''' task if you want to execute bin picking.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf <br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf <br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. Adopt application login and placing part of the code to meet specific workcell and application requirements.<br />
<br />
begin<br />
//-------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// This is a basic bin picking template. The main program loop is defined here.<br />
// Adopt application login and placing procedure here to meet your application requirements<br />
//-------------------------------------------------------------------------------------------------------<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
while true<br />
<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START ==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
//==================== PLACING END ================================== <br />
else<br />
<br />
//====================== ERROR HANDLING START ======================= <br />
// In case of communication failure, main_application is terminated immediately<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
//====================== ERROR HANDLING END ========================= <br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
Always make sure that the robot does not collide with the workcell during transitions between specific waypoints.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
// It it recommended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
IMPORTANT: If error occurs during binpicking procedure, robot moves to home position and halt PHOMAIN task. Watchdog monitors state of PHOMAIN() every second and restart this task imediately.<br />
<br />
begin<br />
//------------------------------------------------------------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Watchdog<br />
// Monitor PHOMAIN task status and restart task after crash<br />
//------------------------------------------------------------------------------------------------------------------------<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile <br />
end<br />
<br />
== 5. Runtime ==<br />
<br />
Now you are ready to start the binpicking application. Save the Cell, transfer all changes to the robot controller using Transfer Manager tool, and reload the application using the "old menu". <br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Switch controller to '''Auto mode''', press '''Reset''' button if Safety Restart is needed and launch the '''main_application'''.<br />
<br />
If a connection to Vision Controller was established properly you should see following information on logging screen:<br />
<br />
<br />
[[File: Staubli BP tutorial runtime2.png]]<br />
<br />
<br />
You should also receive the notification that the Vision Controller has established a successful connection to the robot controller:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
According to the current robot controller mode you might need to press the '''Power (Button I)''' and the '''Play (Button II)''' in order to enable motion execution<br />
<br />
<br />
[[File: Staubli BP tutorial pendant run2.png]]<br />
<br />
<br />
Robot controller should start sending requests to the Vision controller and executing first binpicking movements. See logging screen on Pendant for information about the procedure: <br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png]]<br />
<br />
<br />
'''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.'''</div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Val3_main_app.jpg&diff=559File:Val3 main app.jpg2018-04-12T07:30:20Z<p>Michald: </p>
<hr />
<div></div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Val3_app_disk.jpg&diff=558File:Val3 app disk.jpg2018-04-12T07:29:56Z<p>Michald: </p>
<hr />
<div></div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Val3_disk.jpg&diff=557File:Val3 disk.jpg2018-04-12T07:29:28Z<p>Michald: </p>
<hr />
<div></div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Val3_app.jpg&diff=556File:Val3 app.jpg2018-04-12T07:29:03Z<p>Michald: </p>
<hr />
<div></div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=555Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-12T07:28:38Z<p>Michald: /* 3 STAUBLI Robotics Suite */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:Staubli BP tutorial transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:Staubli BP tutorial cell explorer.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:Staubli BP Tutorial pendant.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu. V Main menu vybrat Application manager (Kliknut enter alebo Right). V application manger je potrebne otvorit aplikacie kliknutim na F7 (open). Nasledne z disku vyberte main_application<br />
<br />
<br />
Vratte sa na spat na hlavnu obrazku (Tlacidlo home). A nasledne otvorte VAL3 applications. Klik na dolnu listu, ktora vyroluje widget a v nom kliknut na V, tak ako je to znazornene na obrazku<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png]]<br />
<br />
<br />
Kliknite na F7 open alebo right<br />
<br />
[[File:val3_app.jpg]]<br />
<br />
Rozbalte vsetky aplikacie na disku F7 open<br />
<br />
[[File:val3_disk.jpg]]<br />
<br />
Zo zoznamu vsetkych aplikacii na disku vyberte '''main_application'''<br />
<br />
[[File:val3_app_disk.jpg]]<br />
<br />
Ak je applikacia uspesne nahrata budete ju viediet ako na obrazku:<br />
<br />
[[File:val3_main_app.jpg]]<br />
<br />
Tlacidlom home sa vratte spat do pekneho gui<br />
<br />
Rolovaci widget zatvorte a kliknite na '''main_application''' a nastavte ju na autostart<br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png]]<br />
<br />
Aplikacia je tak nachystana na spustenie<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.3.3''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - '''Tu je to len ako volitelna funkci - ak chce integrator cakat, ci je sponenie s VC. Fyzicke pripojenie sa deje vo photoneo_client''' function to establish a connection to the Vision Controller. Blocking function; suspends the program until a proper connection is established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions application''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for opening your gripper here <br />
<br />
- '''griper_detach()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
'''Nastavenie rychlosti a aproximacii''' V globalnej premmenej '''customer_definitions:mPickingSpeed''' typu mdesc definujte vsetky potrebne rychlost index riadku prislucha k idndexu trajektorie. Cize pre approach trajektoriu prisluchaju hodnoty v prvom riadku.<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 start() ====<br />
The '''start()''' 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.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf<br />
<br />
<br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
<br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
begin<br />
<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
<br />
// ==================== PLACING START==================================<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, rapid program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
Kedze error handling je nastaveny, tak ze ked pride error, tak sa robot dostane do definovanej home pozicie a ukonci proceduru main(). Watchdog to bude zistovat kazdu sekundu a v pripade chyby nastartuje main()<br />
<br />
begin<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile<br />
<br />
end<br />
<br />
=== 4.4.4 watchdog_main() ===<br />
<br />
treba toto este opisat a dorobit<br />
<br />
== 5. Runtime ==<br />
<br />
Send VAL3 changes, reload the application. If everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File:Staubli BP tutorial runtime1.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Ked sa vytvori server na Vision controlery tak na pendante bude vidiet nasledujuci screen:<br />
<br />
[[File: Staubli BP tutorial runtime2.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required.<br />
<br />
<br />
Enable the '''power (Button I)''' and Hit the '''Play (Button II)'''<br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png]]<br />
<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=554Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-12T07:27:04Z<p>Michald: /* 3 STAUBLI Robotics Suite */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:Staubli BP tutorial fig1.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:Staubli BP tutorial fig2.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:Staubli BP tutorial transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:Staubli BP tutorial cell explorer.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:Staubli BP Tutorial pendant.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu. V Main menu vybrat Application manager (Kliknut enter alebo Right). V application manger je potrebne otvorit aplikacie kliknutim na F7 (open). Nasledne z disku vyberte main_application<br />
<br />
<br />
Vratte sa na spat na hlavnu obrazku (Tlacidlo home). A nasledne otvorte VAL3 applications. Klik na dolnu listu, ktora vyroluje widget a v nom kliknut na V, tak ako je to znazornene na obrazku<br />
<br />
<br />
[[File:Staubli BP tutorial menu.png]]<br />
<br />
<br />
Kliknite na F7 open alebo right<br />
<br />
[[File:val3_app.png]]<br />
<br />
Rozbalte vsetky aplikacie na disku F7 open<br />
<br />
[[File:val3_disk.png]]<br />
<br />
Zo zoznamu vsetkych aplikacii na disku vyberte '''main_application'''<br />
<br />
[[File:val3_app_disk.png]]<br />
<br />
Ak je applikacia uspesne nahrata budete ju viediet ako na obrazku:<br />
<br />
[[File:val3_main_app.png]]<br />
<br />
Tlacidlom home sa vratte spat do pekneho gui<br />
<br />
Rolovaci widget zatvorte a kliknite na '''main_application''' a nastavte ju na autostart<br />
<br />
<br />
[[File:Staubli BP tutorial autostart.png]]<br />
<br />
Aplikacia je tak nachystana na spustenie<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.3.3''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - '''Tu je to len ako volitelna funkci - ak chce integrator cakat, ci je sponenie s VC. Fyzicke pripojenie sa deje vo photoneo_client''' function to establish a connection to the Vision Controller. Blocking function; suspends the program until a proper connection is established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions application''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for opening your gripper here <br />
<br />
- '''griper_detach()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
'''Nastavenie rychlosti a aproximacii''' V globalnej premmenej '''customer_definitions:mPickingSpeed''' typu mdesc definujte vsetky potrebne rychlost index riadku prislucha k idndexu trajektorie. Cize pre approach trajektoriu prisluchaju hodnoty v prvom riadku.<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 start() ====<br />
The '''start()''' 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.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf<br />
<br />
<br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
<br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
begin<br />
<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
<br />
// ==================== PLACING START==================================<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, rapid program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
Kedze error handling je nastaveny, tak ze ked pride error, tak sa robot dostane do definovanej home pozicie a ukonci proceduru main(). Watchdog to bude zistovat kazdu sekundu a v pripade chyby nastartuje main()<br />
<br />
begin<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile<br />
<br />
end<br />
<br />
=== 4.4.4 watchdog_main() ===<br />
<br />
treba toto este opisat a dorobit<br />
<br />
== 5. Runtime ==<br />
<br />
Send VAL3 changes, reload the application. If everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File:Staubli BP tutorial runtime1.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Ked sa vytvori server na Vision controlery tak na pendante bude vidiet nasledujuci screen:<br />
<br />
[[File: Staubli BP tutorial runtime2.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required.<br />
<br />
<br />
Enable the '''power (Button I)''' and Hit the '''Play (Button II)'''<br />
<br />
<br />
[[File: Staubli BP tutorial runtime3.png]]<br />
<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=534Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-11T10:34:34Z<p>Michald: /* 4.4 main_module application */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:staubli_pendant_load_app.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu. V Main menu vybrat Application manager (Kliknut enter alebo Right). V application manger je potrebne otvorit aplikacie kliknutim na F7 (open). Nasledne z disku vyberte main_application<br />
<br />
<br />
Vratte sa na spat na hlavnu obrazku (Tlacidlo home). A nasledne otvorte VAL3 applications. Klik na dolnu listu, ktora vyroluje widget a v nom kliknut na V, tak ako je to znazornene na obrazku<br />
<br />
<br />
[[File:open_app.png]]<br />
<br />
<br />
Rolovaci widget zatvorte a kliknite na '''main_application''' a nastavte ju na autostart<br />
<br />
<br />
[[File:autostart_application.png]]<br />
<br />
Aplikacia je tak nachystana na spustenie<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.3.3''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - '''Tu je to len ako volitelna funkci - ak chce integrator cakat, ci je sponenie s VC. Fyzicke pripojenie sa deje vo photoneo_client''' function to establish a connection to the Vision Controller. Blocking function; suspends the program until a proper connection is established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions application''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for opening your gripper here <br />
<br />
- '''griper_detach()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
'''Nastavenie rychlosti a aproximacii''' V globalnej premmenej '''customer_definitions:mPickingSpeed''' typu mdesc definujte vsetky potrebne rychlost index riadku prislucha k idndexu trajektorie. Cize pre approach trajektoriu prisluchaju hodnoty v prvom riadku.<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 start() ====<br />
The '''start()''' 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.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf<br />
<br />
<br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
<br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
begin<br />
<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
<br />
// ==================== PLACING START==================================<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, rapid program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
Kedze error handling je nastaveny, tak ze ked pride error, tak sa robot dostane do definovanej home pozicie a ukonci proceduru main(). Watchdog to bude zistovat kazdu sekundu a v pripade chyby nastartuje main()<br />
<br />
begin<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile<br />
<br />
end<br />
<br />
=== 4.4.4 watchdog_main() ===<br />
<br />
treba toto este opisat a dorobit<br />
<br />
== 5. Runtime ==<br />
<br />
Send VAL3 changes, reload the application. If everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File:staubli_waitting.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Ked sa vytvori server na Vision controlery tak na pendante bude vidiet nasledujuci screen:<br />
<br />
[[File: Staubli_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required.<br />
<br />
<br />
Enable the '''power (Button I)''' and Hit the '''Play (Button II)'''<br />
<br />
<br />
[[File: staubli_program_run.png]]<br />
<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=533Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-11T10:24:55Z<p>Michald: /* 4.4 main_module application */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:staubli_pendant_load_app.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu. V Main menu vybrat Application manager (Kliknut enter alebo Right). V application manger je potrebne otvorit aplikacie kliknutim na F7 (open). Nasledne z disku vyberte main_application<br />
<br />
<br />
Vratte sa na spat na hlavnu obrazku (Tlacidlo home). A nasledne otvorte VAL3 applications. Klik na dolnu listu, ktora vyroluje widget a v nom kliknut na V, tak ako je to znazornene na obrazku<br />
<br />
<br />
[[File:open_app.png]]<br />
<br />
<br />
Rolovaci widget zatvorte a kliknite na '''main_application''' a nastavte ju na autostart<br />
<br />
<br />
[[File:autostart_application.png]]<br />
<br />
Aplikacia je tak nachystana na spustenie<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.3.3''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - '''Tu je to len ako volitelna funkci - ak chce integrator cakat, ci je sponenie s VC. Fyzicke pripojenie sa deje vo photoneo_client''' function to establish a connection to the Vision Controller. Blocking function; suspends the program until a proper connection is established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions application''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for opening your gripper here <br />
<br />
- '''griper_detach()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
'''Nastavenie rychlosti a aproximacii''' V globalnej premmenej '''customer_definitions:mPickingSpeed''' typu mdesc definujte vsetky potrebne rychlost index riadku prislucha k idndexu trajektorie. Cize pre approach trajektoriu prisluchaju hodnoty v prvom riadku.<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 start() ====<br />
The '''start()''' 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.<br />
<br />
begin<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Start()<br />
//----------------------------------------------------------------------<br />
<br />
call photoneo_common:start()<br />
<br />
// Start PHOMAIN task<br />
// Comment this code, when you can calibrate<br />
if((taskStatus("PHOMAIN") == -1))<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
<br />
// Start WATCHDOG task<br />
if((taskStatus("WATCHDOG") == -1))<br />
taskCreate "WATCHDOG", 50, watchdog_main()<br />
endIf<br />
<br />
<br />
// Start PHOCALIB task <br />
// Uncomment this code when you can calibrate<br />
//if((taskStatus("PHOCALIB") == -1))<br />
// taskCreate "PHOCALIB", 50, calibration()<br />
//endIf<br />
<br />
end<br />
<br />
==== 4.4.2 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
begin<br />
<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
<br />
// ==================== PLACING START==================================<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, rapid program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
popUpMsg("Communication failure")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
popUpMsg("Service error from VC")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
popUpMsg("No part found or planning failed", "CLIENT")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.5 watchdog_main() and error handling ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.2<br />
<br />
Kedze error handling je nastaveny, tak ze ked pride error, tak sa robot dostane do definovanej home pozicie a ukonci proceduru main(). Watchdog to bude zistovat kazdu sekundu a v pripade chyby nastartuje main()<br />
<br />
begin<br />
<br />
while(true)<br />
// Check PHOMAIN State<br />
if((taskStatus("PHOMAIN") == -1))<br />
popUpMsg("Main program is down! Restarting...")<br />
taskCreate "PHOMAIN", 50, main()<br />
endIf<br />
// Check Tasks State Every Second<br />
delay(1)<br />
endWhile<br />
<br />
end<br />
<br />
=== 4.4.4 watchdog_main() ===<br />
<br />
treba toto este opisat a dorobit<br />
<br />
== 5. Runtime ==<br />
<br />
Send VAL3 changes, reload the application. If everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File:staubli_waitting.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Ked sa vytvori server na Vision controlery tak na pendante bude vidiet nasledujuci screen:<br />
<br />
[[File: Staubli_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required.<br />
<br />
<br />
Enable the '''power (Button I)''' and Hit the '''Play (Button II)'''<br />
<br />
<br />
[[File: staubli_program_run.png]]<br />
<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=532Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-11T10:10:14Z<p>Michald: /* 4.2 VAL3 CONFIG */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:staubli_pendant_load_app.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu. V Main menu vybrat Application manager (Kliknut enter alebo Right). V application manger je potrebne otvorit aplikacie kliknutim na F7 (open). Nasledne z disku vyberte main_application<br />
<br />
<br />
Vratte sa na spat na hlavnu obrazku (Tlacidlo home). A nasledne otvorte VAL3 applications. Klik na dolnu listu, ktora vyroluje widget a v nom kliknut na V, tak ako je to znazornene na obrazku<br />
<br />
<br />
[[File:open_app.png]]<br />
<br />
<br />
Rolovaci widget zatvorte a kliknite na '''main_application''' a nastavte ju na autostart<br />
<br />
<br />
[[File:autostart_application.png]]<br />
<br />
Aplikacia je tak nachystana na spustenie<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.3.3''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - '''Tu je to len ako volitelna funkci - ak chce integrator cakat, ci je sponenie s VC. Fyzicke pripojenie sa deje vo photoneo_client''' function to establish a connection to the Vision Controller. Blocking function; suspends the program until a proper connection is established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions application''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''gripper_attach()''' - implement function for opening your gripper here <br />
<br />
- '''griper_detach()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
'''Nastavenie rychlosti a aproximacii''' V globalnej premmenej '''customer_definitions:mPickingSpeed''' typu mdesc definujte vsetky potrebne rychlost index riadku prislucha k idndexu trajektorie. Cize pre approach trajektoriu prisluchaju hodnoty v prvom riadku.<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
begin<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
// ==================== PLACING START==================================<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, rapid program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
call photoneo_common:printLog("Communication failure", "CLIENT")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
call photoneo_common:printLog("Service error from VC", "CLIENT")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
call photoneo_common:printLog("No part found or planning failed", "CLIENT")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.2 calibration() ====<br />
<br />
'''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.<br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.3 err_handling() ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.3<br />
<br />
=== 4.4.4 watchdog_main() ===<br />
<br />
treba toto este opisat a dorobit<br />
<br />
== 5. Runtime ==<br />
<br />
Send VAL3 changes, reload the application. If everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File:staubli_waitting.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Ked sa vytvori server na Vision controlery tak na pendante bude vidiet nasledujuci screen:<br />
<br />
[[File: Staubli_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required.<br />
<br />
<br />
Enable the '''power (Button I)''' and Hit the '''Play (Button II)'''<br />
<br />
<br />
[[File: staubli_program_run.png]]<br />
<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Staubli_program_run.png&diff=510File:Staubli program run.png2018-04-10T16:24:17Z<p>Michald: </p>
<hr />
<div></div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Staubli_connected.png&diff=509File:Staubli connected.png2018-04-10T16:23:45Z<p>Michald: </p>
<hr />
<div></div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Staubli_waitting.png&diff=508File:Staubli waitting.png2018-04-10T16:23:25Z<p>Michald: </p>
<hr />
<div></div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=507Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-10T16:23:06Z<p>Michald: /* 5. Runtime */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:staubli_pendant_load_app.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu. V Main menu vybrat Application manager (Kliknut enter alebo Right). V application manger je potrebne otvorit aplikacie kliknutim na F7 (open). Nasledne z disku vyberte main_application<br />
<br />
<br />
Vratte sa na spat na hlavnu obrazku (Tlacidlo home). A nasledne otvorte VAL3 applications. Klik na dolnu listu, ktora vyroluje widget a v nom kliknut na V, tak ako je to znazornene na obrazku<br />
<br />
<br />
[[File:open_app.png]]<br />
<br />
<br />
Rolovaci widget zatvorte a kliknite na '''main_application''' a nastavte ju na autostart<br />
<br />
<br />
[[File:autostart_application.png]]<br />
<br />
Aplikacia je tak nachystana na spustenie<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.3.3''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - '''Tu je to len ako volitelna funkci - ak chce integrator cakat, ci je sponenie s VC. Fyzicke pripojenie sa deje vo photoneo_client''' function to establish a connection to the Vision Controller. Blocking function; suspends the program until a proper connection is established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions application''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''attach_gripper()''' - implement function for opening your gripper here <br />
<br />
- '''detach_gripper()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
'''Nastavenie rychlosti a aproximacii''' V globalnej premmenej '''customer_definitions:mPickingSpeed''' typu mdesc definujte vsetky potrebne rychlost index riadku prislucha k idndexu trajektorie. Cize pre approach trajektoriu prisluchaju hodnoty v prvom riadku.<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
begin<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
// ==================== PLACING START==================================<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, rapid program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
call photoneo_common:printLog("Communication failure", "CLIENT")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
call photoneo_common:printLog("Service error from VC", "CLIENT")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
call photoneo_common:printLog("No part found or planning failed", "CLIENT")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.2 calibration() ====<br />
<br />
'''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.<br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.3 err_handling() ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.3<br />
<br />
=== 4.4.4 watchdog_main() ===<br />
<br />
treba toto este opisat a dorobit<br />
<br />
== 5. Runtime ==<br />
<br />
Send VAL3 changes, reload the application. If everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File:staubli_waitting.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Ked sa vytvori server na Vision controlery tak na pendante bude vidiet nasledujuci screen:<br />
<br />
[[File: Staubli_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required.<br />
<br />
<br />
Enable the '''power (Button I)''' and Hit the '''Play (Button II)'''<br />
<br />
<br />
[[File: staubli_program_run.png]]<br />
<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=506Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-10T16:10:07Z<p>Michald: /* 4.4.1 main() */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:staubli_pendant_load_app.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu. V Main menu vybrat Application manager (Kliknut enter alebo Right). V application manger je potrebne otvorit aplikacie kliknutim na F7 (open). Nasledne z disku vyberte main_application<br />
<br />
<br />
Vratte sa na spat na hlavnu obrazku (Tlacidlo home). A nasledne otvorte VAL3 applications. Klik na dolnu listu, ktora vyroluje widget a v nom kliknut na V, tak ako je to znazornene na obrazku<br />
<br />
<br />
[[File:open_app.png]]<br />
<br />
<br />
Rolovaci widget zatvorte a kliknite na '''main_application''' a nastavte ju na autostart<br />
<br />
<br />
[[File:autostart_application.png]]<br />
<br />
Aplikacia je tak nachystana na spustenie<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.3.3''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - '''Tu je to len ako volitelna funkci - ak chce integrator cakat, ci je sponenie s VC. Fyzicke pripojenie sa deje vo photoneo_client''' function to establish a connection to the Vision Controller. Blocking function; suspends the program until a proper connection is established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions application''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''attach_gripper()''' - implement function for opening your gripper here <br />
<br />
- '''detach_gripper()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
'''Nastavenie rychlosti a aproximacii''' V globalnej premmenej '''customer_definitions:mPickingSpeed''' typu mdesc definujte vsetky potrebne rychlost index riadku prislucha k idndexu trajektorie. Cize pre approach trajektoriu prisluchaju hodnoty v prvom riadku.<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
begin<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
// ==================== PLACING START==================================<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, rapid program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
call photoneo_common:printLog("Communication failure", "CLIENT")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
call photoneo_common:printLog("Service error from VC", "CLIENT")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
call photoneo_common:printLog("No part found or planning failed", "CLIENT")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.2 calibration() ====<br />
<br />
'''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.<br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.3 err_handling() ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.3<br />
<br />
=== 4.4.4 watchdog_main() ===<br />
<br />
treba toto este opisat a dorobit<br />
<br />
== 5. Runtime ==<br />
<br />
Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File: waiting_for_server_2.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Open Main Menu, browse to '''Production Window''' and '''Set PP to Main''' - at the beginning of the main function:<br />
<br />
<br />
[[File: pp_to_main_2.png]]<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required:<br />
<br />
<br />
[[File: override_vel_2.png]]<br />
<br />
<br />
Hit the '''Play''' button in AUTO mode or '''Enable + Play''' button in MANUAL mode and you should see the following application output:<br />
<br />
<br />
[[File: binpicking_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=505Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-10T16:09:14Z<p>Michald: /* 4. VAL3 */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:staubli_pendant_load_app.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu. V Main menu vybrat Application manager (Kliknut enter alebo Right). V application manger je potrebne otvorit aplikacie kliknutim na F7 (open). Nasledne z disku vyberte main_application<br />
<br />
<br />
Vratte sa na spat na hlavnu obrazku (Tlacidlo home). A nasledne otvorte VAL3 applications. Klik na dolnu listu, ktora vyroluje widget a v nom kliknut na V, tak ako je to znazornene na obrazku<br />
<br />
<br />
[[File:open_app.png]]<br />
<br />
<br />
Rolovaci widget zatvorte a kliknite na '''main_application''' a nastavte ju na autostart<br />
<br />
<br />
[[File:autostart_application.png]]<br />
<br />
Aplikacia je tak nachystana na spustenie<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.3.3''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - '''Tu je to len ako volitelna funkci - ak chce integrator cakat, ci je sponenie s VC. Fyzicke pripojenie sa deje vo photoneo_client''' function to establish a connection to the Vision Controller. Blocking function; suspends the program until a proper connection is established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_to_scanner_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions application''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''attach_gripper()''' - implement function for opening your gripper here <br />
<br />
- '''detach_gripper()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
'''Nastavenie rychlosti a aproximacii''' V globalnej premmenej '''customer_definitions:mPickingSpeed''' typu mdesc definujte vsetky potrebne rychlost index riadku prislucha k idndexu trajektorie. Cize pre approach trajektoriu prisluchaju hodnoty v prvom riadku.<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 main_module application ===<br />
<br />
The following section provides a detailed explanation of '''main_application ''' - the module through which the user's application and Photoneo Bin Picking API are integrated together. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
begin<br />
<br />
//---------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Main Module<br />
// Adopt this program to meet your requirements<br />
//---------------------------------------------------------------<br />
// BIN PICKING<br />
// This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
// bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
// of the code to meet specific workcell and application requirements here. <br />
<br />
// Clear error counter for err_handling procedure<br />
l_nErrorCounter = 0<br />
<br />
// Wait for connection to the the Vision Controller <br />
call photoneo_common:wait_for_server()<br />
<br />
// Send bin picking initialization request to the Vision Controller, <br />
call photoneo_common:initialize_request()<br />
<br />
// Move robot away from scanning area - reteach this position for your robot and workcell<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// When robot is away from scanning area, trigger first scan and localization<br />
call photoneo_common:scan_request()<br />
<br />
while true<br />
//==================== PHOTONEO BIN PICKING START ===========================<br />
// wait until scanning is completed<br />
call photoneo_common:wait_for_scan_completition()<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// Trigger trajectory planning<br />
call photoneo_common:trajectory_request()<br />
<br />
// While trajectory is being calculated, move robot to bin picking start position<br />
movej(photoneo_common:jStartPose, flange, mNomSpeed)<br />
<br />
// Calculated trajectory is received here<br />
call photoneo_common:trajectory_receive()<br />
endIf<br />
<br />
// Check Error Status<br />
if(photoneo_common:nErrCode == photoneo_common:nOK)<br />
<br />
// If trajectory is valid pick part execute bin picking application<br />
call customer_definitions:pick_part()<br />
<br />
//=================== PHOTONEO BIN PICKING END ===========================<br />
<br />
// Clear error counter if result is ok<br />
l_nErrorCounter = 0<br />
<br />
//==================== PLACING START==================================<br />
// Adopt code for placing operations<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
<br />
// Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
call photoneo_common:scan_request()<br />
call place_part() <br />
<br />
// ==================== PLACING START==================================<br />
else<br />
<br />
// ERROR HANDLING<br />
// Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
// For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
// communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
<br />
// In case of communication failure, rapid program is terminated immediatelly<br />
if(photoneo_common:nErrCode == photoneo_common:nERR_COM_FAILURE)<br />
call photoneo_common:printLog("Communication failure", "CLIENT")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
<br />
//If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_SERVICE or photoneo_common:nErrCode == photoneo_common:nERR_NOT_INITIALIZED)<br />
call photoneo_common:printLog("Service error from VC", "CLIENT")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
return<br />
delay(10)<br />
call photoneo_common:initialize_request()<br />
call photoneo_common:scan_request()<br />
<br />
// If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
elseIf(photoneo_common:nErrCode == photoneo_common:nERR_PLANNING_FAILED or photoneo_common:nErrCode == photoneo_common:nERR_NO_PART_FOUND)<br />
call photoneo_common:printLog("No part found or planning failed", "CLIENT")<br />
movej(jHomePose, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:scan_request()<br />
endIf<br />
<br />
l_nErrorCounter = l_nErrorCounter + 1<br />
if(l_nErrorCounter > 2)<br />
return<br />
endIf<br />
<br />
endIf <br />
endWhile<br />
end<br />
<br />
==== 4.4.2 calibration() ====<br />
<br />
'''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.<br />
<br />
begin<br />
<br />
//----------------------------------------------------------------------<br />
// Copyright (c) 2018 Photoneo s.r.o.<br />
// All rights reserved<br />
// Description: Photoneo Staubli Module v.1.2.0 - Calibration Routine<br />
// Reteach points and use as many as you need<br />
//----------------------------------------------------------------------<br />
<br />
// CALIBRATION<br />
// Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
// It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
// Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
<br />
movej(jCalib1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 1 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib2, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 2 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib3, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 3 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalib4, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
movej(jCalibReserved1, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Helping WayPoint reached", "CLIENT")<br />
<br />
movej(jCalib5, flange, mNomSpeed)<br />
waitEndMove()<br />
call photoneo_common:printLog("Calibration Point 4 reached", "CLIENT")<br />
call photoneo_common:calib_add_point_request()<br />
<br />
call photoneo_common:calib_set_to_scanner_request()<br />
<br />
end<br />
<br />
<br />
==== 4.4.3 err_handling() ====<br />
<br />
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. '''photoneo_common:nErrCode''' contains the error state from the last response from the Vision Controller. Example of Error handling is described in chapter 4.4.3<br />
<br />
=== 4.4.4 watchdog_main() ===<br />
<br />
treba toto este opisat a dorobit<br />
<br />
== 5. Runtime ==<br />
<br />
Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File: waiting_for_server_2.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Open Main Menu, browse to '''Production Window''' and '''Set PP to Main''' - at the beginning of the main function:<br />
<br />
<br />
[[File: pp_to_main_2.png]]<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required:<br />
<br />
<br />
[[File: override_vel_2.png]]<br />
<br />
<br />
Hit the '''Play''' button in AUTO mode or '''Enable + Play''' button in MANUAL mode and you should see the following application output:<br />
<br />
<br />
[[File: binpicking_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Staubli_mdesc.png&diff=504File:Staubli mdesc.png2018-04-10T15:28:43Z<p>Michald: </p>
<hr />
<div></div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=503Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-10T15:27:28Z<p>Michald: /* 4. VAL3 */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:staubli_pendant_load_app.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu. V Main menu vybrat Application manager (Kliknut enter alebo Right). V application manger je potrebne otvorit aplikacie kliknutim na F7 (open). Nasledne z disku vyberte main_application<br />
<br />
<br />
Vratte sa na spat na hlavnu obrazku (Tlacidlo home). A nasledne otvorte VAL3 applications. Klik na dolnu listu, ktora vyroluje widget a v nom kliknut na V, tak ako je to znazornene na obrazku<br />
<br />
<br />
[[File:open_app.png]]<br />
<br />
<br />
Rolovaci widget zatvorte a kliknite na '''main_application''' a nastavte ju na autostart<br />
<br />
<br />
[[File:autostart_application.png]]<br />
<br />
Aplikacia je tak nachystana na spustenie<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.3.3''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - '''Tu je to len ako volitelna funkci - ak chce integrator cakat, ci je sponenie s VC. Fyzicke pripojenie sa deje vo photoneo_client''' function to establish a connection to the Vision Controller. Blocking function; suspends the program until a proper connection is established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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 '''photoneo_common:jStartPose''' before calling this function.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions application''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''attach_gripper()''' - implement function for opening your gripper here <br />
<br />
- '''detach_gripper()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
'''Nastavenie rychlosti a aproximacii''' V globalnej premmenej '''customer_definitions:mPickingSpeed''' typu mdesc definujte vsetky potrebne rychlost index riadku prislucha k idndexu trajektorie. Cize pre approach trajektoriu prisluchaju hodnoty v prvom riadku.<br />
<br />
[[File:staubli_mdesc.png]]<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 VAL3 ERROR HANDLING === <br />
<br />
Photoneo BP solution provides basic error handling. If an error occurs during bin picking operations the '''photoeno_common:nErrCode''' variable contains the code of the specific error which will helps to identify the source of the problem. <br />
<br />
'''photonoe_common:nERR_OK := 0''' - Service response from Vision Controller is valid <br />
<br />
'''photonoe_common:nERR_SERVICE := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''photonoe_common:nERR_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''photonoe_common:nERR_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''photonoe_common:nERR_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''photonoe_common:nERR_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''photonoe_common:nERR_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''photonoe_common:nERR_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''photonoe_common:nERR_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''photonoe_common:nERR_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''photonoe_common:nERR_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 MAIN MODULE ===<br />
<br />
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. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
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. <br />
<br />
<br />
<br />
MODULE MainModule<br />
<br />
! Copyright (c) 2018 Photoneo s.r.o.<br />
! All rights reserved<br />
! Description: Main bin picking module<br />
!<br />
! Home, start and end binpicking target variables<br />
VAR robtarget home_pose;<br />
VAR robtarget start_bin_picking_robtarget;<br />
VAR robtarget end_bin_picking_robtarget;<br />
VAR jointtarget start_bin_picking_jointtarget;<br />
VAR jointtarget end_bin_picking_jointtarget;<br />
<br />
! Error handling variables<br />
VAR num err_counter;<br />
CONST num MAX_ERR_COUNT := 2;<br />
<br />
PROC main()<br />
<br />
!calibration; ! If bin picking is about to be executed comment this line<br />
bin_picking; ! If calibration is about to be executed comment this line<br />
<br />
ENDPROC <br />
<br />
==== 4.4.2 bin_picking() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
! BIN PICKING<br />
! This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
! bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
! of the code to meet specific workcell and application requirements here. <br />
!<br />
PROC bin_picking()<br />
<br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
<br />
PHO_ERR_CODE := PHO_PLANNING_FAILED;<br />
! <br />
! RETEACH home position for your application<br />
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]];<br />
!<br />
! RETEACH bin picking start and end pose<br />
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]];<br />
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]];<br />
!<br />
! Convert cartesian position to jointtarget<br />
start_bin_picking_jointtarget := CalcJointT(start_bin_picking_robtarget, tool0);<br />
end_bin_picking_jointtarget := CalcJointT(end_bin_picking_robtarget, tool0);<br />
!<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004 ;<br />
! <br />
! Send bin picking initialization request to the Vision Controller, <br />
! start and end poses defined above will be used in trajectory planning pipeline<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
! <br />
! Move robot away from scanning area - reteach this position for your robot and workcell<br />
MoveJ home_pose, v500, z30, tool0;<br />
! <br />
! When robot is away from scanning area, trigger first scan and localization<br />
pho_request_scan;<br />
!<br />
WHILE true DO<br />
scan_again: <br />
!==================== PHOTONEO BIN PICKING START ===========================<br />
! Wait until scanning is completed<br />
pho_wait_for_scan_completion;<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ENDIF <br />
!<br />
! Trigger trajectory planning<br />
pho_request_trajectory;<br />
!<br />
! While trajectory is being calculated, move robot to bin picking start position<br />
MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;<br />
!<br />
! Execute bin picking application, calculated trajectory is received here<br />
pho_bin_picking; <br />
!==================== PHOTONEO BIN PICKING END ===========================<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ELSE <br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
!<br />
!==================== PLACING START==================================<br />
! Move robot from bin picking end position away from scanning area - reteach this position for your robot and workcell<br />
! 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;<br />
!<br />
! Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
pho_request_scan;<br />
!<br />
! Commands for actual part placing - reteach positions for your robot and workcell<br />
! 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;<br />
! open_gripper;<br />
! 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; <br />
!==================== PLACING END=================================== <br />
ENDIF <br />
ENDWHILE <br />
ENDPROC<br />
<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
! CALIBRATION<br />
! Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
! It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
! Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
PROC calibration()<br />
<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004;<br />
! <br />
! 1. calibration waypoint <br />
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;<br />
pho_request_calib_add_point;<br />
! <br />
! 2. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 3. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 4. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 5. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 6. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! Finally set calibration result to the PhoXi Scanner<br />
TPWrite "Setting calibration result to the PhoXi Scanner!";<br />
pho_request_calib_set; <br />
TPWrite "Calibration complete!";<br />
EXIT;<br />
<br />
ENDPROC<br />
<br />
==== 4.4.4 err_handling() ====<br />
<br />
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. <br />
<br />
! ERROR HANDLING<br />
! Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
! For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
! communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
PROC err_handling()<br />
<br />
!--Release gripper if needed<br />
!open_gripper;<br />
<br />
! Move robot to home pose<br />
MoveJ home_pose, v500, z30, tool0;<br />
<br />
!--Display error<br />
TPWrite pho_err_info(PHO_ERR_CODE);<br />
<br />
IF err_counter >= MAX_ERR_COUNT THEN<br />
ErrLog 4800, "Photoneo internal error", pho_err_info(PHO_ERR_CODE), "Please reboot the Vision controller and restart application"," ", " ";<br />
EXIT;<br />
ENDIF<br />
<br />
! If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
IF (PHO_ERR_CODE = PHO_PLANNING_FAILED OR PHO_ERR_CODE = PHO_NO_PART_FOUND) THEN <br />
TPWrite "NO PART FOUND OR PLANNING PATH FAILED";<br />
pho_request_scan;<br />
<br />
! If bin picking has not been initialized or service returned error response, reinitialize and trigger new scan (Adopt if needed)<br />
ELSEIF(PHO_ERR_CODE = PHO_NOT_INITIALIZED) THEN<br />
<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
ELSEIF (PHO_ERR_CODE = PHO_SERVICE_ERR ) THEN<br />
<br />
Waittime 10;<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! In case of communication failure, rapid program is terminated immediatelly<br />
ELSEIF (PHO_ERR_CODE = PHO_BAD_DATA OR PHO_ERR_CODE = PHO_TIMEOUT OR PHO_ERR_CODE = PHO_COM_FAILURE ) THEN<br />
ErrLog 4800, "Photoneo internal error", "Communication failure!", "Please reboot the Vision controller"," "," ";<br />
EXIT;<br />
<br />
! Otherwise trigger next scan and try to continue<br />
ELSE<br />
pho_request_scan;<br />
ENDIF<br />
<br />
err_counter := err_counter + 1;<br />
! reset error flag for next cycle<br />
PHO_OCCURRED_ERR := FALSE;<br />
<br />
ENDPROC<br />
<br />
== 5. Runtime ==<br />
<br />
Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File: waiting_for_server_2.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Open Main Menu, browse to '''Production Window''' and '''Set PP to Main''' - at the beginning of the main function:<br />
<br />
<br />
[[File: pp_to_main_2.png]]<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required:<br />
<br />
<br />
[[File: override_vel_2.png]]<br />
<br />
<br />
Hit the '''Play''' button in AUTO mode or '''Enable + Play''' button in MANUAL mode and you should see the following application output:<br />
<br />
<br />
[[File: binpicking_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=502Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-10T15:22:07Z<p>Michald: /* 4. VAL3 */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:staubli_pendant_load_app.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu. V Main menu vybrat Application manager (Kliknut enter alebo Right). V application manger je potrebne otvorit aplikacie kliknutim na F7 (open). Nasledne z disku vyberte main_application<br />
<br />
<br />
Vratte sa na spat na hlavnu obrazku (Tlacidlo home). A nasledne otvorte VAL3 applications. Klik na dolnu listu, ktora vyroluje widget a v nom kliknut na V, tak ako je to znazornene na obrazku<br />
<br />
<br />
[[File:open_app.png]]<br />
<br />
<br />
Rolovaci widget zatvorte a kliknite na '''main_application''' a nastavte ju na autostart<br />
<br />
<br />
[[File:autostart_application.png]]<br />
<br />
Aplikacia je tak nachystana na spustenie<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''pho_request_init()''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the'''photoneo_common in chapter 3.3.3''' side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points. <br />
<br />
'''wait_for_server()''' - '''Tu je to len ako volitelna funkci - ak chce integrator cakat, ci je sponenie s VC. Fyzicke pripojenie sa deje vo photoneo_client''' function to establish a connection to the Vision Controller. Blocking function; suspends the program until a proper connection is established.<br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the VAL3 program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the VAL3 program continues immediately at the next line.<br />
<br />
'''trajectory_receive()''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). This is usually called inside ''pick_part()'' function by default. Blocking function; waits for motion data to be received. <br />
<br />
'''calib_add_point_request()''' - 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.<br />
<br />
'''calib_set_request()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''calib_reset_request()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''pick_part()''' - 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.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 VAL3 CONFIG ===<br />
<br />
'''customer_definitions application''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''attach_gripper()''' - implement function for opening your gripper here <br />
<br />
- '''detach_gripper()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''pick_part()''' - 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 !!!'''<br />
<br />
'''Nastavenie rychlosti a aproximacii''' V globalnej premmenej '''mPickingSpeed''' typu mdesc definujte vsetky potrebne rychlost index riadku prislucha k idndexu trajektorie. Cize pre approach trajektoriu prisluchaju hodnoty v prvom riadku.<br />
<br />
<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 RAPID ERROR HANDLING === <br />
<br />
Photoneo BP solution 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. <br />
<br />
'''PHO_NO_ERR := 0''' - Service response from Vision Controller is valid <br />
<br />
'''PHO_SERVICE_ERR := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''PHO_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''PHO_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''PHO_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''PHO_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''PHO_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''PHO_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''PHO_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''PHO_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''PHO_COLLISION_DETECT := 205''' - Collision has been detected<br />
<br />
'''PHO_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 MAIN MODULE ===<br />
<br />
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. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
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. <br />
<br />
<br />
<br />
MODULE MainModule<br />
<br />
! Copyright (c) 2018 Photoneo s.r.o.<br />
! All rights reserved<br />
! Description: Main bin picking module<br />
!<br />
! Home, start and end binpicking target variables<br />
VAR robtarget home_pose;<br />
VAR robtarget start_bin_picking_robtarget;<br />
VAR robtarget end_bin_picking_robtarget;<br />
VAR jointtarget start_bin_picking_jointtarget;<br />
VAR jointtarget end_bin_picking_jointtarget;<br />
<br />
! Error handling variables<br />
VAR num err_counter;<br />
CONST num MAX_ERR_COUNT := 2;<br />
<br />
PROC main()<br />
<br />
!calibration; ! If bin picking is about to be executed comment this line<br />
bin_picking; ! If calibration is about to be executed comment this line<br />
<br />
ENDPROC <br />
<br />
==== 4.4.2 bin_picking() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
! BIN PICKING<br />
! This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
! bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
! of the code to meet specific workcell and application requirements here. <br />
!<br />
PROC bin_picking()<br />
<br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
<br />
PHO_ERR_CODE := PHO_PLANNING_FAILED;<br />
! <br />
! RETEACH home position for your application<br />
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]];<br />
!<br />
! RETEACH bin picking start and end pose<br />
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]];<br />
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]];<br />
!<br />
! Convert cartesian position to jointtarget<br />
start_bin_picking_jointtarget := CalcJointT(start_bin_picking_robtarget, tool0);<br />
end_bin_picking_jointtarget := CalcJointT(end_bin_picking_robtarget, tool0);<br />
!<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004 ;<br />
! <br />
! Send bin picking initialization request to the Vision Controller, <br />
! start and end poses defined above will be used in trajectory planning pipeline<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
! <br />
! Move robot away from scanning area - reteach this position for your robot and workcell<br />
MoveJ home_pose, v500, z30, tool0;<br />
! <br />
! When robot is away from scanning area, trigger first scan and localization<br />
pho_request_scan;<br />
!<br />
WHILE true DO<br />
scan_again: <br />
!==================== PHOTONEO BIN PICKING START ===========================<br />
! Wait until scanning is completed<br />
pho_wait_for_scan_completion;<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ENDIF <br />
!<br />
! Trigger trajectory planning<br />
pho_request_trajectory;<br />
!<br />
! While trajectory is being calculated, move robot to bin picking start position<br />
MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;<br />
!<br />
! Execute bin picking application, calculated trajectory is received here<br />
pho_bin_picking; <br />
!==================== PHOTONEO BIN PICKING END ===========================<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ELSE <br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
!<br />
!==================== PLACING START==================================<br />
! Move robot from bin picking end position away from scanning area - reteach this position for your robot and workcell<br />
! 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;<br />
!<br />
! Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
pho_request_scan;<br />
!<br />
! Commands for actual part placing - reteach positions for your robot and workcell<br />
! 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;<br />
! open_gripper;<br />
! 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; <br />
!==================== PLACING END=================================== <br />
ENDIF <br />
ENDWHILE <br />
ENDPROC<br />
<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
! CALIBRATION<br />
! Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
! It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
! Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
PROC calibration()<br />
<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004;<br />
! <br />
! 1. calibration waypoint <br />
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;<br />
pho_request_calib_add_point;<br />
! <br />
! 2. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 3. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 4. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 5. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 6. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! Finally set calibration result to the PhoXi Scanner<br />
TPWrite "Setting calibration result to the PhoXi Scanner!";<br />
pho_request_calib_set; <br />
TPWrite "Calibration complete!";<br />
EXIT;<br />
<br />
ENDPROC<br />
<br />
==== 4.4.4 err_handling() ====<br />
<br />
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. <br />
<br />
! ERROR HANDLING<br />
! Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
! For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
! communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
PROC err_handling()<br />
<br />
!--Release gripper if needed<br />
!open_gripper;<br />
<br />
! Move robot to home pose<br />
MoveJ home_pose, v500, z30, tool0;<br />
<br />
!--Display error<br />
TPWrite pho_err_info(PHO_ERR_CODE);<br />
<br />
IF err_counter >= MAX_ERR_COUNT THEN<br />
ErrLog 4800, "Photoneo internal error", pho_err_info(PHO_ERR_CODE), "Please reboot the Vision controller and restart application"," ", " ";<br />
EXIT;<br />
ENDIF<br />
<br />
! If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
IF (PHO_ERR_CODE = PHO_PLANNING_FAILED OR PHO_ERR_CODE = PHO_NO_PART_FOUND) THEN <br />
TPWrite "NO PART FOUND OR PLANNING PATH FAILED";<br />
pho_request_scan;<br />
<br />
! If bin picking has not been initialized or service returned error response, reinitialize and trigger new scan (Adopt if needed)<br />
ELSEIF(PHO_ERR_CODE = PHO_NOT_INITIALIZED) THEN<br />
<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
ELSEIF (PHO_ERR_CODE = PHO_SERVICE_ERR ) THEN<br />
<br />
Waittime 10;<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! In case of communication failure, rapid program is terminated immediatelly<br />
ELSEIF (PHO_ERR_CODE = PHO_BAD_DATA OR PHO_ERR_CODE = PHO_TIMEOUT OR PHO_ERR_CODE = PHO_COM_FAILURE ) THEN<br />
ErrLog 4800, "Photoneo internal error", "Communication failure!", "Please reboot the Vision controller"," "," ";<br />
EXIT;<br />
<br />
! Otherwise trigger next scan and try to continue<br />
ELSE<br />
pho_request_scan;<br />
ENDIF<br />
<br />
err_counter := err_counter + 1;<br />
! reset error flag for next cycle<br />
PHO_OCCURRED_ERR := FALSE;<br />
<br />
ENDPROC<br />
<br />
== 5. Runtime ==<br />
<br />
Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File: waiting_for_server_2.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Open Main Menu, browse to '''Production Window''' and '''Set PP to Main''' - at the beginning of the main function:<br />
<br />
<br />
[[File: pp_to_main_2.png]]<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required:<br />
<br />
<br />
[[File: override_vel_2.png]]<br />
<br />
<br />
Hit the '''Play''' button in AUTO mode or '''Enable + Play''' button in MANUAL mode and you should see the following application output:<br />
<br />
<br />
[[File: binpicking_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Robot_staubli_transfer_manager.png&diff=501File:Robot staubli transfer manager.png2018-04-10T15:03:38Z<p>Michald: </p>
<hr />
<div></div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=500Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-10T15:02:20Z<p>Michald: </p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:staubli_pendant_load_app.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu. V Main menu vybrat Application manager (Kliknut enter alebo Right). V application manger je potrebne otvorit aplikacie kliknutim na F7 (open). Nasledne z disku vyberte main_application<br />
<br />
<br />
Vratte sa na spat na hlavnu obrazku (Tlacidlo home). A nasledne otvorte VAL3 applications. Klik na dolnu listu, ktora vyroluje widget a v nom kliknut na V, tak ako je to znazornene na obrazku<br />
<br />
<br />
[[File:open_app.png]]<br />
<br />
<br />
Rolovaci widget zatvorte a kliknite na '''main_application''' a nastavte ju na autostart<br />
<br />
<br />
[[File:autostart_application.png]]<br />
<br />
Aplikacia je tak nachystana na spustenie<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''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. <br />
<br />
'''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. <br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the RAPID program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the RAPID program continues immediately at the next line.<br />
<br />
'''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. <br />
<br />
'''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). <br />
<br />
'''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.<br />
<br />
'''pho_calib_set()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''pho_calib_reset()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''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.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 RAPID CONFIG ===<br />
<br />
'''CustomerDefinitions module''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''open_gripper()''' - implement function for opening your gripper here <br />
<br />
- '''close_gripper()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''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) <br />
<br />
- '''pho_bin_picking_simple()''' - a very basic bin picking sequence (for experimental purposes)<br />
<br />
- '''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 !!!'''<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 RAPID ERROR HANDLING === <br />
<br />
Photoneo BP solution 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. <br />
<br />
'''PHO_NO_ERR := 0''' - Service response from Vision Controller is valid <br />
<br />
'''PHO_SERVICE_ERR := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''PHO_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''PHO_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''PHO_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''PHO_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''PHO_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''PHO_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''PHO_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''PHO_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''PHO_COLLISION_DETECT := 205''' - Collision has been detected<br />
<br />
'''PHO_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 MAIN MODULE ===<br />
<br />
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. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
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. <br />
<br />
<br />
<br />
MODULE MainModule<br />
<br />
! Copyright (c) 2018 Photoneo s.r.o.<br />
! All rights reserved<br />
! Description: Main bin picking module<br />
!<br />
! Home, start and end binpicking target variables<br />
VAR robtarget home_pose;<br />
VAR robtarget start_bin_picking_robtarget;<br />
VAR robtarget end_bin_picking_robtarget;<br />
VAR jointtarget start_bin_picking_jointtarget;<br />
VAR jointtarget end_bin_picking_jointtarget;<br />
<br />
! Error handling variables<br />
VAR num err_counter;<br />
CONST num MAX_ERR_COUNT := 2;<br />
<br />
PROC main()<br />
<br />
!calibration; ! If bin picking is about to be executed comment this line<br />
bin_picking; ! If calibration is about to be executed comment this line<br />
<br />
ENDPROC <br />
<br />
==== 4.4.2 bin_picking() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
! BIN PICKING<br />
! This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
! bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
! of the code to meet specific workcell and application requirements here. <br />
!<br />
PROC bin_picking()<br />
<br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
<br />
PHO_ERR_CODE := PHO_PLANNING_FAILED;<br />
! <br />
! RETEACH home position for your application<br />
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]];<br />
!<br />
! RETEACH bin picking start and end pose<br />
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]];<br />
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]];<br />
!<br />
! Convert cartesian position to jointtarget<br />
start_bin_picking_jointtarget := CalcJointT(start_bin_picking_robtarget, tool0);<br />
end_bin_picking_jointtarget := CalcJointT(end_bin_picking_robtarget, tool0);<br />
!<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004 ;<br />
! <br />
! Send bin picking initialization request to the Vision Controller, <br />
! start and end poses defined above will be used in trajectory planning pipeline<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
! <br />
! Move robot away from scanning area - reteach this position for your robot and workcell<br />
MoveJ home_pose, v500, z30, tool0;<br />
! <br />
! When robot is away from scanning area, trigger first scan and localization<br />
pho_request_scan;<br />
!<br />
WHILE true DO<br />
scan_again: <br />
!==================== PHOTONEO BIN PICKING START ===========================<br />
! Wait until scanning is completed<br />
pho_wait_for_scan_completion;<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ENDIF <br />
!<br />
! Trigger trajectory planning<br />
pho_request_trajectory;<br />
!<br />
! While trajectory is being calculated, move robot to bin picking start position<br />
MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;<br />
!<br />
! Execute bin picking application, calculated trajectory is received here<br />
pho_bin_picking; <br />
!==================== PHOTONEO BIN PICKING END ===========================<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ELSE <br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
!<br />
!==================== PLACING START==================================<br />
! Move robot from bin picking end position away from scanning area - reteach this position for your robot and workcell<br />
! 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;<br />
!<br />
! Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
pho_request_scan;<br />
!<br />
! Commands for actual part placing - reteach positions for your robot and workcell<br />
! 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;<br />
! open_gripper;<br />
! 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; <br />
!==================== PLACING END=================================== <br />
ENDIF <br />
ENDWHILE <br />
ENDPROC<br />
<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
! CALIBRATION<br />
! Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
! It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
! Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
PROC calibration()<br />
<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004;<br />
! <br />
! 1. calibration waypoint <br />
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;<br />
pho_request_calib_add_point;<br />
! <br />
! 2. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 3. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 4. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 5. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 6. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! Finally set calibration result to the PhoXi Scanner<br />
TPWrite "Setting calibration result to the PhoXi Scanner!";<br />
pho_request_calib_set; <br />
TPWrite "Calibration complete!";<br />
EXIT;<br />
<br />
ENDPROC<br />
<br />
==== 4.4.4 err_handling() ====<br />
<br />
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. <br />
<br />
! ERROR HANDLING<br />
! Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
! For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
! communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
PROC err_handling()<br />
<br />
!--Release gripper if needed<br />
!open_gripper;<br />
<br />
! Move robot to home pose<br />
MoveJ home_pose, v500, z30, tool0;<br />
<br />
!--Display error<br />
TPWrite pho_err_info(PHO_ERR_CODE);<br />
<br />
IF err_counter >= MAX_ERR_COUNT THEN<br />
ErrLog 4800, "Photoneo internal error", pho_err_info(PHO_ERR_CODE), "Please reboot the Vision controller and restart application"," ", " ";<br />
EXIT;<br />
ENDIF<br />
<br />
! If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
IF (PHO_ERR_CODE = PHO_PLANNING_FAILED OR PHO_ERR_CODE = PHO_NO_PART_FOUND) THEN <br />
TPWrite "NO PART FOUND OR PLANNING PATH FAILED";<br />
pho_request_scan;<br />
<br />
! If bin picking has not been initialized or service returned error response, reinitialize and trigger new scan (Adopt if needed)<br />
ELSEIF(PHO_ERR_CODE = PHO_NOT_INITIALIZED) THEN<br />
<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
ELSEIF (PHO_ERR_CODE = PHO_SERVICE_ERR ) THEN<br />
<br />
Waittime 10;<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! In case of communication failure, rapid program is terminated immediatelly<br />
ELSEIF (PHO_ERR_CODE = PHO_BAD_DATA OR PHO_ERR_CODE = PHO_TIMEOUT OR PHO_ERR_CODE = PHO_COM_FAILURE ) THEN<br />
ErrLog 4800, "Photoneo internal error", "Communication failure!", "Please reboot the Vision controller"," "," ";<br />
EXIT;<br />
<br />
! Otherwise trigger next scan and try to continue<br />
ELSE<br />
pho_request_scan;<br />
ENDIF<br />
<br />
err_counter := err_counter + 1;<br />
! reset error flag for next cycle<br />
PHO_OCCURRED_ERR := FALSE;<br />
<br />
ENDPROC<br />
<br />
== 5. Runtime ==<br />
<br />
Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File: waiting_for_server_2.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Open Main Menu, browse to '''Production Window''' and '''Set PP to Main''' - at the beginning of the main function:<br />
<br />
<br />
[[File: pp_to_main_2.png]]<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required:<br />
<br />
<br />
[[File: override_vel_2.png]]<br />
<br />
<br />
Hit the '''Play''' button in AUTO mode or '''Enable + Play''' button in MANUAL mode and you should see the following application output:<br />
<br />
<br />
[[File: binpicking_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Autostart_application.png&diff=499File:Autostart application.png2018-04-10T14:55:37Z<p>Michald: </p>
<hr />
<div></div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Open_app.png&diff=498File:Open app.png2018-04-10T14:55:11Z<p>Michald: </p>
<hr />
<div></div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=497Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-10T14:53:36Z<p>Michald: /* 3.5 Load Application */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:Robot staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:staubli_pendant_load_app.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu. V Main menu vybrat Application manager (Kliknut enter alebo Right). V application manger je potrebne otvorit aplikacie kliknutim na F7 (open). Nasledne z disku vyberte main_application<br />
<br />
<br />
Vratte sa na spat na hlavnu obrazku (Tlacidlo home). A nasledne otvorte VAL3 applications. Klik na dolnu listu, ktora vyroluje widget a v nom kliknut na V, tak ako je to znazornene na obrazku<br />
<br />
<br />
[[File:open_app.png]]<br />
<br />
<br />
Rolovaci widget zatvorte a kliknite na '''main_application''' a nastavte ju na autostart<br />
<br />
<br />
[[File:autostart_application.png]]<br />
<br />
Aplikacia je tak nachystana na spustenie<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''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. <br />
<br />
'''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. <br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the RAPID program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the RAPID program continues immediately at the next line.<br />
<br />
'''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. <br />
<br />
'''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). <br />
<br />
'''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.<br />
<br />
'''pho_calib_set()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''pho_calib_reset()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''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.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 RAPID CONFIG ===<br />
<br />
'''CustomerDefinitions module''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''open_gripper()''' - implement function for opening your gripper here <br />
<br />
- '''close_gripper()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''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) <br />
<br />
- '''pho_bin_picking_simple()''' - a very basic bin picking sequence (for experimental purposes)<br />
<br />
- '''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 !!!'''<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 RAPID ERROR HANDLING === <br />
<br />
Photoneo BP solution 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. <br />
<br />
'''PHO_NO_ERR := 0''' - Service response from Vision Controller is valid <br />
<br />
'''PHO_SERVICE_ERR := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''PHO_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''PHO_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''PHO_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''PHO_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''PHO_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''PHO_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''PHO_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''PHO_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''PHO_COLLISION_DETECT := 205''' - Collision has been detected<br />
<br />
'''PHO_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 MAIN MODULE ===<br />
<br />
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. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
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. <br />
<br />
<br />
<br />
MODULE MainModule<br />
<br />
! Copyright (c) 2018 Photoneo s.r.o.<br />
! All rights reserved<br />
! Description: Main bin picking module<br />
!<br />
! Home, start and end binpicking target variables<br />
VAR robtarget home_pose;<br />
VAR robtarget start_bin_picking_robtarget;<br />
VAR robtarget end_bin_picking_robtarget;<br />
VAR jointtarget start_bin_picking_jointtarget;<br />
VAR jointtarget end_bin_picking_jointtarget;<br />
<br />
! Error handling variables<br />
VAR num err_counter;<br />
CONST num MAX_ERR_COUNT := 2;<br />
<br />
PROC main()<br />
<br />
!calibration; ! If bin picking is about to be executed comment this line<br />
bin_picking; ! If calibration is about to be executed comment this line<br />
<br />
ENDPROC <br />
<br />
==== 4.4.2 bin_picking() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
! BIN PICKING<br />
! This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
! bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
! of the code to meet specific workcell and application requirements here. <br />
!<br />
PROC bin_picking()<br />
<br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
<br />
PHO_ERR_CODE := PHO_PLANNING_FAILED;<br />
! <br />
! RETEACH home position for your application<br />
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]];<br />
!<br />
! RETEACH bin picking start and end pose<br />
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]];<br />
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]];<br />
!<br />
! Convert cartesian position to jointtarget<br />
start_bin_picking_jointtarget := CalcJointT(start_bin_picking_robtarget, tool0);<br />
end_bin_picking_jointtarget := CalcJointT(end_bin_picking_robtarget, tool0);<br />
!<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004 ;<br />
! <br />
! Send bin picking initialization request to the Vision Controller, <br />
! start and end poses defined above will be used in trajectory planning pipeline<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
! <br />
! Move robot away from scanning area - reteach this position for your robot and workcell<br />
MoveJ home_pose, v500, z30, tool0;<br />
! <br />
! When robot is away from scanning area, trigger first scan and localization<br />
pho_request_scan;<br />
!<br />
WHILE true DO<br />
scan_again: <br />
!==================== PHOTONEO BIN PICKING START ===========================<br />
! Wait until scanning is completed<br />
pho_wait_for_scan_completion;<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ENDIF <br />
!<br />
! Trigger trajectory planning<br />
pho_request_trajectory;<br />
!<br />
! While trajectory is being calculated, move robot to bin picking start position<br />
MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;<br />
!<br />
! Execute bin picking application, calculated trajectory is received here<br />
pho_bin_picking; <br />
!==================== PHOTONEO BIN PICKING END ===========================<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ELSE <br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
!<br />
!==================== PLACING START==================================<br />
! Move robot from bin picking end position away from scanning area - reteach this position for your robot and workcell<br />
! 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;<br />
!<br />
! Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
pho_request_scan;<br />
!<br />
! Commands for actual part placing - reteach positions for your robot and workcell<br />
! 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;<br />
! open_gripper;<br />
! 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; <br />
!==================== PLACING END=================================== <br />
ENDIF <br />
ENDWHILE <br />
ENDPROC<br />
<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
! CALIBRATION<br />
! Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
! It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
! Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
PROC calibration()<br />
<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004;<br />
! <br />
! 1. calibration waypoint <br />
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;<br />
pho_request_calib_add_point;<br />
! <br />
! 2. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 3. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 4. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 5. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 6. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! Finally set calibration result to the PhoXi Scanner<br />
TPWrite "Setting calibration result to the PhoXi Scanner!";<br />
pho_request_calib_set; <br />
TPWrite "Calibration complete!";<br />
EXIT;<br />
<br />
ENDPROC<br />
<br />
==== 4.4.4 err_handling() ====<br />
<br />
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. <br />
<br />
! ERROR HANDLING<br />
! Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
! For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
! communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
PROC err_handling()<br />
<br />
!--Release gripper if needed<br />
!open_gripper;<br />
<br />
! Move robot to home pose<br />
MoveJ home_pose, v500, z30, tool0;<br />
<br />
!--Display error<br />
TPWrite pho_err_info(PHO_ERR_CODE);<br />
<br />
IF err_counter >= MAX_ERR_COUNT THEN<br />
ErrLog 4800, "Photoneo internal error", pho_err_info(PHO_ERR_CODE), "Please reboot the Vision controller and restart application"," ", " ";<br />
EXIT;<br />
ENDIF<br />
<br />
! If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
IF (PHO_ERR_CODE = PHO_PLANNING_FAILED OR PHO_ERR_CODE = PHO_NO_PART_FOUND) THEN <br />
TPWrite "NO PART FOUND OR PLANNING PATH FAILED";<br />
pho_request_scan;<br />
<br />
! If bin picking has not been initialized or service returned error response, reinitialize and trigger new scan (Adopt if needed)<br />
ELSEIF(PHO_ERR_CODE = PHO_NOT_INITIALIZED) THEN<br />
<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
ELSEIF (PHO_ERR_CODE = PHO_SERVICE_ERR ) THEN<br />
<br />
Waittime 10;<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! In case of communication failure, rapid program is terminated immediatelly<br />
ELSEIF (PHO_ERR_CODE = PHO_BAD_DATA OR PHO_ERR_CODE = PHO_TIMEOUT OR PHO_ERR_CODE = PHO_COM_FAILURE ) THEN<br />
ErrLog 4800, "Photoneo internal error", "Communication failure!", "Please reboot the Vision controller"," "," ";<br />
EXIT;<br />
<br />
! Otherwise trigger next scan and try to continue<br />
ELSE<br />
pho_request_scan;<br />
ENDIF<br />
<br />
err_counter := err_counter + 1;<br />
! reset error flag for next cycle<br />
PHO_OCCURRED_ERR := FALSE;<br />
<br />
ENDPROC<br />
<br />
== 5. Runtime ==<br />
<br />
Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File: waiting_for_server_2.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Open Main Menu, browse to '''Production Window''' and '''Set PP to Main''' - at the beginning of the main function:<br />
<br />
<br />
[[File: pp_to_main_2.png]]<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required:<br />
<br />
<br />
[[File: override_vel_2.png]]<br />
<br />
<br />
Hit the '''Play''' button in AUTO mode or '''Enable + Play''' button in MANUAL mode and you should see the following application output:<br />
<br />
<br />
[[File: binpicking_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Staubli_pendant_load_app.png&diff=496File:Staubli pendant load app.png2018-04-10T14:01:40Z<p>Michald: </p>
<hr />
<div></div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=495Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-09T08:04:21Z<p>Michald: /* 4.1 VAL3 API */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:Robot staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:staubli_pendant_load_app.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu '''todo napisat aspon kombinaciu tlacidiel'''<br />
<br />
<br />
[[File:setup_auto_load.png]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''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. <br />
<br />
'''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. <br />
<br />
'''scan_request()''' - request to trigger the next scan and localization. Non-blocking request; the RAPID program continues immediately at the next line.<br />
<br />
'''wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''trajectory_request()''' - request to start trajectory planning for current goal. Non-blocking function; the RAPID program continues immediately at the next line.<br />
<br />
'''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. <br />
<br />
'''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). <br />
<br />
'''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.<br />
<br />
'''pho_calib_set()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''pho_calib_reset()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''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.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 RAPID CONFIG ===<br />
<br />
'''CustomerDefinitions module''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''open_gripper()''' - implement function for opening your gripper here <br />
<br />
- '''close_gripper()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''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) <br />
<br />
- '''pho_bin_picking_simple()''' - a very basic bin picking sequence (for experimental purposes)<br />
<br />
- '''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 !!!'''<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 RAPID ERROR HANDLING === <br />
<br />
Photoneo BP solution 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. <br />
<br />
'''PHO_NO_ERR := 0''' - Service response from Vision Controller is valid <br />
<br />
'''PHO_SERVICE_ERR := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''PHO_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''PHO_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''PHO_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''PHO_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''PHO_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''PHO_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''PHO_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''PHO_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''PHO_COLLISION_DETECT := 205''' - Collision has been detected<br />
<br />
'''PHO_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 MAIN MODULE ===<br />
<br />
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. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
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. <br />
<br />
<br />
<br />
MODULE MainModule<br />
<br />
! Copyright (c) 2018 Photoneo s.r.o.<br />
! All rights reserved<br />
! Description: Main bin picking module<br />
!<br />
! Home, start and end binpicking target variables<br />
VAR robtarget home_pose;<br />
VAR robtarget start_bin_picking_robtarget;<br />
VAR robtarget end_bin_picking_robtarget;<br />
VAR jointtarget start_bin_picking_jointtarget;<br />
VAR jointtarget end_bin_picking_jointtarget;<br />
<br />
! Error handling variables<br />
VAR num err_counter;<br />
CONST num MAX_ERR_COUNT := 2;<br />
<br />
PROC main()<br />
<br />
!calibration; ! If bin picking is about to be executed comment this line<br />
bin_picking; ! If calibration is about to be executed comment this line<br />
<br />
ENDPROC <br />
<br />
==== 4.4.2 bin_picking() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
! BIN PICKING<br />
! This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
! bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
! of the code to meet specific workcell and application requirements here. <br />
!<br />
PROC bin_picking()<br />
<br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
<br />
PHO_ERR_CODE := PHO_PLANNING_FAILED;<br />
! <br />
! RETEACH home position for your application<br />
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]];<br />
!<br />
! RETEACH bin picking start and end pose<br />
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]];<br />
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]];<br />
!<br />
! Convert cartesian position to jointtarget<br />
start_bin_picking_jointtarget := CalcJointT(start_bin_picking_robtarget, tool0);<br />
end_bin_picking_jointtarget := CalcJointT(end_bin_picking_robtarget, tool0);<br />
!<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004 ;<br />
! <br />
! Send bin picking initialization request to the Vision Controller, <br />
! start and end poses defined above will be used in trajectory planning pipeline<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
! <br />
! Move robot away from scanning area - reteach this position for your robot and workcell<br />
MoveJ home_pose, v500, z30, tool0;<br />
! <br />
! When robot is away from scanning area, trigger first scan and localization<br />
pho_request_scan;<br />
!<br />
WHILE true DO<br />
scan_again: <br />
!==================== PHOTONEO BIN PICKING START ===========================<br />
! Wait until scanning is completed<br />
pho_wait_for_scan_completion;<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ENDIF <br />
!<br />
! Trigger trajectory planning<br />
pho_request_trajectory;<br />
!<br />
! While trajectory is being calculated, move robot to bin picking start position<br />
MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;<br />
!<br />
! Execute bin picking application, calculated trajectory is received here<br />
pho_bin_picking; <br />
!==================== PHOTONEO BIN PICKING END ===========================<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ELSE <br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
!<br />
!==================== PLACING START==================================<br />
! Move robot from bin picking end position away from scanning area - reteach this position for your robot and workcell<br />
! 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;<br />
!<br />
! Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
pho_request_scan;<br />
!<br />
! Commands for actual part placing - reteach positions for your robot and workcell<br />
! 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;<br />
! open_gripper;<br />
! 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; <br />
!==================== PLACING END=================================== <br />
ENDIF <br />
ENDWHILE <br />
ENDPROC<br />
<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
! CALIBRATION<br />
! Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
! It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
! Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
PROC calibration()<br />
<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004;<br />
! <br />
! 1. calibration waypoint <br />
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;<br />
pho_request_calib_add_point;<br />
! <br />
! 2. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 3. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 4. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 5. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 6. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! Finally set calibration result to the PhoXi Scanner<br />
TPWrite "Setting calibration result to the PhoXi Scanner!";<br />
pho_request_calib_set; <br />
TPWrite "Calibration complete!";<br />
EXIT;<br />
<br />
ENDPROC<br />
<br />
==== 4.4.4 err_handling() ====<br />
<br />
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. <br />
<br />
! ERROR HANDLING<br />
! Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
! For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
! communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
PROC err_handling()<br />
<br />
!--Release gripper if needed<br />
!open_gripper;<br />
<br />
! Move robot to home pose<br />
MoveJ home_pose, v500, z30, tool0;<br />
<br />
!--Display error<br />
TPWrite pho_err_info(PHO_ERR_CODE);<br />
<br />
IF err_counter >= MAX_ERR_COUNT THEN<br />
ErrLog 4800, "Photoneo internal error", pho_err_info(PHO_ERR_CODE), "Please reboot the Vision controller and restart application"," ", " ";<br />
EXIT;<br />
ENDIF<br />
<br />
! If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
IF (PHO_ERR_CODE = PHO_PLANNING_FAILED OR PHO_ERR_CODE = PHO_NO_PART_FOUND) THEN <br />
TPWrite "NO PART FOUND OR PLANNING PATH FAILED";<br />
pho_request_scan;<br />
<br />
! If bin picking has not been initialized or service returned error response, reinitialize and trigger new scan (Adopt if needed)<br />
ELSEIF(PHO_ERR_CODE = PHO_NOT_INITIALIZED) THEN<br />
<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
ELSEIF (PHO_ERR_CODE = PHO_SERVICE_ERR ) THEN<br />
<br />
Waittime 10;<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! In case of communication failure, rapid program is terminated immediatelly<br />
ELSEIF (PHO_ERR_CODE = PHO_BAD_DATA OR PHO_ERR_CODE = PHO_TIMEOUT OR PHO_ERR_CODE = PHO_COM_FAILURE ) THEN<br />
ErrLog 4800, "Photoneo internal error", "Communication failure!", "Please reboot the Vision controller"," "," ";<br />
EXIT;<br />
<br />
! Otherwise trigger next scan and try to continue<br />
ELSE<br />
pho_request_scan;<br />
ENDIF<br />
<br />
err_counter := err_counter + 1;<br />
! reset error flag for next cycle<br />
PHO_OCCURRED_ERR := FALSE;<br />
<br />
ENDPROC<br />
<br />
== 5. Runtime ==<br />
<br />
Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File: waiting_for_server_2.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Open Main Menu, browse to '''Production Window''' and '''Set PP to Main''' - at the beginning of the main function:<br />
<br />
<br />
[[File: pp_to_main_2.png]]<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required:<br />
<br />
<br />
[[File: override_vel_2.png]]<br />
<br />
<br />
Hit the '''Play''' button in AUTO mode or '''Enable + Play''' button in MANUAL mode and you should see the following application output:<br />
<br />
<br />
[[File: binpicking_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=494Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-09T08:00:35Z<p>Michald: /* 4. VAL3 */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:Robot staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:staubli_pendant_load_app.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu '''todo napisat aspon kombinaciu tlacidiel'''<br />
<br />
<br />
[[File:setup_auto_load.png]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
Photoneo Staubli interface was designed to be easily integrated into existing application written in VAL3 code. It provides two means which influence the final robot behavior: <br />
<br />
- '''VAL3 API''' - set of VAL3 requests (or procedures) used to control the bin picking sequence. Requests are defined in photoneo_common application and used within main_module application <br />
<br />
- '''VAL3 CONFIG''' - '''customer_definitions application''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 VAL3 API ===<br />
<br />
The following API describes the functionality of requests provided by Photoneo Stabli Interface. These requests are intended for high level control of bin picking sequences and are usually called in main_module application. <br />
--------------------------------------------------------<br />
'''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. <br />
<br />
'''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. <br />
<br />
'''pho_request_scan()''' - request to trigger the next scan and localization. Non-blocking request; the RAPID program continues immediately at the next line.<br />
<br />
'''pho_wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''pho_request_trajectory()''' - request to start trajectory planning for current goal. Non-blocking function; the RAPID program continues immediately at the next line.<br />
<br />
'''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. <br />
<br />
'''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). <br />
<br />
'''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.<br />
<br />
'''pho_calib_set()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''pho_calib_reset()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''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.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 RAPID CONFIG ===<br />
<br />
'''CustomerDefinitions module''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''open_gripper()''' - implement function for opening your gripper here <br />
<br />
- '''close_gripper()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''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) <br />
<br />
- '''pho_bin_picking_simple()''' - a very basic bin picking sequence (for experimental purposes)<br />
<br />
- '''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 !!!'''<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 RAPID ERROR HANDLING === <br />
<br />
Photoneo BP solution 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. <br />
<br />
'''PHO_NO_ERR := 0''' - Service response from Vision Controller is valid <br />
<br />
'''PHO_SERVICE_ERR := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''PHO_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''PHO_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''PHO_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''PHO_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''PHO_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''PHO_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''PHO_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''PHO_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''PHO_COLLISION_DETECT := 205''' - Collision has been detected<br />
<br />
'''PHO_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 MAIN MODULE ===<br />
<br />
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. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
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. <br />
<br />
<br />
<br />
MODULE MainModule<br />
<br />
! Copyright (c) 2018 Photoneo s.r.o.<br />
! All rights reserved<br />
! Description: Main bin picking module<br />
!<br />
! Home, start and end binpicking target variables<br />
VAR robtarget home_pose;<br />
VAR robtarget start_bin_picking_robtarget;<br />
VAR robtarget end_bin_picking_robtarget;<br />
VAR jointtarget start_bin_picking_jointtarget;<br />
VAR jointtarget end_bin_picking_jointtarget;<br />
<br />
! Error handling variables<br />
VAR num err_counter;<br />
CONST num MAX_ERR_COUNT := 2;<br />
<br />
PROC main()<br />
<br />
!calibration; ! If bin picking is about to be executed comment this line<br />
bin_picking; ! If calibration is about to be executed comment this line<br />
<br />
ENDPROC <br />
<br />
==== 4.4.2 bin_picking() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
! BIN PICKING<br />
! This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
! bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
! of the code to meet specific workcell and application requirements here. <br />
!<br />
PROC bin_picking()<br />
<br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
<br />
PHO_ERR_CODE := PHO_PLANNING_FAILED;<br />
! <br />
! RETEACH home position for your application<br />
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]];<br />
!<br />
! RETEACH bin picking start and end pose<br />
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]];<br />
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]];<br />
!<br />
! Convert cartesian position to jointtarget<br />
start_bin_picking_jointtarget := CalcJointT(start_bin_picking_robtarget, tool0);<br />
end_bin_picking_jointtarget := CalcJointT(end_bin_picking_robtarget, tool0);<br />
!<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004 ;<br />
! <br />
! Send bin picking initialization request to the Vision Controller, <br />
! start and end poses defined above will be used in trajectory planning pipeline<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
! <br />
! Move robot away from scanning area - reteach this position for your robot and workcell<br />
MoveJ home_pose, v500, z30, tool0;<br />
! <br />
! When robot is away from scanning area, trigger first scan and localization<br />
pho_request_scan;<br />
!<br />
WHILE true DO<br />
scan_again: <br />
!==================== PHOTONEO BIN PICKING START ===========================<br />
! Wait until scanning is completed<br />
pho_wait_for_scan_completion;<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ENDIF <br />
!<br />
! Trigger trajectory planning<br />
pho_request_trajectory;<br />
!<br />
! While trajectory is being calculated, move robot to bin picking start position<br />
MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;<br />
!<br />
! Execute bin picking application, calculated trajectory is received here<br />
pho_bin_picking; <br />
!==================== PHOTONEO BIN PICKING END ===========================<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ELSE <br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
!<br />
!==================== PLACING START==================================<br />
! Move robot from bin picking end position away from scanning area - reteach this position for your robot and workcell<br />
! 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;<br />
!<br />
! Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
pho_request_scan;<br />
!<br />
! Commands for actual part placing - reteach positions for your robot and workcell<br />
! 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;<br />
! open_gripper;<br />
! 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; <br />
!==================== PLACING END=================================== <br />
ENDIF <br />
ENDWHILE <br />
ENDPROC<br />
<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
! CALIBRATION<br />
! Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
! It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
! Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
PROC calibration()<br />
<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004;<br />
! <br />
! 1. calibration waypoint <br />
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;<br />
pho_request_calib_add_point;<br />
! <br />
! 2. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 3. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 4. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 5. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 6. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! Finally set calibration result to the PhoXi Scanner<br />
TPWrite "Setting calibration result to the PhoXi Scanner!";<br />
pho_request_calib_set; <br />
TPWrite "Calibration complete!";<br />
EXIT;<br />
<br />
ENDPROC<br />
<br />
==== 4.4.4 err_handling() ====<br />
<br />
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. <br />
<br />
! ERROR HANDLING<br />
! Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
! For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
! communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
PROC err_handling()<br />
<br />
!--Release gripper if needed<br />
!open_gripper;<br />
<br />
! Move robot to home pose<br />
MoveJ home_pose, v500, z30, tool0;<br />
<br />
!--Display error<br />
TPWrite pho_err_info(PHO_ERR_CODE);<br />
<br />
IF err_counter >= MAX_ERR_COUNT THEN<br />
ErrLog 4800, "Photoneo internal error", pho_err_info(PHO_ERR_CODE), "Please reboot the Vision controller and restart application"," ", " ";<br />
EXIT;<br />
ENDIF<br />
<br />
! If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
IF (PHO_ERR_CODE = PHO_PLANNING_FAILED OR PHO_ERR_CODE = PHO_NO_PART_FOUND) THEN <br />
TPWrite "NO PART FOUND OR PLANNING PATH FAILED";<br />
pho_request_scan;<br />
<br />
! If bin picking has not been initialized or service returned error response, reinitialize and trigger new scan (Adopt if needed)<br />
ELSEIF(PHO_ERR_CODE = PHO_NOT_INITIALIZED) THEN<br />
<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
ELSEIF (PHO_ERR_CODE = PHO_SERVICE_ERR ) THEN<br />
<br />
Waittime 10;<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! In case of communication failure, rapid program is terminated immediatelly<br />
ELSEIF (PHO_ERR_CODE = PHO_BAD_DATA OR PHO_ERR_CODE = PHO_TIMEOUT OR PHO_ERR_CODE = PHO_COM_FAILURE ) THEN<br />
ErrLog 4800, "Photoneo internal error", "Communication failure!", "Please reboot the Vision controller"," "," ";<br />
EXIT;<br />
<br />
! Otherwise trigger next scan and try to continue<br />
ELSE<br />
pho_request_scan;<br />
ENDIF<br />
<br />
err_counter := err_counter + 1;<br />
! reset error flag for next cycle<br />
PHO_OCCURRED_ERR := FALSE;<br />
<br />
ENDPROC<br />
<br />
== 5. Runtime ==<br />
<br />
Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File: waiting_for_server_2.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Open Main Menu, browse to '''Production Window''' and '''Set PP to Main''' - at the beginning of the main function:<br />
<br />
<br />
[[File: pp_to_main_2.png]]<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required:<br />
<br />
<br />
[[File: override_vel_2.png]]<br />
<br />
<br />
Hit the '''Play''' button in AUTO mode or '''Enable + Play''' button in MANUAL mode and you should see the following application output:<br />
<br />
<br />
[[File: binpicking_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=493Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-09T07:57:20Z<p>Michald: /* 3.5 Load Application */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:Robot staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
Ako prvy krok treba kliknut na tlacidlo na pendante, ktore je znazornene na obrazku zo simulacie<br />
<br />
[[File:staubli_pendant_load_app.png]]<br />
<br />
V skaredom ciernobielom okne treba nahrat applikaciu '''todo napisat aspon kombinaciu tlacidiel'''<br />
<br />
<br />
[[File:setup_auto_load.png]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. However your VAL3 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 VAL3 API.<br />
<br />
== 4. VAL3 ==<br />
<br />
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: <br />
<br />
- '''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 <br />
<br />
- '''RAPID CONFIG''' - '''CustomerDefinitions.mod''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 RAPID API ===<br />
<br />
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. <br />
--------------------------------------------------------<br />
'''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. <br />
<br />
'''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. <br />
<br />
'''pho_request_scan()''' - request to trigger the next scan and localization. Non-blocking request; the RAPID program continues immediately at the next line.<br />
<br />
'''pho_wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''pho_request_trajectory()''' - request to start trajectory planning for current goal. Non-blocking function; the RAPID program continues immediately at the next line.<br />
<br />
'''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. <br />
<br />
'''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). <br />
<br />
'''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.<br />
<br />
'''pho_calib_set()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''pho_calib_reset()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''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.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 RAPID CONFIG ===<br />
<br />
'''CustomerDefinitions module''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''open_gripper()''' - implement function for opening your gripper here <br />
<br />
- '''close_gripper()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''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) <br />
<br />
- '''pho_bin_picking_simple()''' - a very basic bin picking sequence (for experimental purposes)<br />
<br />
- '''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 !!!'''<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 RAPID ERROR HANDLING === <br />
<br />
Photoneo BP solution 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. <br />
<br />
'''PHO_NO_ERR := 0''' - Service response from Vision Controller is valid <br />
<br />
'''PHO_SERVICE_ERR := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''PHO_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''PHO_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''PHO_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''PHO_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''PHO_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''PHO_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''PHO_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''PHO_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''PHO_COLLISION_DETECT := 205''' - Collision has been detected<br />
<br />
'''PHO_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 MAIN MODULE ===<br />
<br />
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. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
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. <br />
<br />
<br />
<br />
MODULE MainModule<br />
<br />
! Copyright (c) 2018 Photoneo s.r.o.<br />
! All rights reserved<br />
! Description: Main bin picking module<br />
!<br />
! Home, start and end binpicking target variables<br />
VAR robtarget home_pose;<br />
VAR robtarget start_bin_picking_robtarget;<br />
VAR robtarget end_bin_picking_robtarget;<br />
VAR jointtarget start_bin_picking_jointtarget;<br />
VAR jointtarget end_bin_picking_jointtarget;<br />
<br />
! Error handling variables<br />
VAR num err_counter;<br />
CONST num MAX_ERR_COUNT := 2;<br />
<br />
PROC main()<br />
<br />
!calibration; ! If bin picking is about to be executed comment this line<br />
bin_picking; ! If calibration is about to be executed comment this line<br />
<br />
ENDPROC <br />
<br />
==== 4.4.2 bin_picking() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
! BIN PICKING<br />
! This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
! bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
! of the code to meet specific workcell and application requirements here. <br />
!<br />
PROC bin_picking()<br />
<br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
<br />
PHO_ERR_CODE := PHO_PLANNING_FAILED;<br />
! <br />
! RETEACH home position for your application<br />
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]];<br />
!<br />
! RETEACH bin picking start and end pose<br />
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]];<br />
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]];<br />
!<br />
! Convert cartesian position to jointtarget<br />
start_bin_picking_jointtarget := CalcJointT(start_bin_picking_robtarget, tool0);<br />
end_bin_picking_jointtarget := CalcJointT(end_bin_picking_robtarget, tool0);<br />
!<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004 ;<br />
! <br />
! Send bin picking initialization request to the Vision Controller, <br />
! start and end poses defined above will be used in trajectory planning pipeline<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
! <br />
! Move robot away from scanning area - reteach this position for your robot and workcell<br />
MoveJ home_pose, v500, z30, tool0;<br />
! <br />
! When robot is away from scanning area, trigger first scan and localization<br />
pho_request_scan;<br />
!<br />
WHILE true DO<br />
scan_again: <br />
!==================== PHOTONEO BIN PICKING START ===========================<br />
! Wait until scanning is completed<br />
pho_wait_for_scan_completion;<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ENDIF <br />
!<br />
! Trigger trajectory planning<br />
pho_request_trajectory;<br />
!<br />
! While trajectory is being calculated, move robot to bin picking start position<br />
MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;<br />
!<br />
! Execute bin picking application, calculated trajectory is received here<br />
pho_bin_picking; <br />
!==================== PHOTONEO BIN PICKING END ===========================<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ELSE <br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
!<br />
!==================== PLACING START==================================<br />
! Move robot from bin picking end position away from scanning area - reteach this position for your robot and workcell<br />
! 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;<br />
!<br />
! Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
pho_request_scan;<br />
!<br />
! Commands for actual part placing - reteach positions for your robot and workcell<br />
! 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;<br />
! open_gripper;<br />
! 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; <br />
!==================== PLACING END=================================== <br />
ENDIF <br />
ENDWHILE <br />
ENDPROC<br />
<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
! CALIBRATION<br />
! Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
! It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
! Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
PROC calibration()<br />
<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004;<br />
! <br />
! 1. calibration waypoint <br />
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;<br />
pho_request_calib_add_point;<br />
! <br />
! 2. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 3. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 4. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 5. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 6. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! Finally set calibration result to the PhoXi Scanner<br />
TPWrite "Setting calibration result to the PhoXi Scanner!";<br />
pho_request_calib_set; <br />
TPWrite "Calibration complete!";<br />
EXIT;<br />
<br />
ENDPROC<br />
<br />
==== 4.4.4 err_handling() ====<br />
<br />
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. <br />
<br />
! ERROR HANDLING<br />
! Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
! For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
! communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
PROC err_handling()<br />
<br />
!--Release gripper if needed<br />
!open_gripper;<br />
<br />
! Move robot to home pose<br />
MoveJ home_pose, v500, z30, tool0;<br />
<br />
!--Display error<br />
TPWrite pho_err_info(PHO_ERR_CODE);<br />
<br />
IF err_counter >= MAX_ERR_COUNT THEN<br />
ErrLog 4800, "Photoneo internal error", pho_err_info(PHO_ERR_CODE), "Please reboot the Vision controller and restart application"," ", " ";<br />
EXIT;<br />
ENDIF<br />
<br />
! If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
IF (PHO_ERR_CODE = PHO_PLANNING_FAILED OR PHO_ERR_CODE = PHO_NO_PART_FOUND) THEN <br />
TPWrite "NO PART FOUND OR PLANNING PATH FAILED";<br />
pho_request_scan;<br />
<br />
! If bin picking has not been initialized or service returned error response, reinitialize and trigger new scan (Adopt if needed)<br />
ELSEIF(PHO_ERR_CODE = PHO_NOT_INITIALIZED) THEN<br />
<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
ELSEIF (PHO_ERR_CODE = PHO_SERVICE_ERR ) THEN<br />
<br />
Waittime 10;<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! In case of communication failure, rapid program is terminated immediatelly<br />
ELSEIF (PHO_ERR_CODE = PHO_BAD_DATA OR PHO_ERR_CODE = PHO_TIMEOUT OR PHO_ERR_CODE = PHO_COM_FAILURE ) THEN<br />
ErrLog 4800, "Photoneo internal error", "Communication failure!", "Please reboot the Vision controller"," "," ";<br />
EXIT;<br />
<br />
! Otherwise trigger next scan and try to continue<br />
ELSE<br />
pho_request_scan;<br />
ENDIF<br />
<br />
err_counter := err_counter + 1;<br />
! reset error flag for next cycle<br />
PHO_OCCURRED_ERR := FALSE;<br />
<br />
ENDPROC<br />
<br />
== 5. Runtime ==<br />
<br />
Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File: waiting_for_server_2.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Open Main Menu, browse to '''Production Window''' and '''Set PP to Main''' - at the beginning of the main function:<br />
<br />
<br />
[[File: pp_to_main_2.png]]<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required:<br />
<br />
<br />
[[File: override_vel_2.png]]<br />
<br />
<br />
Hit the '''Play''' button in AUTO mode or '''Enable + Play''' button in MANUAL mode and you should see the following application output:<br />
<br />
<br />
[[File: binpicking_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=492Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-09T07:48:39Z<p>Michald: </p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:Robot staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
<br />
=== 3.5 Load Application ===<br />
<br />
V skaredom ciernobielom okne<br />
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. <br />
<br />
Right Click on '''T_ROB1''' task and select '''Load Module''' or '''Load Module From Controller''':<br />
<br />
<br />
[[File:Robot studio load module.png]]<br />
<br />
<br />
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:<br />
<br />
<br />
[[File:Robot studio final panel2.png]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. 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. <br />
<br />
== 4. VAL3 ==<br />
<br />
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: <br />
<br />
- '''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 <br />
<br />
- '''RAPID CONFIG''' - '''CustomerDefinitions.mod''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 RAPID API ===<br />
<br />
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. <br />
--------------------------------------------------------<br />
'''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. <br />
<br />
'''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. <br />
<br />
'''pho_request_scan()''' - request to trigger the next scan and localization. Non-blocking request; the RAPID program continues immediately at the next line.<br />
<br />
'''pho_wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''pho_request_trajectory()''' - request to start trajectory planning for current goal. Non-blocking function; the RAPID program continues immediately at the next line.<br />
<br />
'''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. <br />
<br />
'''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). <br />
<br />
'''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.<br />
<br />
'''pho_calib_set()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''pho_calib_reset()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''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.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 RAPID CONFIG ===<br />
<br />
'''CustomerDefinitions module''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''open_gripper()''' - implement function for opening your gripper here <br />
<br />
- '''close_gripper()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''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) <br />
<br />
- '''pho_bin_picking_simple()''' - a very basic bin picking sequence (for experimental purposes)<br />
<br />
- '''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 !!!'''<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 RAPID ERROR HANDLING === <br />
<br />
Photoneo BP solution 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. <br />
<br />
'''PHO_NO_ERR := 0''' - Service response from Vision Controller is valid <br />
<br />
'''PHO_SERVICE_ERR := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''PHO_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''PHO_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''PHO_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''PHO_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''PHO_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''PHO_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''PHO_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''PHO_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''PHO_COLLISION_DETECT := 205''' - Collision has been detected<br />
<br />
'''PHO_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 MAIN MODULE ===<br />
<br />
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. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
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. <br />
<br />
<br />
<br />
MODULE MainModule<br />
<br />
! Copyright (c) 2018 Photoneo s.r.o.<br />
! All rights reserved<br />
! Description: Main bin picking module<br />
!<br />
! Home, start and end binpicking target variables<br />
VAR robtarget home_pose;<br />
VAR robtarget start_bin_picking_robtarget;<br />
VAR robtarget end_bin_picking_robtarget;<br />
VAR jointtarget start_bin_picking_jointtarget;<br />
VAR jointtarget end_bin_picking_jointtarget;<br />
<br />
! Error handling variables<br />
VAR num err_counter;<br />
CONST num MAX_ERR_COUNT := 2;<br />
<br />
PROC main()<br />
<br />
!calibration; ! If bin picking is about to be executed comment this line<br />
bin_picking; ! If calibration is about to be executed comment this line<br />
<br />
ENDPROC <br />
<br />
==== 4.4.2 bin_picking() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
! BIN PICKING<br />
! This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
! bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
! of the code to meet specific workcell and application requirements here. <br />
!<br />
PROC bin_picking()<br />
<br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
<br />
PHO_ERR_CODE := PHO_PLANNING_FAILED;<br />
! <br />
! RETEACH home position for your application<br />
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]];<br />
!<br />
! RETEACH bin picking start and end pose<br />
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]];<br />
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]];<br />
!<br />
! Convert cartesian position to jointtarget<br />
start_bin_picking_jointtarget := CalcJointT(start_bin_picking_robtarget, tool0);<br />
end_bin_picking_jointtarget := CalcJointT(end_bin_picking_robtarget, tool0);<br />
!<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004 ;<br />
! <br />
! Send bin picking initialization request to the Vision Controller, <br />
! start and end poses defined above will be used in trajectory planning pipeline<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
! <br />
! Move robot away from scanning area - reteach this position for your robot and workcell<br />
MoveJ home_pose, v500, z30, tool0;<br />
! <br />
! When robot is away from scanning area, trigger first scan and localization<br />
pho_request_scan;<br />
!<br />
WHILE true DO<br />
scan_again: <br />
!==================== PHOTONEO BIN PICKING START ===========================<br />
! Wait until scanning is completed<br />
pho_wait_for_scan_completion;<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ENDIF <br />
!<br />
! Trigger trajectory planning<br />
pho_request_trajectory;<br />
!<br />
! While trajectory is being calculated, move robot to bin picking start position<br />
MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;<br />
!<br />
! Execute bin picking application, calculated trajectory is received here<br />
pho_bin_picking; <br />
!==================== PHOTONEO BIN PICKING END ===========================<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ELSE <br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
!<br />
!==================== PLACING START==================================<br />
! Move robot from bin picking end position away from scanning area - reteach this position for your robot and workcell<br />
! 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;<br />
!<br />
! Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
pho_request_scan;<br />
!<br />
! Commands for actual part placing - reteach positions for your robot and workcell<br />
! 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;<br />
! open_gripper;<br />
! 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; <br />
!==================== PLACING END=================================== <br />
ENDIF <br />
ENDWHILE <br />
ENDPROC<br />
<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
! CALIBRATION<br />
! Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
! It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
! Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
PROC calibration()<br />
<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004;<br />
! <br />
! 1. calibration waypoint <br />
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;<br />
pho_request_calib_add_point;<br />
! <br />
! 2. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 3. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 4. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 5. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 6. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! Finally set calibration result to the PhoXi Scanner<br />
TPWrite "Setting calibration result to the PhoXi Scanner!";<br />
pho_request_calib_set; <br />
TPWrite "Calibration complete!";<br />
EXIT;<br />
<br />
ENDPROC<br />
<br />
==== 4.4.4 err_handling() ====<br />
<br />
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. <br />
<br />
! ERROR HANDLING<br />
! Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
! For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
! communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
PROC err_handling()<br />
<br />
!--Release gripper if needed<br />
!open_gripper;<br />
<br />
! Move robot to home pose<br />
MoveJ home_pose, v500, z30, tool0;<br />
<br />
!--Display error<br />
TPWrite pho_err_info(PHO_ERR_CODE);<br />
<br />
IF err_counter >= MAX_ERR_COUNT THEN<br />
ErrLog 4800, "Photoneo internal error", pho_err_info(PHO_ERR_CODE), "Please reboot the Vision controller and restart application"," ", " ";<br />
EXIT;<br />
ENDIF<br />
<br />
! If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
IF (PHO_ERR_CODE = PHO_PLANNING_FAILED OR PHO_ERR_CODE = PHO_NO_PART_FOUND) THEN <br />
TPWrite "NO PART FOUND OR PLANNING PATH FAILED";<br />
pho_request_scan;<br />
<br />
! If bin picking has not been initialized or service returned error response, reinitialize and trigger new scan (Adopt if needed)<br />
ELSEIF(PHO_ERR_CODE = PHO_NOT_INITIALIZED) THEN<br />
<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
ELSEIF (PHO_ERR_CODE = PHO_SERVICE_ERR ) THEN<br />
<br />
Waittime 10;<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! In case of communication failure, rapid program is terminated immediatelly<br />
ELSEIF (PHO_ERR_CODE = PHO_BAD_DATA OR PHO_ERR_CODE = PHO_TIMEOUT OR PHO_ERR_CODE = PHO_COM_FAILURE ) THEN<br />
ErrLog 4800, "Photoneo internal error", "Communication failure!", "Please reboot the Vision controller"," "," ";<br />
EXIT;<br />
<br />
! Otherwise trigger next scan and try to continue<br />
ELSE<br />
pho_request_scan;<br />
ENDIF<br />
<br />
err_counter := err_counter + 1;<br />
! reset error flag for next cycle<br />
PHO_OCCURRED_ERR := FALSE;<br />
<br />
ENDPROC<br />
<br />
== 5. Runtime ==<br />
<br />
Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File: waiting_for_server_2.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Open Main Menu, browse to '''Production Window''' and '''Set PP to Main''' - at the beginning of the main function:<br />
<br />
<br />
[[File: pp_to_main_2.png]]<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required:<br />
<br />
<br />
[[File: override_vel_2.png]]<br />
<br />
<br />
Hit the '''Play''' button in AUTO mode or '''Enable + Play''' button in MANUAL mode and you should see the following application output:<br />
<br />
<br />
[[File: binpicking_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=Bin_Picking_Tutorial:_Setting_up_Photoneo_Bin_Picking_Studio_with_STAUBLI_robots&diff=491Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with STAUBLI robots2018-04-09T07:45:12Z<p>Michald: /* 3.4 Transfer files */</p>
<hr />
<div>== 1. Prerequisities ==<br />
<br />
Photoneo Stäubli Interface is compatible with '''CS9 controler'''. <br />
<br />
Mozno by to islo aj na CS8 len je potrebne spravit upravy v kode.<br />
Pre instalaciu photoneo aplikacie je potrebne pouzit Stäubli Robotics Suite a mat k dispozicii licencny kluc<br />
<br />
<br />
NOTE: Use of '''Stäubli Robotics Suite 2016.6.1''' or higher is highly recommended for Photoneo Stäubli Interface setup.<br />
<br />
== 2. CS9 Controller setup ==<br />
<br />
The following tutorial gives a step by step guide of how to configure your Stäubli CS9 controller and install all necessary VAL3 applications you will need to get the robot interface for Photoneo Binpicking Solution up and running. <br />
<br />
This tutorial was originally written using the latest '''Stäubli Robotics Suite 2016.6.1''', however it should be compatible with older versions with minor changes. <br />
<br />
=== 2.1 Network configuration ===<br />
<br />
Turn on the CS9 Controller, wait for the Initialization Screen to appear, open the '''Settings''' and select the '''Network''' option:<br />
<br />
<br />
[[File:staubli_menu_network.png]]<br />
<br />
<br />
In the Network pane, setup your network interfaces. Jeden pre Robot Suite, druhy pre binpicking<br />
<br />
<br />
[[File:staubli_network_setup.png]] <br />
<br />
<br />
<br />
== 3 STAUBLI Robotics Suite ==<br />
<br />
=== 3.1 Create new project ===<br />
<br />
Klikny na '''new''' a potom na '''new cell wizard'''<br />
<br />
[[File:staubli_new_project.png]]<br />
<br />
Zadaj nazov projektu a cestu<br />
<br />
Klikny next<br />
<br />
vyber '''Add a local controller from a remote controller'''. Pre vyber je '''Add a local controller''' je potom potrebne rucne nastavit kontroler a robota<br />
<br />
[[File:staubli_remote_controller.png]]<br />
<br />
Nastav host kliknut na '''...'''<br />
<br />
[[File:staubli_conection.png]]<br />
<br />
Nastav IP robota, nastav user name na maintenance. Default heslo spec_cal<br />
<br />
klikny na ok a nasledne na next<br />
<br />
Ak je vsetko ok, tak sa napise hlaska<br />
<br />
[[File:staubli_success_transfer.png]]<br />
<br />
=== 3.2 Copy the application ===<br />
<br />
Nakopirovat progamy resp. priecinky (photoneo_common, customer_definitions, main_application) vo windows filesysteme z val3 (miesto kde budu ulozene programy) do vytvoreneho projektu: Project_name\Controller_name\usr\usrapp<br />
<br />
V Staubli Robotics Suite kliknut v cell explorer na project_name->controller_name (pravym tlacidlom na controller_name) a vybrat '''open application''' a postupne vybrat vsetky 3 aplikacie. Otvarat je potrebne subory typu .pjx<br />
<br />
[[File:staubli_open_app.png]]<br />
<br />
<br />
Vysledkom by malo byt otvorene 3 aplikacie znazornene na obrazku<br />
<br />
[[File:staubli_apps.png]]<br />
<br />
=== 3.3 Nevyhnutne upravy phptoneo_common ===<br />
<br />
==== 3.3.1 Nastavenie fBaseLink ====<br />
<br />
treba nastavit spravnu hodnotu Z offsetu (asi podla tabulky)<br />
<br />
<br />
[[File:fBaseLink.png]]<br />
<br />
==== 3.3.2 Nastavenie socketu ====<br />
<br />
V hornej liste v home kliknut na Physical IO's. V tabulke pravym kliknut na socket a vybrat Edit Board<br />
<br />
<br />
[[File:socket_setup.png]]<br />
<br />
V novom okne je potrebne kliknut na '''+''' a vybrat '''tcp client'''<br />
<br />
<br />
[[File:add_tcp_client.png]]<br />
<br />
Vyplnit udaje podla fotky<br />
<br />
[[File:staubli_tcp_client.png]]<br />
<br />
Zopakovat to iste pre '''tcp server'''<br />
<br />
[[File:staubli_tcp_server.png]]<br />
<br />
<br />
Na zaver treba skontrolovat, ci globalna premenna '''sPHOCLIENT''' a '''sPHOSERVER''' su naozaj nalinkovane na vytvorene sockety. <br />
<br />
'''sPHOCLIENT''' by mal v stlpci '''lo''' obsahovat '''Sockets\PhotoneoClient'''. Ak nie treba mu vybrat spravny socket dvojklikom na bunku v stlpci '''lo'''.<br />
<br />
[[File:socket_link.png]]<br />
<br />
To iste je potrebne skontrolovat aj pre '''sPHOSERVER''', ktory by mal obsahovat '''Sockets\PhotoneoStateServer'''.<br />
<br />
===== 3.3.3 Nastavenie start a end pose =====<br />
<br />
V globalnych premennych '''jStartPose''' a '''jEndPose''', treba nastavit vhodne hodnoty klbovych premmenych pre startovu a koncovu polohu binpickingu<br />
<br />
[[File:staubli_start_pose.png]]<br />
<br />
=== 3.4 Transfer files ===<br />
<br />
Na presun suborov existuje nastroj '''Transfer manager''' v hornej liste v zalozke '''home'''. Po kliknuty na ikonu je potrebne pripojit sa na CS9 pod uzivatelom '''maintenance''' s prednastavenym heslom '''spec_cal'''<br />
<br />
[[File:Robot staubli_conection.png]]<br />
<br />
Na zaver v okne transfer manager, treba zakliknut '''IO''' a '''VAL3 Applications''', nasledne '''>> transfer >>'''. <br />
<br />
[[File:Robot staubli_transfer_manager.png]]<br />
<br />
=== 3.4 Create State Server Task ===<br />
<br />
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. <br />
<br />
(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. <br />
<br />
<br />
[[File:Robot studio state server config2.png]]<br />
<br />
<br />
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:<br />
<br />
<br />
[[File:ABB pendant grant access.png]]<br />
<br />
<br />
The State Server Task which runs in the background and will report the current state of the robot to the Vision Controller. <br />
<br />
On the Left pane, select the '''Controller''' option, right click on the '''Task''' item in the list and select '''New Task...''':<br />
<br />
<br />
[[File:Robot Studio Task Definition 2.png]]<br />
<br />
<br />
The following dialogue should appear. Change the settings to those shown in the figure below: <br />
<br />
(''String to Copy & Paste:'' '''Task''': PHO_STATE_SERVER, '''Main Entry''': pho_state_server_main)<br />
<br />
<br />
[[File:Robot studio task settings 3.png]]<br />
<br />
=== 3.4 Automatic Loading of Modules ===<br />
<br />
Now we need to configure the ABB system to automatically load '''StateServer.mod''' during the boot.<br />
<br />
Right Click on '''Automatic Loading of Modules''' and select '''New Automatic Loading of Modules''' as shown in the figure below: <br />
<br />
<br />
[[File:Robot studio loading modules.png]]<br />
<br />
<br />
Configure the module for '''PhotoneoState Server.mod''' as is shown in the figure below:<br />
<br />
(''String to Copy & Paste:'' '''File''': HOME://Photoneo/PhotoneoStateServer.mod)<br />
<br />
<br />
<br />
[[File:Robot studio state server automatic loading.png]]<br />
<br />
Repeat the same procedure for '''PhotoneoCommon.sys''' as a system module:<br />
<br />
(''String to Copy & Paste:'' '''File''': HOME://Photoneo/PhotoneoCommon.sys)<br />
<br />
<br />
[[File:Robot studio pho common.png]]<br />
<br />
<br />
Also repeat the same procedure for '''CustomerDefinitions.mod''' containing user settings:<br />
<br />
(''String to Copy & Paste:'' '''File''': HOME://Photoneo/CustomerDefinitions.mod)<br />
<br />
<br />
[[File:Robot studio customer definitions.png]]<br />
<br />
=== 3.5 Load Main Module ===<br />
<br />
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. <br />
<br />
Right Click on '''T_ROB1''' task and select '''Load Module''' or '''Load Module From Controller''':<br />
<br />
<br />
[[File:Robot studio load module.png]]<br />
<br />
<br />
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:<br />
<br />
<br />
[[File:Robot studio final panel2.png]]<br />
<br />
<br />
At this point your Robot Controller is configured to work with Photoneo Binpicking Solution. 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. <br />
<br />
== 4. RAPID ==<br />
<br />
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: <br />
<br />
- '''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 <br />
<br />
- '''RAPID CONFIG''' - '''CustomerDefinitions.mod''' holds an application specific settings such as gripper commands, motion speed, precision and overall bin picking sequence definition. <br />
<br />
=== 4.1 RAPID API ===<br />
<br />
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. <br />
--------------------------------------------------------<br />
'''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. <br />
<br />
'''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. <br />
<br />
'''pho_request_scan()''' - request to trigger the next scan and localization. Non-blocking request; the RAPID program continues immediately at the next line.<br />
<br />
'''pho_wait_for_scan_completition()''' - function to wait for scan to be finished. This should be called after triggering the scan, but not immediately<br />
<br />
'''pho_request_trajectory()''' - request to start trajectory planning for current goal. Non-blocking function; the RAPID program continues immediately at the next line.<br />
<br />
'''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. <br />
<br />
'''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). <br />
<br />
'''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.<br />
<br />
'''pho_calib_set()''' - request to set current calibration result to the PhoXi Scanner<br />
<br />
'''pho_calib_reset()''' - request to reset current calibration and remove all previously added points<br />
<br />
'''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.<br />
--------------------------------------------------------<br />
<br />
=== 4.2 RAPID CONFIG ===<br />
<br />
'''CustomerDefinitions module''' enables the user to configure several bin picking settings, including gripper command implementations, trajectory speed and precision adjustments. <br />
--------------------------------------------------------<br />
- '''open_gripper()''' - implement function for opening your gripper here <br />
<br />
- '''close_gripper()''' - implement function for closing your gripper here<br />
<br />
- '''gripper_user_1()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_2()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_3()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_4()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_5()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''gripper_user_6()''' - implement custom user gripper command (reserved for future use)<br />
<br />
- '''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) <br />
<br />
- '''pho_bin_picking_simple()''' - a very basic bin picking sequence (for experimental purposes)<br />
<br />
- '''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 !!!'''<br />
<br />
--------------------------------------------------------<br />
<br />
=== 4.3 RAPID ERROR HANDLING === <br />
<br />
Photoneo BP solution 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. <br />
<br />
'''PHO_NO_ERR := 0''' - Service response from Vision Controller is valid <br />
<br />
'''PHO_SERVICE_ERR := 1''' - Service response from Vision Controller is invalid.<br />
<br />
'''PHO_UNKNOWN_REQ := 2''' - The Vision Controller received an unknown request.<br />
<br />
'''PHO_COM_FAILURE := 3''' - Communication failure due to socket closure. <br />
<br />
'''PHO_BAD_DATA := 4''' - Data validation check has failed. <br />
<br />
'''PHO_TIMEOUT := 5''' - Communication failure due to socket timeout.<br />
<br />
'''PHO_PLANNING_FAILED := 201''' - Trajectory planning has failed<br />
<br />
'''PHO_NO_PART_FOUND := 202''' - No part has been localized<br />
<br />
'''PHO_NOT_INITIALIZED := 203''' - Bin picking application has not been properly initialized on Vision Controller<br />
<br />
'''PHO_PART_LOST := 204''' - Part has been lost during motion execution<br />
<br />
'''PHO_COLLISION_DETECT := 205''' - Collision has been detected<br />
<br />
'''PHO_UNKNOWN_ERR := 299''' - Unspecified internal error<br />
<br />
<br />
=== 4.4 MAIN MODULE ===<br />
<br />
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. <br />
<br />
''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.'' <br />
<br />
==== 4.4.1 main() ====<br />
<br />
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. <br />
<br />
<br />
<br />
MODULE MainModule<br />
<br />
! Copyright (c) 2018 Photoneo s.r.o.<br />
! All rights reserved<br />
! Description: Main bin picking module<br />
!<br />
! Home, start and end binpicking target variables<br />
VAR robtarget home_pose;<br />
VAR robtarget start_bin_picking_robtarget;<br />
VAR robtarget end_bin_picking_robtarget;<br />
VAR jointtarget start_bin_picking_jointtarget;<br />
VAR jointtarget end_bin_picking_jointtarget;<br />
<br />
! Error handling variables<br />
VAR num err_counter;<br />
CONST num MAX_ERR_COUNT := 2;<br />
<br />
PROC main()<br />
<br />
!calibration; ! If bin picking is about to be executed comment this line<br />
bin_picking; ! If calibration is about to be executed comment this line<br />
<br />
ENDPROC <br />
<br />
==== 4.4.2 bin_picking() ====<br />
<br />
This is a basic bin picking template. '''The main program loop is defined here'''. The sser 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.<br />
<br />
! BIN PICKING<br />
! This is a basic bin picking template. The main program loop is defined here. User is expected to reteach <br />
! bin picking start and end positions, set IP Address and Port of Vision Controller and adopt placing part<br />
! of the code to meet specific workcell and application requirements here. <br />
!<br />
PROC bin_picking()<br />
<br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
<br />
PHO_ERR_CODE := PHO_PLANNING_FAILED;<br />
! <br />
! RETEACH home position for your application<br />
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]];<br />
!<br />
! RETEACH bin picking start and end pose<br />
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]];<br />
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]];<br />
!<br />
! Convert cartesian position to jointtarget<br />
start_bin_picking_jointtarget := CalcJointT(start_bin_picking_robtarget, tool0);<br />
end_bin_picking_jointtarget := CalcJointT(end_bin_picking_robtarget, tool0);<br />
!<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004 ;<br />
! <br />
! Send bin picking initialization request to the Vision Controller, <br />
! start and end poses defined above will be used in trajectory planning pipeline<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
! <br />
! Move robot away from scanning area - reteach this position for your robot and workcell<br />
MoveJ home_pose, v500, z30, tool0;<br />
! <br />
! When robot is away from scanning area, trigger first scan and localization<br />
pho_request_scan;<br />
!<br />
WHILE true DO<br />
scan_again: <br />
!==================== PHOTONEO BIN PICKING START ===========================<br />
! Wait until scanning is completed<br />
pho_wait_for_scan_completion;<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ENDIF <br />
!<br />
! Trigger trajectory planning<br />
pho_request_trajectory;<br />
!<br />
! While trajectory is being calculated, move robot to bin picking start position<br />
MoveAbsJ start_bin_picking_jointtarget, v1000, z200, tool0;<br />
!<br />
! Execute bin picking application, calculated trajectory is received here<br />
pho_bin_picking; <br />
!==================== PHOTONEO BIN PICKING END ===========================<br />
!<br />
! Handle errors if occured<br />
IF (PHO_OCCURRED_ERR = TRUE) THEN <br />
err_handling;<br />
GOTO scan_again;<br />
ELSE <br />
! Clear error counter for err_handling procedure<br />
err_counter := 0;<br />
!<br />
!==================== PLACING START==================================<br />
! Move robot from bin picking end position away from scanning area - reteach this position for your robot and workcell<br />
! 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;<br />
!<br />
! Triger next scan and localization, trajectory for next cycle is calculated while object is being placed <br />
pho_request_scan;<br />
!<br />
! Commands for actual part placing - reteach positions for your robot and workcell<br />
! 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;<br />
! open_gripper;<br />
! 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; <br />
!==================== PLACING END=================================== <br />
ENDIF <br />
ENDWHILE <br />
ENDPROC<br />
<br />
<br />
==== 4.4.3 calibration() ====<br />
<br />
'''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.<br />
<br />
! CALIBRATION<br />
! Reteach calibration positions and call add calibration point request after reaching each calibration pose<br />
! It it recomended to run calibration in MANUAL mode step by step to have a proper control over the process. <br />
! Always make sure that robot does not collide with workcell during transitions between specific waypoints<br />
PROC calibration()<br />
<br />
! Connect to the the Vision Controller, adopt Vision Controller IP address and port here if needed <br />
pho_wait_for_server "192.168.1.6", 11004;<br />
! <br />
! 1. calibration waypoint <br />
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;<br />
pho_request_calib_add_point;<br />
! <br />
! 2. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 3. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 4. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 5. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! 6. calibration waypoint<br />
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;<br />
pho_request_calib_add_point;<br />
!<br />
! Finally set calibration result to the PhoXi Scanner<br />
TPWrite "Setting calibration result to the PhoXi Scanner!";<br />
pho_request_calib_set; <br />
TPWrite "Calibration complete!";<br />
EXIT;<br />
<br />
ENDPROC<br />
<br />
==== 4.4.4 err_handling() ====<br />
<br />
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. <br />
<br />
! ERROR HANDLING<br />
! Shit happens. Several error situations might occur during bin picking procedure. Some of them are more serious some are less.<br />
! For example if no part is found or trajectory planning fails, program just tries to repeat the whole sequence. However if <br />
! communication failure is detected, program is halted immediately. It is possible to adopt this behavior here if needed<br />
PROC err_handling()<br />
<br />
!--Release gripper if needed<br />
!open_gripper;<br />
<br />
! Move robot to home pose<br />
MoveJ home_pose, v500, z30, tool0;<br />
<br />
!--Display error<br />
TPWrite pho_err_info(PHO_ERR_CODE);<br />
<br />
IF err_counter >= MAX_ERR_COUNT THEN<br />
ErrLog 4800, "Photoneo internal error", pho_err_info(PHO_ERR_CODE), "Please reboot the Vision controller and restart application"," ", " ";<br />
EXIT;<br />
ENDIF<br />
<br />
! If planning failed or no part was found, notify user and continue by next scan (Adopt if needed)<br />
IF (PHO_ERR_CODE = PHO_PLANNING_FAILED OR PHO_ERR_CODE = PHO_NO_PART_FOUND) THEN <br />
TPWrite "NO PART FOUND OR PLANNING PATH FAILED";<br />
pho_request_scan;<br />
<br />
! If bin picking has not been initialized or service returned error response, reinitialize and trigger new scan (Adopt if needed)<br />
ELSEIF(PHO_ERR_CODE = PHO_NOT_INITIALIZED) THEN<br />
<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! If bin picking service returned error response, reinitialize and trigger new scan (Adopt if needed) <br />
ELSEIF (PHO_ERR_CODE = PHO_SERVICE_ERR ) THEN<br />
<br />
Waittime 10;<br />
pho_request_init start_bin_picking_jointtarget, end_bin_picking_jointtarget;<br />
pho_request_scan;<br />
<br />
! In case of communication failure, rapid program is terminated immediatelly<br />
ELSEIF (PHO_ERR_CODE = PHO_BAD_DATA OR PHO_ERR_CODE = PHO_TIMEOUT OR PHO_ERR_CODE = PHO_COM_FAILURE ) THEN<br />
ErrLog 4800, "Photoneo internal error", "Communication failure!", "Please reboot the Vision controller"," "," ";<br />
EXIT;<br />
<br />
! Otherwise trigger next scan and try to continue<br />
ELSE<br />
pho_request_scan;<br />
ENDIF<br />
<br />
err_counter := err_counter + 1;<br />
! reset error flag for next cycle<br />
PHO_OCCURRED_ERR := FALSE;<br />
<br />
ENDPROC<br />
<br />
== 5. Runtime ==<br />
<br />
Apply RAPID changes, restart the Robot Controller; if everything is set correctly, you should see the following info screen on the Pendant:<br />
<br />
<br />
[[File: waiting_for_server_2.png]]<br />
<br />
<br />
Make sure that the Bin Picking application on the Vision Controller side is running and waiting for a connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu) <br />
<br />
<br />
Open Main Menu, browse to '''Production Window''' and '''Set PP to Main''' - at the beginning of the main function:<br />
<br />
<br />
[[File: pp_to_main_2.png]]<br />
<br />
<br />
Choose if you want to run the application in '''AUTO''' or '''MANUAL''' mode and adopt the speed override if required:<br />
<br />
<br />
[[File: override_vel_2.png]]<br />
<br />
<br />
Hit the '''Play''' button in AUTO mode or '''Enable + Play''' button in MANUAL mode and you should see the following application output:<br />
<br />
<br />
[[File: binpicking_connected.png]]<br />
<br />
<br />
You should receive the notification that the Vision Controller has established a successful connection:<br />
<br />
<br />
[[File: ]] (Tu asi pride screenshot z webu)<br />
<br />
<br />
The robot should now start sending requests to the Vision Controller and execute bin picking movements.</div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Staubli_start_pose.png&diff=490File:Staubli start pose.png2018-04-09T07:39:01Z<p>Michald: </p>
<hr />
<div></div>Michaldhttp://wiki.photoneo.com/index.php?title=File:Staubli_tcp_client.png&diff=489File:Staubli tcp client.png2018-04-09T07:38:31Z<p>Michald: </p>
<hr />
<div></div>Michald