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
Line 219: Line 219:
 
- '''*TrajReq''' - request to start trajectory planning for current goal. Non-blocking function; the AS program continues immediately at the next line.
 
- '''*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 binpicking trajectories (consisting of a sequence of trajectory and gripper operations). Blocking function; waits for motion data to be received.
+
- '''*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.
 
- '''*ChangeSol''' - request to change currently deployed solution.
Line 309: Line 309:
  
 
This is a basic bin picking template. '''The main program loop is defined here'''
 
This is a basic bin picking template. '''The main program loop is defined here'''
 
  
 
     ' Copyright (c) 2019 Photoneo s.r.o.
 
     ' Copyright (c) 2019 Photoneo s.r.o.
Line 394: Line 393:
 
     'Continue in Next Loop
 
     'Continue in Next Loop
 
     GoTo *MainProg
 
     GoTo *MainProg
 
  
 
== 5. Runtime ==
 
== 5. Runtime ==
Line 400: Line 398:
 
Once all changes have been uploaded to the robot controller, you are ready to start the bin picking application.
 
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. Select PHOMAIN program:
+
The first step is to select the program which will be run. Select '''PHOMAIN''' program:

Revision as of 13:36, 7 March 2019

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

1. Prerequisites

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

  • - CR750D
  • - CR800

The robot used for the development: RV2-FR + CR800 controller with firmware version as shown in the figure below:


Setting Up Guide Mitsubishi Step 22.png


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

2. Mitsubishi Controller Setup

2.1 Set IP Address

Setting up an IP Address of 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)

Turn on the Robot Controller and Click the MEMU at the bottom. Select Parameter to open the Parameter list:


Setting Up Guide Mitsubishi Step 17.png


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


Setting Up Guide Mitsubishi Step 21.png


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


Setting Up Guide Mitsubishi Step 19.png


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.


Setting Up Guide Mitsubishi RT Toolbox 1.png


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


Setting Up Guide Mitsubishi RT Toolbox 2.png

2.3 Go Online

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


Setting Up Guide Mitsubishi Step 0.png


Change to Online mode to start configuring Robot Controller:


Setting Up Guide Mitsubishi Step 2.png

3. Project Setup

Photoneo Mitsubishi Interface consists of following .prg 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 amend program, poses, logic and gripper actions 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.

3.1 Transfering 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:


Setting Up Guide Mitsubishi Step 3.png


Select four program files and copy them to the robot. Ensure that you have selected proper Source and Destination:


Setting Up Guide Mitsubishi Step 4.png

3.2 Parameters

As a next step Open Parameter List and search for a PRGUSR:


Setting Up Guide Mitsubishi Step 5.png


Type PHOCOMMON here to enable sharing global variables within all programs:


Setting Up Guide Mitsubishi Step 6.png


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


Setting Up Guide Mitsubishi Step 7.png


As a next step browse to Parameter -> Communication Parameter -> Ethernet

Basic networking parameters are shown here including NETIP configured as a first step:


Setting Up Guide Mitsubishi Step 8.png


Now switch to Device and Line. Photoneo Mitsubishi Module utilize OPT12 and OPT13 Devices:


Setting Up Guide Mitsubishi Step 9.png


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


Setting Up Guide Mitsubishi Step 10.png


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


Setting Up Guide Mitsubishi Step 11.png


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:


Setting Up Guide Mitsubishi Step 15.png


Double click on Slot8 and select the PHOSTATE program.

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


Setting Up Guide Mitsubishi Step 16.png


3.3 Reteach 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 PHOMAIN file and select Joint Tab at the bottom of the screen to show a list of joint positions defined within the 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).

  • - JHome - the robot Home position it should not interfere with 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)
  • - 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)
  • - 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)
  • - JPlaceUp - Place Up Pose - pose above final placing pose (Local Variable depends on the application)
  • - JPlace - Place Pose - the final placing pose (Local Variable depends on the application)

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.


Setting Up Guide Mitsubishi Step 12.png

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

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:


Setting Up Guide Mitsubishi Step 13.png

3.5 Gripper commands

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

Scroll down in PHOMAIN program and find 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 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: The WaitForScan has to be called after the ScanReq. A user can perform standard robotic commands between these two calls but cannot perform any other Photoneo Bin Picking API calls. The WaitForScan function has to be finished first. For example - ScanReq followed by TrajReq results in communication error.


NOTE #2: The TrajRecv has to be called after the TrajReq. A user can perform standard robotic commands between these two calls but cannot perform any other Photoneo Bin Picking API calls. The TrajRecv function has to be finished first. For example - the TrajReq followed by the ScanReq results in a communication error.

4.2 MELFA CONFIG

Photoneo Mitsubishi Interface enables the user to configure several to 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 performing bin picking sequences, which consist of various numbers of operations to be performed. Do not edit !!!

- *PlaceObject - placing operation. Adapt placing sequence 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.


Following is the list of 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 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


The PHOMAIN already includes basic error handling but it can be adapted to 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. Select PHOMAIN program: