Remote TCP & Toolpath URCap – URScript Functions and Examples
This article explains how to use the URScript functions enabled by the Remote TCP & Toolpath URCap.
Created date: July 22nd, 2020.
Example is valid for: Polyscope for e-Series version: 5.6.0.90886
Note that older or newer software versions may behave differently.
This example can be used for e-Series only. Program files are available for download at the bottom of the page.
The Remote TCP & Toolpath URCap is developed to enhance Universal Robots’ capabilities for process applications. A process application means processing a work-in-process part to drive it closer to a final product. Examples include dispensing, gluing, painting, deburring, sewing, polishing, and welding. The Remote TCP & Toolpath URCap enables two critical functions: Remote Tool Center Point and G-code Toolpath Import.
A set of URScript functions is available to advanced users and UR+ developers who want to use the Remote TCP and G-code Toolpath Import functions without relying on the default GUI in Polyscope. These functions can be embedded in other URCaps for a more streamlined workflow.
Activate URCap
The Remote TCP & Toolpath URCap is embedded in Polyscope 5.6 and above for Universal Robots e-Series. There is no additional charge for using this URCap. To activate this URCap, go to Menu → Settings → System → URCaps → Remote TCP & Toolpath and follow the steps for robot registration and license activation.
- Step 1. Sign in at www.universal-robots.com/activate
- Step 2. Download the registration file to your USB drive
- Step 3. Plug your USB drive into the teach pendant and tap Activate to load the registration file
- Step 4. Restart your robot to complete the activation process
For more information on how to activate this URCap, please refer to Section 11.4 Robot Registration and URCap License Files in Polyscope 5.8 Software Manual or watch this tutorial video on the UR Support Site.
Start URCap Controller
After the URCap is activated, go to Installation → URCaps → Remote TCP & Toolpath to reach the URCap homepage. First, make sure to start the controller on this page before using the URCap. When the controller status is changed to running, you can proceed with using this URCap.
The Remote TCP & Toolpath URCap enables a new URScrip module processpath. It includes the following functions:
Function |
Description |
mc_add_circular(pose_via, pose_to, a, v, r, mode=0) |
Add a motion to move to pose (circular in tool-space) |
mc_add_linear(pose, a, v, r) |
Add a motion to move to pose (linear in tool-space) |
mc_add_path(path_id, a, v, r) |
Add a motion to move according to the g-codes specified in the nc_file. |
mc_get_target_rtcp_speed() |
This command returns the target linear speed of a Remote TCP. |
mc_initialize(mode, tcp, doc=6) |
Initialize a new motion sequence. |
mc_load_path(nc_file, useFeedRate) |
Load a .nc toolpath file. |
mc_run_motion(id=-1) |
Run through the motion with ID id. |
mc_set_pcs(pcs) |
Set the Part Coordinate System (PCS). |
mc_set_speed_factor(s) |
Set speed factor in range [0, 1]. |
Please refer to Section 7 Module processpath in Polyscope 5.8 Script Manual for detailed explanations of these functions.
Load Toolpath File
Please download myToolPathFile.nc attached below. It is a sample G-code toolpath file. Here is an illustration of this toolpath.
If you are testing on a UR robot, please save this toolpath file under the root directory of your USB drive. Navigate to the following page in the URCap to import the toolpath file into Polyscope.
If you are testing on your computer using URSim, please save the toolpath file under "/programs".
If this directory does not exist in your URSim yet, please follow the steps below to create it.
- Open System Tools > XTerm in URSim.
- Go to root directory: cd /
- Create a new folder called "programs": sudo mkdir programs
- Grant permission to access "programs": sudo chmod guoa+wx programs
The following examples show how to use these functions in scripts. Please choose UR5e for testing purposes.
Example 1 - Remote TCP Moves
The URScript file (Example1.script) is attached below.
# Define Remote TCP
remote_tcp = p[-0.3909, -0.519, 0.295, 1.57, 0.0, 0.0]
# Define Part Coordinate System (PCS)
pcs = p[0.0, 0.0, 0.01, 0.0, 0.0, 0.0]
# Initialize with remote TCP (mode = 1) and constrain 6-DOF
mc_initialize(1, remote_tcp, doc = 6)
# Set PCS
mc_set_pcs(pcs)
# Define waypoints
waypoint1 = p[0.05, 0.1, 0.1, 0.0, 0.0, 0.0]
waypoint2 = p[0.05, 0.05, 0.1, 0.0, 0.0, 0.0]
circle_viapoint = p[0.075, 0.1, 0.1, 0.0, 0.0, 0.0]
circle_endpoint = p[0.1, 0.05, 0.1, 0.0, 0.0, 0.0]
# Define motion parameters
acc_factor = 0.05
speed_factor = 0.25
blend_radius = 0.02
# Circular motion in constrained mode
mode=1
# Add linear and circular motions
mc_add_linear(waypoint1, acc_factor, speed_factor, blend_radius)
mc_add_linear(waypoint2, acc_factor, speed_factor, blend_radius)
mc_add_circular(circle_viapoint, circle_endpoint, acc_factor, speed_factor, blend_radius, mode)
# Set different PCS for subsequent motion
pcs = p[0.0, 0.0, 0.02, 0.0, 0.0, 0.0]
acc_factor = 0.1
speed_factor = 1.0
blend_rad_toolpath = 0.0
mc_set_pcs(pcs)
# Add G-code toolpath motion
path_id = mc_load_path("/programs/myToolPathFile.nc", use_feedrate = False)
mc_add_path(path_id, acc_factor, speed_factor, blend_rad_toolpath)
# Execute the motions
mc_run_motion()
Example 2 - Regular TCP Toolpath Moves using 5-DOF
The URScript file (Example2.script) is attached below.
# Define TCP
tcp = p[0.0, 0.03, 0.125, 2.3580, 0.0, 0.0]
# Define Part Coordinate System (PCS)
pcs = p[-0.25, -0.65,0.05,0.0,0.0,-1.57]
# Initialize with regular TCP (mode = 0) and constrain 5-DOF
mc_initialize(0, tcp, doc = 5)
# Define initial waypoint
waypoint1 = p[0.05, 0.1, 0.1, 0.0, 0.0, 0.0]
# Define motion parameters
speed_factor = 0.1
acc_factor = 0.25
blend_radius = 0.02
blend_rad_toolpath = 0.0
# Set PCS
mc_set_pcs(pcs)
# Add a linear motion
mc_add_linear(waypoint1, acc_factor, speed_factor, blend_radius)
# Add G-code toolpath motion
path_id = mc_load_path("/programs/myToolPathFile.nc", use_feedrate = False)
mc_add_path(path_id, acc_factor, speed_factor, blend_rad_toolpath)
# Execute the motions
mc_run_motion()
Example 3 – Toolpath Moves with Digital Output
The URScript file (Example3.script) is attached below.
# This examples demonstrates using motion id to wait for a specific motion to finish and set digital output
# Define Remote TCP
remote_tcp = p[-0.3909, -0.519, 0.295, 1.57, 0.0, 0.0]
# Define Part Coordinate System (PCS)
pcs = p[0.0, 0.0, 0.01, 0.0, 0.0, 0.0]
# Initialize with remote TCP (mode = 1) and constrain 6-DOF
mc_initialize(1, remote_tcp, doc = 6)
# Set PCS
mc_set_pcs(pcs)
# Define waypoints
waypoint1 = p[0.05, 0.1, 0.1, 0.0, 0.0, 0.0]
waypoint2 = p[0.05, 0.05, 0.1, 0.0, 0.0, 0.0]
circle_viapoint1 = p[0.075, 0.1, 0.1, 0.0, 0.0, 0.0]
circle_endpoint1 = p[0.1, 0.05, 0.1, 0.0, 0.0, 0.0]
# Define motion parameters
speed_factor = 0.1
acc_factor = 0.05
blend_radius = 0.02
# Add linear and circular motions
id0 = mc_add_linear(waypoint1, acc_factor, speed_factor, blend_radius)
id1 = mc_add_linear(waypoint2, acc_factor, speed_factor,blend_radius)
id2 = mc_add_circular(circle_viapoint1,circle_endpoint1, acc_factor, speed_factor, blend_radius, mode = 1)
# Define and set PCS for G-code toolpath
pcs_toolpath = p[0.0, 0.0, 0.02, 0.0, 0.0, 0.0]
mc_set_pcs(pcs_toolpath)
# Add G-code toolpath motion
path_id = mc_load_path("/programs/myToolPathFile.nc", use_feedrate = True)
id3 = mc_add_path(path_id, 1.0, 0.0, 0.0)
# Execute motions to id=id2 and wait for id2 to finish.
# This will execute motions from id0 to id2.
mc_run_motion(id2)
# Set digital output
set_standard_digital_out(7, True)
# Execute the rest of the motions - in this case, just id3
mc_run_motion()
# Set digital output
set_standard_digital_out(7, False)