Moving to a position calculated from user input
Let the user enter some dimensions of an object, and then move the robot according to them
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.
We will take 3 examples:
1) Square motion relative to the tool
2) Square motion relative to the tool with blend
3) Square motion relative to the tool with variable blend
1) Square motion relative to the tool
The following program is an example of how to follow a rectangular path, relative to the tool, which dimensions has been assigned by the operator.
It is starting on the current position of the TCP, which is saved under the pose variable start_pose using the script function get_forward_kin().
This can be achieved in SW versions higher that 1.7 also with the script function get_actual_tcp_pose().
Program Robot Program start_pos≔get_forward_kin() // Reads the position of the tool at this point in the program height≔'Height in mm?' // Operator assignment to get the value of the variable height width≔'Width in mm?' // Operator assignment to get the value of the variable width |
The TCP is moving within a loop through the other three corners of the square using MoveL movements with variable positions. These positions are calculated using the script function pose_trans (), with the start position as first argument, and using the values assigned by the operator in its second pose argument to define the dimensions of the rectangle (X and Y).
Loop MoveL corner_1≔pose_trans(start_pos,p[width/1000.0,0.0,0.0,0.0,0.0,0.0]) corner_1 MoveL corner_2≔pose_trans(start_pos,p[width/1000.0,height/1000.0,0.0,0.0,0.0,0.0]) corner_2 MoveL corner_3≔pose_trans(start_pos,p[0.0,height/1000.0,0.0,0.0,0.0,0.0]) corner_3 MoveL start_pos |
Note that X and Y dimensions on the second pose have been divided by 1000 since values are entered by operator in millimetres and they need to be converted to meters when working with script functions.
Please refer to the script manual for further information.
This program can be downloaded from the bottom of this site. square_motion_relative_to_the_tool
2) Square motion relative to the tool with blend
For some applications it will make sense to blend on the corners.
It can be done using the Blend with radius parameter on the command tab in Polyscope for variable positions.
An example using blends like this can be found below. We can see how the move commands are constructed if we look at the essentials of the script code generated from the program.
def square_motion_relative_to_the_tool(): while (True): global start_pos=get_forward_kin() global height=request_float_from_primary_client("Height in mm?") global width=request_float_from_primary_client("Width in mm?") while (True): global corner_1=pose_trans(start_pos,p[width/1000.0,0.0,0.0,0.0,0.0,0.0]) movel(pose_trans(p[0.0,0.0,0.0,0.0,0.0,0.0], corner_1), a=1.2, v=0.25) global corner_2=pose_trans(start_pos,p[width/1000.0,height/1000.0,0.0,0.0,0.0,0.0]) movel(pose_trans(p[0.0,0.0,0.0,0.0,0.0,0.0], corner_2), a=1.2, v=0.25) global corner_3=pose_trans(start_pos,p[0.0,height/1000.0,0.0,0.0,0.0,0.0]) movel(pose_trans(p[0.0,0.0,0.0,0.0,0.0,0.0], corner_3), a=1.2, v=0.25) movel(pose_trans(p[0.0,0.0,0.0,0.0,0.0,0.0], start_pos), a=1.2, v=0.25) end end end |
This program can be downloaded from the bottom of this site. square_motion_relative_to_the_tool_with_variable_blends
3) Square motion relative to the tool with variable blend
The next example is using the blend radius parameter on the movel() script function. You must keep in mind that blends cannot overlap, so the value of the blend radius cannot be higher than half of the shortest side of the rectangle.
Program Robot Program start_pos≔get_forward_kin() height≔'Height in mm?' width≔'Width in mm?' blend_radius≔'Radius' // Operator assignment to get the value of the variable blend_radius If 2*blend_radius>height // Checks whether entered blend radius value fits within height value blend_radius≔height/2.0 // Assign maximum value if limitation is exceeded If 2*blend_radius>width // Check whether entered blend radius value fits within width value blend_radius≔width/2.0 // Assign maximum value if limitation is exceeded |
This time the value for the blend radius is being assigned by the operator. If the limitation for the blend radius value is exceeded then the program will detect it and modify the value to its maximum allowed.
Loop corner_1=pose_trans(start_pos,p[width/1000.0,0.0,0.0,0.0,0.0,0.0]) movel(corner_1,a=1.2,v=0.25,r=blend_radius/1000.0) corner_2=pose_trans(start_pos,p[width/1000.0,height/1000.0,0.0,0.0,0.0,0.0]) movel(corner_2,a=1.2,v=0.25,r=blend_radius/1000.0) corner_3=pose_trans(start_pos,p[0.0,height/1000.0,0.0,0.0,0.0,0.0]) movel(corner_3,a=1.2,v=0.25,r=blend_radius/1000.0) movel(start_pos,a=1.2,v=0.25,r=blend_radius/1000.0) |
This program can be downloaded from the bottom of this site. Program name is square_motion_relative_to_the_tool_with_blends