Bin Picking Tutorial: Setting up Photoneo Bin Picking Studio with MITSUBISHI robots
NOTE: Users are strongly recommended to read the general introduction to robot interfaces prior to installing specific robot modules.
- 1 1. Prerequisites
- 2 2. Mitsubishi Controller Setup
- 3 3. Project Setup
- 4 4. MELFA V Language
- 5 5. Runtime
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:
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:
Turn ON the Keyboard by pressing KEY at the bottom and type NETIP to the search box:
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).
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.
The default configuration should work with RTToolbox3. Do not change any parameters in Communication Settings here unless you know exactly what you are doing:
2.3 Go Online
If the project configuration has been completed successfully , RTToolbox should be in Offline mode:
Change to Online mode to start configuring the Robot Controller:
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:
Select four program files from the ZIP archive and copy them to the robot. Ensure that you have selected the correct Source and Destination:
As the next step, open Parameter -> Parameter List and search for PRGUSR:
Type PHOCOMMON here to enable the sharing global of variables across all programs:
Next browse to Parameter -> Program Parameter -> Command and ensure that RAD is selected:
Then browse to Parameter -> Communication Parameter -> Ethernet
Basic network parameters are shown here including NETIP which was configured in the first step:
Now switch to Device and Line. The Photoneo Mitsubishi Module utilizes OPT12 and OPT13 devices:
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
Configure OPT13 as a Server and change protocol to Data Link. The default port utilized for State Server is 11004
Now browse to Parameter -> Program Parameter -> Slot Table.
As is shown in the figure below the PHOSTATE program should be added to Slot 8:
Double click on Slot8 and select the PHOSTATE program.
Change the conditions to ALWAYS to ensure that the PHOSTATE program starts at boot:
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.
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:
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)
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.
- *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
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:
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:
When you are ready to start binpicking , switch to Auto Mode, turn SERVO ON and hit Start.
You should see that the Binpicking Status has changed Robot Controller:
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.