Warning
You are reading the documentation for an older Pickit release (1.10). Documentation for the latest release (3.4) can be found here.
Universal Robots Example Program
Attention
This article describes the legacy way of using Pickit with a Universal Robot. For new robot programs, please refer to the Installation and setup article.
This program is part of the Universal Robots package which you can download here.
More details about downloading this programs and uploading them on a Universal Robot can be found in the URScript article.
Loading the example program
In the initialization screen, select Program robot
and
then Load program
. Navigate to the folder corresponding to your UR
version and select the program Robot_picking.urp. Click Open. The
program is then loaded.
The example program explained
The example application program Robot_picking.txt executes a simple picking task using Pickit.
Init Variables
BeforeStart
pickit_port≔5001
pickit_ip≔"169.254.5.180"
actual_pose≔get_target_tcp_pose()
pick_pose≔p[0,0,0,0,0,0]
pre_pick_offset≔p[0,0,-0.15,0,0,0]
Script: pickit_functions
pickit_socket_open()
Script: pickit_communication
Script: pickit_transformations
Robot Program
MoveJ
actual_pose
Loop pickit_is_running()
'pickit_configure(1,3)'
If pickit_remaining_objects()≟0
pickit_look_for_object()
Else
pickit_next_object()
Wait pickit_has_response()
If pickit_object_found()
pick_pose≔pickit_get_pose( False )
pre_pick_pose≔pose_trans(pick_pose, pre_pick_offset)
MoveJ
pre_pick_pose
pick_pose
pre_pick_pose
If pickit_object_dim[0] > 0.1
MoveJ
drop_off_large
Else
MoveJ
drop_off_small
pickit_socket_close()
Pickit-related code lines are explained in detail:
pickit_port≔5001
pickit_ip≔"169.254.5.180"
The pickit_port and pickit_ip must be set to their correct values to enable communication between the robot and Pickit.
pick_pose≔p[0,0,0,0,0,0]
pre_pick_offset≔p[0,0,-0.15,0,0,0]
The pose of the next detected object to be picked shall be stored in the pose variable pick_pose. For each pick, it is intended that the tool briefly goes to an intermediary position above the actual pick_pose, before picking the object. The pre_pick_offset defines this offset and will be used later, adding a negative translational component to the z-axis of the tool.
Script: pickit_functions
...
Script: pickit_communication
Script: pickit_transformations
Scripts containing relevant Pickit functions are loaded.
pickit_socket_open()
pickit_socket_close()
Lines 9 and 35 open and close a socket connection with Pickit respectively.
Loop pickit_is_running()
This line indicates that, as long as Pickit is running (i.e., the RUN button is active), the code inside its scope will be executed repeatedly.
'pickit_configure(1,3)'
Pickit is commanded to load the setup and product with codes 1 and 3 respectively. These are the numbers shown next to the setup and product on the Pickit CONFIGURATION page. If this line is suppressed, Pickit keeps its current setup and product. If the specified setup or product does not exist, the program does not proceed. Make sure that the setup and product passed to pickit_configure()are the ones you are expecting, or the robot may have an unexpected behaviour.
If pickit_remaining_objects()≟0
pickit_look_for_object()
Else
pickit_next_object()
If only one object was found the last time Pickit searched for objects, it is ordered to search for objects once again. However, if Pickit found more than one object in its previous search, the next object is requested.
Wait pickit_has_response()
If pickit_object_found()
pick_pose≔pickit_get_pose( False )
pre_pick_pose≔pose_trans(pick_pose, pre_pick_offset)
MoveJ
pre_pick_pose
pick_pose
pre_pick_pose
The program waits until Pickit returns the requested object and, if it is found, the robot shall pick it.The pose that the robot shall reach to pick the object (pick_pose) is returned by the function pickit_get_pose(). Before the actual picking, it is desired that the robot first stops at a distance above the object. This pose is here called pre_pick_pose and is the pick pose translated by 15 cm in the Z direction, as defined by the variable pre_pick_offset. The robot is commanded to adopt first the pre_pick_pose, than the pick_pose (where it actually picks the object), and finally the pre_pick_pose again.
If pickit_object_dim[0] > 0.1
MoveJ
drop_off_large
Else
MoveJ
drop_off_small
In this example application, it is desired that large and small objects are dropped in different places. The robot reaches this places by adopting poses drop_off_large and drop_off_small respectively. As such, depending on the object’s dimensions, defined by pickit_object_dim[0], the robot shall adopt the correct pose to reach the corresponding target place.
Notice that the actual picking is not performed here. The procedure to grasp and drop depends on the employed gripper.
Running the example program
Attention
Before running the program, it should be verified that the robot camera calibration has been done correctly and that the tool frame has been defined correctly.
To allow Pickit to respond to robot requests, Pickit has to be in the Running state. Press the RUN button on the Pickit web interface.
In order to run the program in the robot controller, at the bottom of the graphic interface, make sure that Real robot is selected and that the robot speed is set to a safe value. Click on the rewind button to make sure that the program starts from the beginning - the program line Robot Program shall be highlighted, meaning that’s the point at which the program will start. Finally click on the play button to run the program.
The program execution can be stopped or paused by clicking in the stop and pause buttons respectively.
Danger
When running a program for the first time, it is advised to set a low robot speed. As such, non-expected behaviour (for example due to incorrect programming or wrong calibration) can be identified early enough to prevent the robot from colliding with surrounding objects or people.