Using Vision with the Robot

Before you can use results from a vision sequence to guide the robot, you need to calibrate the camera that is used by the sequence. Refer to the following for details.
Vision Calibration

If you attempt to get a result from a sequence object that requires calibration and there is no calibration, then a run time error will occur.

Position Results

All position results reported by objects in a vision sequence that uses a robot-calibrated camera are in the specified local coordinate system. Unlike other robot/vision systems, there is no extra step to do a pixel coordinate to robot coordinate transformation function call. This is completely handled by Vision Guide 8.0. The X, Y, and U coordinates of the part in the robot local coordinate system can easily be retrieved.
To accurately position an end effector at a position determined by the vision system, you need to define a tool for the end effector. See Defining a Tool in the next section.
The following results can be used for guiding the robot:

Results Description
RobotXYU Returns x, y, and u along with found status.
RobotToolXYU

Upward camera only

Returns X, Y, and U coordinate values to define a robot tool with found status

RobotX Returns the X coordinate.
RobotY Returns the Y coordinate.
RobotU Returns the U coordinate.
RobotPlacePos

Upward camera only

Returns a robot position in Point in order to place the detected part to the work place position (RobotPlaceTargetPos) registered to CalRobotPlacePos.

Caution: CalRobotPlacePos needs to be set for each object.

The U coordinate 0° position is along the Y-axis pointing straight out from the robot base.
The following illustration supplements RobotPlacePos.

In this illustration, an upward camera is located on robot coordinates, which is a work plane, and a workpiece placement position (RobotPlaceTargetPos) specified in CalRobotPlacePos is registered. In practice, after detecting a picked workpiece position (VRun) by using a vision sequence which uses an upward camera, and then a robot position to place the workpiece (RobotPlacePos) will be gotten (VGet).
The right side of the illustration shows the state after moving to RobotPlacePos. After moving to RobotPlacePos, the position and posture of a workpiece can match a workpiece placement position.
RobotPlacePos gets a point which posture flag is default, so correcting can be required to move. The following example shows how to detect a position of a picked workpiece with an upward camera and move it on a workpiece placement position in a way to reduce the amount of joint movement.

Function placePart  
	'Move robot into position snapshot   
	Go camshot  
	  
	VRun findPart  
	VGet findPart.Blob01.RobotPlacePos, P100  
	  
	'------------------\-  
	' When the robot is SCARA  
	Double diffJ4 'Angle difference between RobotPlacePos and latch position(J4)  
	diffJ4 = PAgl(P100, 4) \- PAgl(LatchPos(WithoutToolArm), 4)  
	If diffJ4 > 180 Then  
		Go P100 -U(360) 'Joint4 will be the shortest movement  
	ElseIf diffJ4 < -180 Then  
		Go P100 +U(360) 'Joint4 will be the shortest movement  
	Else  
		Go P100  
	EndIf  
	  
	'------------------\-  
	' When the robot is 6-axis  
	Go P100 LJM 4	 '4: Joint6 will be the shortest movement  
Fend  

The error 4007 can be occurred when a point gotten by RobotPlacePos was outside of a moving area. Change a workpiece placement position or use RobotToolXYU.

Defining a Tool

It is important to define tools for the robot end effectors.
This tells the robot where the end effector is, so that all position information is with respect to the end effector, not the TOOL 0 position.
Use the TLSET command to define a tool in SPEL+.
The following are three methods for defining tool offsets.

Define a tool with the Robot Manager Tool Wizard
You can use the Tool Wizard in the Robot Manager to define a tool.
To use the Tool Wizard, perform the following steps:

  1. Open the Robot Manager.
  2. Click the [Tools] tab.
  3. Click the [Tool Wizard] button.
  4. Follow the steps in the wizard to create the tool.

Using a fixed upward camera to calculate tool offsets
Here is an example of how to use a fixed upward camera to calculate tool offsets. It uses the RobotToolXYU result to determine the tool offsets.
The function first runs a sequence to locate the tip of the tool. Then the tool offsets are retrieved using VGet RobotToolXYU, and the tool is defined using TLSet.

