Interpolate a square or lattice using scripts
Explains how to use script codes to interpolate a square or lattice for robot movements
Examples are valid for:
CB2 Software version: 1.8.16941
CB3 Software version: 3.1.17779
e-Series Software version: All versions
Note that older or newer software versions may behave differently.
In order to move the robot to position along the sides of a square or in a lattice, four corner points must be given. These will be called A, B, C and D.
This example uses the function “interpolate_pose()”, please refer to the functionality of this in the script manual or in this How to: Interpolate a pose using script
A square is defined by four corners, A, B, C and D. Between these waypoints, there are “i” positions between A and B, and “j” positions between A and D.
In order to define the sides or lattice positions of the square, the function interpolate_pose is used. The function returns an intermediate position between the two waypoints given.
First we find the position in the “I”-direction, which is the position between A and B, D and C respectively.
ab = interpolate_pose(A, B, i)
dc = interpolate_pose(D, C, i)
This gives two positions, ab and dc. If “i” is 0.25, the point would be 1/4 of the way between A and B, which can be illustrated as below.
The lattice point will then be on the dotted line between ab and dc. This is found using this command:
lattice_point = interpolate_pose(ab, dc, j) |
If j is 0.50 the position found would be:
Thus the lattice point 0.25/1 of the way between A and B and 0.50/1 of the way between A and D is found.
The script codes may be created as a script file, that can be used to get to the different lattice positions. This is also the concept used in the Palletizing wizard.
The script file could look like:
def Lattice(A, B, C, D, i, j): ab = interpolate_pose(A, B, i) dc = interpolate_pose(D, C, i) lattice_point = interpolate_pose(ab, dc, j) return lattice_point end |
This script file may be used in programs and called as an assignment.
Note: Download example is available below for better understanding, open .urp on your offline simulator.