In this example, PreciseVision is used to determine the location of a part that is then acquired by the robot. The output of the vision process is used to create a reference frame, and the robot is moved to a point relative to that reference frame.
In particular, the robot moves to the location safe to avoid blocking the camera's field-of-view. The Vision object vis is then used to connect with PreciseVision and execute the vision process "Main". This vision process takes a picture and executes vision tools to locate the part and perform any desired visual verifications. At the end of the vision process, all that GPL requires is the results of the tool “part1”, which contains the location of the part. The GPL procedure then checks the ResultCount property to ensure that at least one set of results is available. The Result method returns the first set of results from "part1" in the VisResult object vResult. The returned vision location is used to create the object vsRefFrame, which is the reference frame for location vsRelPoint. The robot moves to vsRelPoint and finally moves back to its safe location.
Public Sub MAIN
Dim vis As New Vision
Dim vResult As New VisResult
Robot.Attached = 1
Move.Loc(safe, vsProfile)
vis.Process("Main") ' Run vision process "Main"
If vis.ResultCount("part1") = 0 Then
Console.Writeline("Vision object not found")
Goto done
End If
vResult = vis.Result("part1", 1) ' Get results
' Create a reference frame object and set it
' equal to the returned vision location
Dim vsRefFrame As New RefFrame
vsRefFrame.Loc.PosWrtRef = vResult.Loc
' Pickup point is relative to new frame
vsRelPoint.RefFrame = vsRefFrame
Move.Approach(vsRelPoint, vsProfile)
Move.Loc(vsRelPoint, vsProfile)
Move.Approach(vsRelPoint, vsProfile)
' Move back to safe location
Move.Loc(safe, vsProfile)
done:
End Sub