Function DefineTool	  
  Boolean found  
  Real xTool, yTool, uTool  
	  
  VRun findTip  
  VGet findTip.tip.RobotToolXYU, found, xTool, yTool, uTool  
  If found Then  
    TlSet 1, XY(xTool, yTool, 0, 0)  
EndIf  
Fend  

Manually calculating tool offsets
In the following steps, you must Jog the robot with the Jog buttons from the Jog & Teach window. You cannot free the axes (using SFREE), and move the robot manually when calculating the tool offsets as shown below.
Perform the following steps to calculate tool offsets.

KEY POINTS


  • When using the vertical 6-axis robot, execute the following Local command and then follow the steps on the next page. > Local 1,Here
  • When acquiring the current position in the calculation steps below, the position in Local 1 should be used. If using the Jog & Teach window, set the jog mode to “Local”, display mode for the current position to “World”, and the Local number to “1”. If using the command window, the position of Local 1 can be checked by executing the command as follows.
    > Print Here@1  
    
  1. Position the U axis at 0°.
  2. Set tool to “0” (TOOL 0).
  3. Jog the end effector over a reference point and align it carefully. Do not change the U axis setting.
  4. Write down the current X and Y coordinates as X1 and Y1.
  5. Jog the U axis to the 180° position.
  6. Jog the end effector over the reference point and align it carefully. Do not change the U axis setting.
  7. Write down the current X and Y coordinates as X2 and Y2.
  8. Use the following formula to calculate tool offsets:
    xTool = (X2 - X1) / 2
    yTool = (Y2 - Y1) / 2
  9. Define the tool from the Tools page on the Robot Manager or from the Command window.
    TLSET 1, XY(xTool, yTool, 0, 0)
  10. Test the tool settings:
    Set the current tool to the tool you defined in the previous step. For example, TOOL 1. Jog the end effector over the reference point. Now jog the U axis. The end effector should remain over the reference point.

Tool Calculation for Circuit Board Held by the Robot

In this example, Vision Guide 8.0 calculates a tool for a circuit board that is being held by the robot. Coordinates of two reference points in the circuit board calculate tool offsets. This requires one fixed upward camera. You will need to teach the place position for the board one time after calibrating the camera.

To teach the place position:

  1. Pick up the circuit board with the robot.

  2. Call the example function CalcBoardTool to calculate tool 1.

  3. Switch to Tool 1.

  4. Jog the robot to the place position of the board.

  5. Teach the place position.

    Conventions Description
    a Reference point 1 (Fid1CamPos)
    b Circuit board
    c TOOL offset to be calculated
    d Reference point 2 (Fid2CamPos)
    e Holding position
Function CalcBoardTool As Boolean  
  Boolean found  
  Real x, y, theta  
  Real toolX1, toolY1, toolU  
  Real toolX2, toolY2  
  
  CalcBoardTool = False  
  Jump Fid1CamPos  ' Locate fiducial 1 over camera  
  VRun SearchFid1  
  VGet SearchFid1.Corr01.RobotToolXYU, found, toolX1, toolY1, toolU  
  If Not found Then  
    Exit Function  
  EndIf  
  
  Jump Fid2CamPos  ' Locate fiducial 2 over camera  
  VRun SearchFid2  
  VGet SearchFid2.Corr01.RobotToolXYU, found, toolX2, toolY2, toolU  
  If Not found Then  
    Exit Function  
  EndIf  
  x = (toolX1 + toolX2) / 2  
  y = (toolY1 + toolY2) / 2  
  theta = Atan2(toolX1 \- toolX2, toolY1 \- toolY2)  
  toolU = RadToDeg(theta)  
  TlSet 1, XY(x, y, 0, toolU)  
  CalcBoardTool = True  
Fend  

When using a J2 mount camera for pallet search, the camera imaging position is hard to control. However, the camera moves easily to each imaging position on the pallet by defining an Arm for the camera using the Arm command. For details on the Arm command, refer to the following.
"Epson RC+ 8.0 SPEL+ Language Reference"

Tips:
The Arm command is only available for the SCARA robots.