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

From 3D scanning Knowledge base - Photoneo wiki
Jump to: navigation, search
(5. Runtime)
 
(15 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
== 1. Prerequisites ==
 
== 1. Prerequisites ==
  
Photoneo Mitsubishi Interface is written in '''MELFA V''' language and it it should be compatible with following controllers:
+
The Photoneo Mitsubishi Interface is written in '''MELFA V''' language and should be compatible with the following controllers:
  
 
* - '''CR750D'''
 
* - '''CR750D'''
Line 9: Line 9:
 
* - '''CR800'''
 
* - '''CR800'''
  
The robot used for the development: '''RV2-FR + CR800 controller''' with firmware version as shown in the figure below:
+
'''RV2-FR''' robot utilizing a '''CR800 controller''' was used for the development of the Interface using the firmware version shown in the figure below:
  
  
[[File: Setting Up Guide Mitsubishi Step 22.png]]
+
[[File: Setting Up Guide Mitsubishi Step 22.png|frame|none|alt=Alt text| Figure 1.1.1]]
  
  
Line 21: Line 21:
 
=== 2.1 Set IP Address ===
 
=== 2.1 Set IP Address ===
  
Setting up an IP Address of Robot Controller is an essential step in robot configuration.  
+
Setting up the IP Address of the Robot Controller is an essential step in robot configuration.  
  
It is not possible to go Online until the configuration of IP address does not match the network configuration of PC running RT Toolbox (same subnet)
+
The robot cannot go online until the configuration of the IP address is identical to the network configuration of the PC running RT Toolbox (same subnet)
  
Turn on the Robot Controller and Click the '''MEMU''' at the bottom. Select '''Parameter''' to open the Parameter list:
+
Turn on the Robot Controller and click the '''MENU''' at the bottom. Select '''Parameter''' to open the Parameter list:
  
  
[[File: Setting Up Guide Mitsubishi Step 17.png]]
+
[[File: Setting Up Guide Mitsubishi Step 17.png|frame|none|alt=Alt text| Figure 2.1.1]]
  
  
Line 34: Line 34:
  
  
[[File: Setting Up Guide Mitsubishi Step 21.png]]
+
[[File: Setting Up Guide Mitsubishi Step 21.png|frame|none|alt=Alt text| Figure 2.1.2]]
  
  
This parameter holds the current IP settings of the Robot Controller. '''Change IP Address here''' to match your network configuration (same subnet).
+
This parameter contains the current IP settings of the Robot Controller. ''' Change the IP Address here''' to match your network configuration (i.e. the same subnet).
  
  
[[File: Setting Up Guide Mitsubishi Step 19.png]]
+
[[File: Setting Up Guide Mitsubishi Step 19.png|frame|none|alt=Alt text| Figure 2.1.3]]
  
  
Confirm '''WRITE''' and try to ping the Robot Controller from your PC. If this operation is successful, it should be possible to go Online from RTToolBox3.  
+
Confirm '''WRITE''' and try to ping the Robot Controller from your PC. If this operation is successful, it should be possible to go online from RTToolBox3.  
  
 
=== 2.2 RT ToolBox3 project configuration ===
 
=== 2.2 RT ToolBox3 project configuration ===
  
When configuring the new project in RTToolBox it is recommended to enable TCP/IP communication for commissioning.  
+
When configuring the new project in RTToolBox it is recommended to enable '''TCP/IP''' communication for commissioning.  
  
  
[[File: Setting Up Guide Mitsubishi RT Toolbox 1.png ]]
+
[[File: Setting Up Guide Mitsubishi RT Toolbox 1.png|frame|none|alt=Alt text| Figure 2.2.1]]
  
  
The default configuration should work with RTToolbox3. Do not change any parameters here unless you know exactly what you are doing:
+
The default configuration should work with RTToolbox3. '''Do not change any parameters in Communication Settings here unless you know exactly what you are doing''':
  
  
[[File: Setting Up Guide Mitsubishi RT Toolbox 2.png]]
+
[[File: Setting Up Guide Mitsubishi RT Toolbox 2.png|frame|none|alt=Alt text| Figure 2.2.2]]
  
 
=== 2.3 Go Online ===
 
=== 2.3 Go Online ===
  
If project configuration has been completed, RTToolbox should be in '''Offline mode''':
+
If the project configuration has been completed successfully , RTToolbox should be in '''Offline mode''':
  
  
[[File: Setting Up Guide Mitsubishi Step 0.png]]
+
[[File: Setting Up Guide Mitsubishi Step 0.png|frame|none|alt=Alt text| Figure 2.3.1]]
  
  
'''Change to Online mode''' to start configuring Robot Controller:
+
'''Change to Online mode''' to start configuring the Robot Controller:
  
  
[[File: Setting Up Guide Mitsubishi Step 2.png]]
+
[[File: Setting Up Guide Mitsubishi Step 2.png|frame|none|alt=Alt text| Figure 2.3.2]]
  
 
== 3. Project Setup ==
 
== 3. Project Setup ==
  
Photoneo Mitsubishi Interface consists of following .prg files:
+
The Photoneo Mitsubishi Interface consists of the following program files:
  
* - '''PHOCLIENT''' - handles communication with BP Studio - Do Not Edit  
+
* - '''PHOCLIENT''' - handles communication with BP Studio - '''Do Not Edit'''
  
 
* - '''PHOCOMMON''' - holds the definition of global variables
 
* - '''PHOCOMMON''' - holds the definition of global variables
  
* - '''PHOMAIN''' - the main program loop is defined here amend program, poses, logic and gripper actions here
+
* - '''PHOMAIN''' - the main program loop is defined here '''(program, poses, logic and gripper actions can be amended here)'''
  
* - '''PHOSTATE''' - state server module, it runs in the background from the boot and keeps reporting joint states and TCP pose to the Bin Picking Studio.
+
* - '''PHOSTATE''' - state server module, runs in the background from boot and continually report joint states and TCP poses to the Bin Picking Studio.
  
=== 3.1 Transfering Program files to Robot Controller ===
+
=== 3.1 Transferring Program files to Robot Controller ===
  
As the first step in Robot Controller configuration upload these four files to the Program List. Right Click on '''Program''' and select '''Program Manager''':
+
As the first step in the configuring of the Robot Controller , upload these four files to the Program List. Right Click on '''Program''' and select '''Program Manager''':
  
  
[[File: Setting Up Guide Mitsubishi Step 3.png]]
+
[[File: Setting Up Guide Mitsubishi Step 3.png|frame|none|alt=Alt text| Figure 3.1.1]]
  
  
Select four program files and copy them to the robot. Ensure that you have selected proper '''Source''' and '''Destination''':
+
Select four program files from the ZIP archive and copy them to the robot. Ensure that you have selected the correct '''Source''' and '''Destination''':
  
  
[[File: Setting Up Guide Mitsubishi Step 4.png]]
+
[[File: Setting Up Guide Mitsubishi Step 4.png|frame|none|alt=Alt text| Figure 3.1.2]]
  
 
=== 3.2 Parameters ===
 
=== 3.2 Parameters ===
  
As a next step Open Parameter List and search for a '''PRGUSR''':  
+
As the next step, open '''Parameter''' -> '''Parameter List''' and search for '''PRGUSR''':  
  
  
[[File: Setting Up Guide Mitsubishi Step 5.png]]
+
[[File: Setting Up Guide Mitsubishi Step 5.png|frame|none|alt=Alt text| Figure 3.2.1]]
  
  
Type '''PHOCOMMON''' here to enable sharing global variables within all programs:
+
Type '''PHOCOMMON''' here to enable the sharing global of variables across all programs:
  
  
[[File: Setting Up Guide Mitsubishi Step 6.png]]
+
[[File: Setting Up Guide Mitsubishi Step 6.png|frame|none|alt=Alt text| Figure 3.2.2]]
  
  
Now browse to '''Parameter''' -> '''Program Parameter''' -> '''Command''' and ensure that RAD is selected:
+
Next browse to '''Parameter''' -> '''Program Parameter''' -> '''Command''' and ensure that '''RAD''' is selected:
  
  
[[File: Setting Up Guide Mitsubishi Step 7.png]]
+
[[File: Setting Up Guide Mitsubishi Step 7.png|frame|none|alt=Alt text| Figure 3.2.3]]
  
  
As a next step browse to '''Parameter''' -> '''Communication Parameter''' -> '''Ethernet'''
+
Then browse to '''Parameter''' -> '''Communication Parameter''' -> '''Ethernet'''
  
Basic networking parameters are shown here including NETIP configured as a first step:
+
Basic network parameters are shown here including NETIP which was configured in the first step:
  
  
[[File: Setting Up Guide Mitsubishi Step 8.png]]
+
[[File: Setting Up Guide Mitsubishi Step 8.png|frame|none|alt=Alt text| Figure 3.2.4]]
  
  
Now switch to '''Device and Line'''. Photoneo Mitsubishi Module utilize '''OPT12''' and '''OPT13''' Devices:
+
Now switch to '''Device and Line'''. The Photoneo Mitsubishi Module utilizes '''OPT12''' and '''OPT13''' devices:
  
  
[[File: Setting Up Guide Mitsubishi Step 9.png]]
+
[[File: Setting Up Guide Mitsubishi Step 9.png|frame|none|alt=Alt text| Figure 3.2.5]]
  
  
Configure '''OPT12''' as a '''Client''' and set Vision Controller IP here as configured in BP Studio. '''The default port utilized for Bin Picking Client is 11003'''
+
Configure '''OPT12''' as a '''Client''' and set the Vision Controller IP to that configured in Bin Picking Studio. '''The default port utilized for the Bin Picking Client is 11003'''
  
  
[[File: Setting Up Guide Mitsubishi Step 10.png]]
+
[[File: Setting Up Guide Mitsubishi Step 10.png|frame|none|alt=Alt text| Figure 3.2.6]]
  
  
Line 139: Line 139:
  
  
[[File: Setting Up Guide Mitsubishi Step 11.png]]
+
[[File: Setting Up Guide Mitsubishi Step 11.png|frame|none|alt=Alt text| Figure 3.2.7]]
  
  
 
Now browse to '''Parameter''' -> '''Program Parameter''' -> '''Slot Table'''.  
 
Now browse to '''Parameter''' -> '''Program Parameter''' -> '''Slot Table'''.  
  
As is shown in the figure below '''PHOSTATE''' program needs to be added to the '''Slot 8''':
+
As is shown in the figure below the '''PHOSTATE''' program should be added to '''Slot 8''':
  
  
[[File: Setting Up Guide Mitsubishi Step 15.png]]
+
[[File: Setting Up Guide Mitsubishi Step 15.png|frame|none|alt=Alt text| Figure 3.2.8]]
  
  
 
Double click on '''Slot8''' and select the '''PHOSTATE''' program.  
 
Double click on '''Slot8''' and select the '''PHOSTATE''' program.  
  
Change conditions to '''ALWAYS''' to ensure that '''PHOSTATE''' program starts at the boot:
+
Change the conditions to '''ALWAYS''' to ensure that the '''PHOSTATE''' program starts at boot:
  
  
[[File: Setting Up Guide Mitsubishi Step 16.png]]
+
[[File: Setting Up Guide Mitsubishi Step 16.png|frame|none|alt=Alt text| Figure 3.2.9]]
  
  
=== 3.3 Reteach Positions ===
+
=== 3.3 Reteach PHOMAIN Positions ===
  
 
At this point, your Robot Controller is configured to work with Photoneo Bin Picking Studio. However, in order to meet your application requirements, you need to reteach several robot poses.  
 
At this point, your Robot Controller is configured to work with Photoneo Bin Picking Studio. However, in order to meet your application requirements, you need to reteach several robot poses.  
  
Open '''PHOMAIN''' file and select '''Joint Tab''' at the bottom of the screen to show a list of joint positions defined within the program.  
+
Open the '''PHOMAIN''' file and select '''Joint Tab''' at the bottom of the screen to show a list of joint positions defined within the '''PHOMAIN''' program.  
  
Following is the list of Joint Position defined in basic program template. This can be adjusted to meet application requirements (J_Start and J_End must be always defined).
+
The following list shows the Joint Positions defined in the basic program template. This must be adjusted in order to meet the application requirements  
  
* - '''JHome''' - the robot Home position it should not interfere with scanning volume (Local Variable)
+
* - '''JHome''' - the robot Home position - this should not interfere with the  scanning volume (Local Variable)
  
* - '''J_Start''' - Bin Picking Start Pose - it should be defined approximately above the center of the bin. (Global Variable, it must be defined)
+
* - '''JOutOfScan''' - Helper Joint Pose - guarantees that the trigger will not be issued until the robot is within the scanning volume. It should be defined at the edge of the scanning volume. (Local Variable does not have to be used)  
  
* - '''J_End''' - Bin Picking End Pose - it should be defined approximately above the center of the bin but it can be also shifted towards the placing area (Global Variable, it must be defined)
+
* - '''JPlaceUp''' - Place Up Pose - pose above the final placing pose (Local Variable depends on the application)  
  
* - '''JOutOfScan''' - Helper Joint Pose which guarantees that trigger will not be issued until the robot is in the scanning volume. It should be defined at the edge of scanning volume. (Local Variable doesn't need to be used)  
+
* - '''JPlace''' - Place Pose - the final placing pose (Local Variable depends on the application)
 +
 
 +
* - '''JBackToStart''' - Helper Joint Pose returns the robot back to the start pose. It is recommended to set this position to the same point as the J_Start defined in PHOCLIENT. (Local Variable does not have to be used)  
 +
 
 +
Reteaching all of these poses in Online Mode is simple. Jog the robot to the pose you want to teach and press the '''Get Current Pose''' button. The current joint pose will be saved.
 +
 
 +
=== 3.4 Reteach PHOCLIENT Positions ===
  
* - '''JPlaceUp''' - Place Up Pose - pose above final placing pose (Local Variable depends on the application)
+
Now open '''PHOCLIENT''' file and select the '''Joint Tab''' at the bottom of the screen to show a list of joint positions defined within the PHOCLIENT program.
  
* - '''JPlace''' - Place Pose - the final placing pose (Local Variable depends on the application)  
+
* - '''J_Start''' - Bin Picking Start Pose - this should be defined approximately above the center of the bin. (Global Variable, must be defined)
 +
 
 +
* - '''J_End''' - Bin Picking End Pose - this should be defined approximately above the center of the bin but it can be also shifted towards the placing area (Global Variable, must be defined)
  
Reteaching all of these poses in Online Mode is simple. Jog the robot to the pose you want to teach and press '''Get Current Pose''' button. The current joint pose is saved.
+
Reteach the J_Start and J_End poses using '''Get Current Pose''' button as was used in '''PHOMAIN'''.
  
  
 
[[File: Setting Up Guide Mitsubishi Step 12.png]]
 
[[File: Setting Up Guide Mitsubishi Step 12.png]]
  
=== 3.4 PHOCLIENT Config ===
+
=== 3.5 PHOCLIENT Config ===
  
The only single line of code that needs to be edited in PHOCLIENT is the IP address and Port of Bin Picking Client.  
+
The only two lines of code that should be edited in PHOCLIENT are the IP address and the Port of Bin Picking Client.  
  
Open '''PHOCLIENT''' and find "Try to establish the connection to BP Studio" section. Amend the IP address of Bin Picking Client and Port number here:
+
Open '''PHOCLIENT''' and find "Try to establish the connection to BP Studio" section. '''Amend the IP address''' of Bin Picking Client and the '''Port number''' here:
  
  
 
[[File: Setting Up Guide Mitsubishi Step 13.png]]
 
[[File: Setting Up Guide Mitsubishi Step 13.png]]
  
 +
=== 3.6 Gripper commands ===
  
=== 3.5 Gripper commands ===
+
In the Photoneo Mitsubishi Module gripper commands are implemented as '''subroutines''' directly in the '''PHOMAIN''' program.  
  
In Photoneo Mitsubishi Module gripper command are implemented as '''subroutines''' directly in '''PHOMAIN''' program.
+
Scroll down in the '''PHOMAIN''' program until you find the specific subroutine (Default routines: GripperAttach, GripperDetach)
  
Scroll down in '''PHOMAIN''' program and find specific subroutine (Default routines: GripperAttach, GripperDetach)
 
  
 
[[File: Setting Up Guide Mitsubishi Step 14.png]]
 
[[File: Setting Up Guide Mitsubishi Step 14.png]]
 +
 +
== 4. MELFA V Language ==
 +
 +
The Photoneo Mitsubishi interface was designed to be easily integrated into existing applications written in MELFA V code.
 +
 +
=== 4.1 MELFA API ===
 +
 +
The following API describes the functionality of requests provided by the Photoneo MITSUBISHI Interface. These requests are intended for high-level control of bin picking sequences and are usually called in '''PHOMAIN.prg'''
 +
 +
--------------------------------------------------------
 +
 +
- '''InitReq''' - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the AS side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points.
 +
 +
- '''*ScanReq''' - request to trigger the next scan and localization. Non-blocking request; the AS program continues immediately at the next line.
 +
 +
- '''*WaitForScan''' - function to wait for the scan to be finished. This should be called after triggering the scan, but not immediately. Blocking function, waits for a response from Vision Controller.
 +
 +
- '''*TrajReq''' - request to start trajectory planning for current goal. Non-blocking function; the AS program continues immediately at the next line.
 +
 +
- '''*TrajRecv''' - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). Blocking function; waits for motion data to be received.
 +
 +
- '''*ChangeSol''' - request to change currently deployed solution.
 +
 +
- '''*CalibStart''' - request to start current calibration for selected vision system and remove all previously added points '''(Not supported in this version)'''
 +
 +
- '''*CalibAdd''' -  - request to add calibration point - a scan is triggered and the calibration is recalculated. '''(Not supported in this version)
 +
 +
- '''*CalibSet''' - request to save current calibration result to the selected Vision System '''(Not supported in this version)'''
 +
 +
- '''*CalibReset''' - request to reset current calibration and remove all previously added points '''(Not supported in this version)'''
 +
 +
- '''*LocBin''' -  request to localize bin position in the environment '''(Reserved for future use)'''
 +
 +
- '''*PickFail - request to notify bin picking studio that object picking has failed '''(Reserved for future use)'''
 +
 +
 +
'''NOTE #1:''' '''WaitForScan''' should be called after '''ScanReq'''. Standard robotic commands can be performed between these two calls but no other Photoneo Bin Picking API calls are possible until the '''WaitForScan''' function finished . For example - if '''ScanReq''' is followed by '''TrajReq''', a communication error will occur.
 +
 +
 +
'''NOTE #2:''' '''TrajRecv''' should be called after '''TrajReq'''. Standard robotic commands can be performed between these two calls but no other Photoneo Bin Picking API calls are possible until the '''TrajRecv''' function finished. For example,if '''TrajReq''' is followed by '''ScanReq''', communication error will occur.
 +
 +
=== 4.2 MELFA CONFIG ===
 +
 +
The Photoneo Mitsubishi Interface enables the user to configure several implement gripper commands, to set trajectory speed and to make precision adjustments.
 +
--------------------------------------------------------
 +
 +
==== 4.2.1 SUBROUTINES ====
 +
 +
- '''*PickObject''' - standard bin picking sequence. This flexible, operation-based implementation allows bin picking sequences, which consist of various numbers of operations to be performed. '''Do not edit !!!'''
 +
 +
- '''*PlaceObject''' - placing operation. Adapt placing sequences and poses to meet your application requirements
 +
 +
- '''*ConfigTraj1''' - set JOvrd parameters for first trajectory - usually APPROACH
 +
 +
- '''*ConfigTraj2''' - set JOvrd parameters for first trajectory - usually GRASP
 +
 +
- '''*ConfigTraj3''' - set JOvrd parameters for first trajectory - usually DEAPPROACH
 +
 +
- '''*ConfigTraj4''' - set JOvrd parameters for first trajectory - usually END
 +
 +
- '''*GripAttach''' - implement function for attaching object to the gripper here 
 +
 +
- '''*GripDetach''' - implement function for detaching object from the gripper here
 +
 +
- '''*GripUser1''' - implement custom user gripper command (reserved for future use)
 +
 +
- '''*GripUser2''' - implement custom user gripper command (reserved for future use)
 +
 +
- '''*GripUser3''' - implement custom user gripper command (reserved for future use)
 +
 +
- '''*GripUser4''' - implement custom user gripper command (reserved for future use)
 +
 +
- '''*GripUser5''' - implement custom user gripper command (reserved for future use)
 +
 +
- '''*GripUser6''' - implement custom user gripper command (reserved for future use)
 +
 +
=== 4.3 AS ERROR HANDLING ===
 +
 +
The Photoneo Mitsubishi interface provides basic error handling. If an error occurs during bin picking operations, an error code is available in '''M_Status''' global variable.
 +
--------------------------------------------------------
 +
The following list shows  potential bin picking error codes:
 +
 +
'''OK = 0''' - Service response from Bin Picking Studio is valid
 +
 +
'''SERVICE_ERR = 1''' - Service response from Bin Picking Studio is invalid.
 +
 +
'''UNKNOWN_REQ = 2''' - The Bin Picking Studio has received an unknown request.
 +
 +
'''COMM_FAILURE = 3''' - Communication failure due to socket closure. 
 +
 +
'''BAD_DATA = 4''' - Data validation check has failed. 
 +
 +
'''TIMEOUT = 5''' - Communication failure due to socket timeout.
 +
 +
'''UNKNOWN_ERR = 99''' - Unspecified internal error
 +
 +
'''PLANNING_FAILED = 201''' - Trajectory planning has failed
 +
 +
'''NO_PART_FOUND = 202''' - No part has been localized
 +
 +
'''NOT_INIT = 203''' - Bin picking application has not been properly initialized on the Bin Picking Studio side.
 +
 +
'''WRONG_BP_CONFIG = 255''' - Wrong Bin Picking Configuration - Check Log Console in the Bin Picking Studio
 +
--------------------------------------------------------
 +
'''PHOMAIN''' already includes basic error handling but can be adapted to deal with more complex scenarios if required.
 +
 +
=== 4.4 MAIN APPLICATION ===
 +
 +
This is a basic bin picking template. '''The main program loop is defined here'''
 +
 +
    ' Copyright (c) 2019 Photoneo s.r.o.
 +
    ' All rights reserved
 +
    ' Description: Photoneo Mitsubishi Module v.1.3 - Main Program
 +
    '
 +
    'Redeclaration of array variables
 +
    Dim M_OperBuff(30)
 +
    Dim J_TrajBuff(10,100)
 +
    Dim M_TrajSizes(10)
 +
    Dim M_GripBuff(10)
 +
    Dim M_InfoData(10)
 +
    '
 +
    'Load PHOCLIENT Module to Slot 2
 +
    XLoad 2,"PHOCLIENT"
 +
    *Start
 +
    If C_Prg(2)<>"PHOCLIENT"  Then GoTo *Start
 +
    XRun 2
 +
    Wait M_Run(2)=1
 +
    '
 +
    'Wait for connection
 +
    Wait M_Connect = 1
 +
    '
 +
    'Safety Delay (Do Not Remove!)
 +
    Dly 1.0
 +
    '
 +
    *ReInit
 +
    ' Send Initialize Request
 +
    GoSub *InitReq
 +
    If(M_Status <> M_Ok) Then Hlt
 +
    '
 +
    *ReScan
 +
    'Limit joint speed to 10% of MAX SPEED
 +
    JOvrd 10
 +
    ' Move to Home Pose and Detach Gripper
 +
    Mov JHome
 +
    GoSub *GripDetach
 +
    '
 +
    ' Send First Scan Request
 +
    GoSub *ScanReq
 +
    '
 +
    ' Wait for Scan Completition
 +
    GoSub *WaitForScan
 +
    If((M_Status = M_NotInit) Or (M_Status = M_ServiceErr)) Then *ReInit
 +
    '
 +
    'Initial Wait
 +
    Dly 10
 +
    '
 +
    'Request First Trajectory
 +
    GoSub *TrajReq
 +
    '
 +
    ' Main Loop
 +
    *MainProg
 +
    '
 +
    ' Wait For Trajectory to be Received
 +
    GoSub *TrajRecv
 +
    If((M_Status = M_NotInit) Or (M_Status = M_ServiceErr)) Then *ReInit
 +
    If((M_Status = M_NoPart) Or (M_Status = M_PlanFail)) Then *ReScan
 +
    If(M_Status = M_Ok) Then
 +
    '
 +
    ' Pick Object
 +
    GoSub *PickObject
 +
    '
 +
    ' Move out of scanning volume
 +
    Mov JOutOfScan
 +
    '
 +
    ' Send Next Scan Request
 +
    GoSub *ScanReq
 +
    '
 +
    ' Place Object
 +
    GoSub *PlaceObject
 +
    '
 +
    ' Wait for Scan Completition
 +
    GoSub *WaitForScan
 +
    If((M_Status = M_NotInit) Or (M_Status = M_ServiceErr)) Then *ReInit
 +
    '
 +
    ' Request Trajectory
 +
    GoSub *TrajReq
 +
    '
 +
    ' Return Back to Start Pose
 +
    GoSub *BackToStart
 +
    EndIf
 +
    '
 +
    'Continue in Next Loop
 +
    GoTo *MainProg
 +
 +
== 5. Runtime ==
 +
 +
Once all changes have been uploaded to the robot controller, you are ready to start the bin picking application.
 +
 +
The first step is to select the program which will be run. Turn on the Operation Panel and select the '''PHOMAIN''' program:
 +
 +
 +
[[File: Setting Up Guide Mitsubishi Step 23.png]]
 +
 +
 +
Make sure that your solution on the Deployment page of Bin Picking Studio is running and that the '''Binpicking Status''' is in '''Waiting for a connection''' state as is shown in the figure below:
 +
 +
 +
[[File: Setting Up Guide Mitsubishi Step 25.png]]
 +
 +
 +
When you are ready to start binpicking , switch to Auto Mode, turn SERVO ON and hit Start.
 +
 +
 +
[[File: Setting Up Guide Mitsubishi Step 24.png]]
 +
 +
 +
 +
You should see that the '''Binpicking Status''' has changed Robot Controller:
 +
 +
 +
[[File: Setting Up Guide Mitsubishi Step 26.png]]
 +
 +
 +
The robot should now start sending requests to the Vision Controller and execute bin picking movements.
 +
 +
'''NOTE: Ensure that you are ready to halt motion execution immediately. It is strongly recommended to reduce the speed to 10% of maximum during initial bin picking tests.'''

Latest revision as of 12:46, 11 March 2019

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

1. Prerequisites

The Photoneo Mitsubishi Interface is written in MELFA V language and should be compatible with the following controllers:

  • - CR750D
  • - CR800

RV2-FR robot utilizing a CR800 controller was used for the development of the Interface using the firmware version shown in the figure below:


Alt text
Figure 1.1.1


NOTE: RT Toolbox3 Software is highly recommended for setting up Photoneo Mitsubishi Module

2. Mitsubishi Controller Setup

2.1 Set IP Address

Setting up the IP Address of the Robot Controller is an essential step in robot configuration.

The robot cannot go online until the configuration of the IP address is identical to the network configuration of the PC running RT Toolbox (same subnet)

Turn on the Robot Controller and click the MENU at the bottom. Select Parameter to open the Parameter list:


Alt text
Figure 2.1.1


Turn ON the Keyboard by pressing KEY at the bottom and type NETIP to the search box:


Alt text
Figure 2.1.2


This parameter contains the current IP settings of the Robot Controller. Change the IP Address here to match your network configuration (i.e. the same subnet).


Alt text
Figure 2.1.3


Confirm WRITE and try to ping the Robot Controller from your PC. If this operation is successful, it should be possible to go online from RTToolBox3.

2.2 RT ToolBox3 project configuration

When configuring the new project in RTToolBox it is recommended to enable TCP/IP communication for commissioning.


Alt text
Figure 2.2.1


The default configuration should work with RTToolbox3. Do not change any parameters in Communication Settings here unless you know exactly what you are doing:


Alt text
Figure 2.2.2

2.3 Go Online

If the project configuration has been completed successfully , RTToolbox should be in Offline mode:


Alt text
Figure 2.3.1


Change to Online mode to start configuring the Robot Controller:


Alt text
Figure 2.3.2

3. Project Setup

The Photoneo Mitsubishi Interface consists of the following program files:

  • - PHOCLIENT - handles communication with BP Studio - Do Not Edit
  • - PHOCOMMON - holds the definition of global variables
  • - PHOMAIN - the main program loop is defined here (program, poses, logic and gripper actions can be amended here)
  • - PHOSTATE - state server module, runs in the background from boot and continually report joint states and TCP poses to the Bin Picking Studio.

3.1 Transferring Program files to Robot Controller

As the first step in the configuring of the Robot Controller , upload these four files to the Program List. Right Click on Program and select Program Manager:


Alt text
Figure 3.1.1


Select four program files from the ZIP archive and copy them to the robot. Ensure that you have selected the correct Source and Destination:


Alt text
Figure 3.1.2

3.2 Parameters

As the next step, open Parameter -> Parameter List and search for PRGUSR:


Alt text
Figure 3.2.1


Type PHOCOMMON here to enable the sharing global of variables across all programs:


Alt text
Figure 3.2.2


Next browse to Parameter -> Program Parameter -> Command and ensure that RAD is selected:


Alt text
Figure 3.2.3


Then browse to Parameter -> Communication Parameter -> Ethernet

Basic network parameters are shown here including NETIP which was configured in the first step:


Alt text
Figure 3.2.4


Now switch to Device and Line. The Photoneo Mitsubishi Module utilizes OPT12 and OPT13 devices:


Alt text
Figure 3.2.5


Configure OPT12 as a Client and set the Vision Controller IP to that configured in Bin Picking Studio. The default port utilized for the Bin Picking Client is 11003


Alt text
Figure 3.2.6


Configure OPT13 as a Server and change protocol to Data Link. The default port utilized for State Server is 11004


Alt text
Figure 3.2.7


Now browse to Parameter -> Program Parameter -> Slot Table.

As is shown in the figure below the PHOSTATE program should be added to Slot 8:


Alt text
Figure 3.2.8


Double click on Slot8 and select the PHOSTATE program.

Change the conditions to ALWAYS to ensure that the PHOSTATE program starts at boot:


Alt text
Figure 3.2.9


3.3 Reteach PHOMAIN Positions

At this point, your Robot Controller is configured to work with Photoneo Bin Picking Studio. However, in order to meet your application requirements, you need to reteach several robot poses.

Open the PHOMAIN file and select Joint Tab at the bottom of the screen to show a list of joint positions defined within the PHOMAIN program.

The following list shows the Joint Positions defined in the basic program template. This must be adjusted in order to meet the application requirements

  • - JHome - the robot Home position - this should not interfere with the scanning volume (Local Variable)
  • - JOutOfScan - Helper Joint Pose - guarantees that the trigger will not be issued until the robot is within the scanning volume. It should be defined at the edge of the scanning volume. (Local Variable does not have to be used)
  • - JPlaceUp - Place Up Pose - pose above the final placing pose (Local Variable depends on the application)
  • - JPlace - Place Pose - the final placing pose (Local Variable depends on the application)
  • - JBackToStart - Helper Joint Pose returns the robot back to the start pose. It is recommended to set this position to the same point as the J_Start defined in PHOCLIENT. (Local Variable does not have to be used)

Reteaching all of these poses in Online Mode is simple. Jog the robot to the pose you want to teach and press the Get Current Pose button. The current joint pose will be saved.

3.4 Reteach PHOCLIENT Positions

Now open PHOCLIENT file and select the Joint Tab at the bottom of the screen to show a list of joint positions defined within the PHOCLIENT program.

  • - J_Start - Bin Picking Start Pose - this should be defined approximately above the center of the bin. (Global Variable, must be defined)
  • - J_End - Bin Picking End Pose - this should be defined approximately above the center of the bin but it can be also shifted towards the placing area (Global Variable, must be defined)

Reteach the J_Start and J_End poses using Get Current Pose button as was used in PHOMAIN.


Setting Up Guide Mitsubishi Step 12.png

3.5 PHOCLIENT Config

The only two lines of code that should be edited in PHOCLIENT are the IP address and the Port of Bin Picking Client.

Open PHOCLIENT and find "Try to establish the connection to BP Studio" section. Amend the IP address of Bin Picking Client and the Port number here:


Setting Up Guide Mitsubishi Step 13.png

3.6 Gripper commands

In the Photoneo Mitsubishi Module gripper commands are implemented as subroutines directly in the PHOMAIN program.

Scroll down in the PHOMAIN program until you find the specific subroutine (Default routines: GripperAttach, GripperDetach)


Setting Up Guide Mitsubishi Step 14.png

4. MELFA V Language

The Photoneo Mitsubishi interface was designed to be easily integrated into existing applications written in MELFA V code.

4.1 MELFA API

The following API describes the functionality of requests provided by the Photoneo MITSUBISHI Interface. These requests are intended for high-level control of bin picking sequences and are usually called in PHOMAIN.prg


- InitReq - request to initialize bin picking application from the Vision Controller side. Start and End Poses defined by the operator from the AS side are transferred to the Vision Controller and used in the trajectory planning pipeline as start and terminus points.

- *ScanReq - request to trigger the next scan and localization. Non-blocking request; the AS program continues immediately at the next line.

- *WaitForScan - function to wait for the scan to be finished. This should be called after triggering the scan, but not immediately. Blocking function, waits for a response from Vision Controller.

- *TrajReq - request to start trajectory planning for current goal. Non-blocking function; the AS program continues immediately at the next line.

- *TrajRecv - function to receive requested bin picking trajectories (consisting of a sequence of trajectory and gripper operations). Blocking function; waits for motion data to be received.

- *ChangeSol - request to change currently deployed solution.

- *CalibStart - request to start current calibration for selected vision system and remove all previously added points (Not supported in this version)

- *CalibAdd - - request to add calibration point - a scan is triggered and the calibration is recalculated. (Not supported in this version)

- *CalibSet - request to save current calibration result to the selected Vision System (Not supported in this version)

- *CalibReset - request to reset current calibration and remove all previously added points (Not supported in this version)

- *LocBin - request to localize bin position in the environment (Reserved for future use)

- *PickFail - request to notify bin picking studio that object picking has failed (Reserved for future use)


NOTE #1: WaitForScan should be called after ScanReq. Standard robotic commands can be performed between these two calls but no other Photoneo Bin Picking API calls are possible until the WaitForScan function finished . For example - if ScanReq is followed by TrajReq, a communication error will occur.


NOTE #2: TrajRecv should be called after TrajReq. Standard robotic commands can be performed between these two calls but no other Photoneo Bin Picking API calls are possible until the TrajRecv function finished. For example,if TrajReq is followed by ScanReq, communication error will occur.

4.2 MELFA CONFIG

The Photoneo Mitsubishi Interface enables the user to configure several implement gripper commands, to set trajectory speed and to make precision adjustments.


4.2.1 SUBROUTINES

- *PickObject - standard bin picking sequence. This flexible, operation-based implementation allows bin picking sequences, which consist of various numbers of operations to be performed. Do not edit !!!

- *PlaceObject - placing operation. Adapt placing sequences and poses to meet your application requirements

- *ConfigTraj1 - set JOvrd parameters for first trajectory - usually APPROACH

- *ConfigTraj2 - set JOvrd parameters for first trajectory - usually GRASP

- *ConfigTraj3 - set JOvrd parameters for first trajectory - usually DEAPPROACH

- *ConfigTraj4 - set JOvrd parameters for first trajectory - usually END

- *GripAttach - implement function for attaching object to the gripper here

- *GripDetach - implement function for detaching object from the gripper here

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

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

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

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

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

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

4.3 AS ERROR HANDLING

The Photoneo Mitsubishi interface provides basic error handling. If an error occurs during bin picking operations, an error code is available in M_Status global variable.


The following list shows potential bin picking error codes:

OK = 0 - Service response from Bin Picking Studio is valid

SERVICE_ERR = 1 - Service response from Bin Picking Studio is invalid.

UNKNOWN_REQ = 2 - The Bin Picking Studio has received an unknown request.

COMM_FAILURE = 3 - Communication failure due to socket closure.

BAD_DATA = 4 - Data validation check has failed.

TIMEOUT = 5 - Communication failure due to socket timeout.

UNKNOWN_ERR = 99 - Unspecified internal error

PLANNING_FAILED = 201 - Trajectory planning has failed

NO_PART_FOUND = 202 - No part has been localized

NOT_INIT = 203 - Bin picking application has not been properly initialized on the Bin Picking Studio side.

WRONG_BP_CONFIG = 255 - Wrong Bin Picking Configuration - Check Log Console in the Bin Picking Studio


PHOMAIN already includes basic error handling but can be adapted to deal with more complex scenarios if required.

4.4 MAIN APPLICATION

This is a basic bin picking template. The main program loop is defined here

   ' Copyright (c) 2019 Photoneo s.r.o.
   ' All rights reserved
   ' Description: Photoneo Mitsubishi Module v.1.3 - Main Program
   '
   'Redeclaration of array variables
   Dim M_OperBuff(30)
   Dim J_TrajBuff(10,100)
   Dim M_TrajSizes(10)
   Dim M_GripBuff(10)
   Dim M_InfoData(10)
   '
   'Load PHOCLIENT Module to Slot 2
   XLoad 2,"PHOCLIENT"
   *Start
   If C_Prg(2)<>"PHOCLIENT"  Then GoTo *Start
   XRun 2
   Wait M_Run(2)=1
   ' 
   'Wait for connection
   Wait M_Connect = 1
   '
   'Safety Delay (Do Not Remove!)
   Dly 1.0
   '
   *ReInit
   ' Send Initialize Request
   GoSub *InitReq
   If(M_Status <> M_Ok) Then Hlt
   '
   *ReScan
   'Limit joint speed to 10% of MAX SPEED
   JOvrd 10
   ' Move to Home Pose and Detach Gripper
   Mov JHome
   GoSub *GripDetach
   '
   ' Send First Scan Request
   GoSub *ScanReq
   '
   ' Wait for Scan Completition
   GoSub *WaitForScan
   If((M_Status = M_NotInit) Or (M_Status = M_ServiceErr)) Then *ReInit
   '
   'Initial Wait
   Dly 10
   '
   'Request First Trajectory
   GoSub *TrajReq
   '
   ' Main Loop
   *MainProg
   '
   ' Wait For Trajectory to be Received
   GoSub *TrajRecv
   If((M_Status = M_NotInit) Or (M_Status = M_ServiceErr)) Then *ReInit
   If((M_Status = M_NoPart) Or (M_Status = M_PlanFail)) Then *ReScan
   If(M_Status = M_Ok) Then
   '
   ' Pick Object
   GoSub *PickObject
   '
   ' Move out of scanning volume
   Mov JOutOfScan
   '
   ' Send Next Scan Request
   GoSub *ScanReq
   '
   ' Place Object
   GoSub *PlaceObject
   '
   ' Wait for Scan Completition
   GoSub *WaitForScan
   If((M_Status = M_NotInit) Or (M_Status = M_ServiceErr)) Then *ReInit
   '
   ' Request Trajectory
   GoSub *TrajReq
   '
   ' Return Back to Start Pose
   GoSub *BackToStart
   EndIf
   '
   'Continue in Next Loop
   GoTo *MainProg

5. Runtime

Once all changes have been uploaded to the robot controller, you are ready to start the bin picking application.

The first step is to select the program which will be run. Turn on the Operation Panel and select the PHOMAIN program:


Setting Up Guide Mitsubishi Step 23.png


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


Setting Up Guide Mitsubishi Step 25.png


When you are ready to start binpicking , switch to Auto Mode, turn SERVO ON and hit Start.


Setting Up Guide Mitsubishi Step 24.png


You should see that the Binpicking Status has changed Robot Controller:


Setting Up Guide Mitsubishi Step 26.png


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

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