Skip to content

Send Custom Script Function

SUMMARY

Send Custom Script Function transmits a named URScript function definition to the robot controller. The function is registered by name and can be called from other URScript programs running on the controller.

Use this skill to pre-load utility functions into the controller without sending a full program.

SUPPORTED ROBOTS

This skill is currently supported on Universal Robots only. Calling this method on other robot brands will raise a NotImplementedError.

The Skill

python
robot.send_custom_script_function(
    function_name="my_func",
    script='textmsg("hello from custom function")',
)

The Code

Example: Register and Send a Named URScript Function

Connect to the robot, register a named function, and disconnect.

python
from loguru import logger
from telekinesis.synapse.robots.manipulators import universal_robots

robot_ip = "192.168.1.2"  # replace with your robot's IP

robot = universal_robots.UniversalRobotsUR10E()
# Connect
robot.connect(ip=robot_ip)

function_name = "my_func"
function_body = 'textmsg("hello from custom function")'
robot.send_custom_script_function(function_name, function_body)
logger.success(f"Custom script function '{function_name}' sent to robot.")

# Disconnect
robot.disconnect()

The Explanation of the Code

send_custom_script_function wraps the provided script body into a URScript function definition using the given function_name, then sends it to the controller. The resulting function can subsequently be called by name from other URScript programs or inline scripts. The call returns True on success.

How to Tune the Parameters

ParameterTypeDefaultDescription
function_namestrName for the URScript function as it will be registered on the controller.
scriptstrThe function body as a URScript string (without the def/end wrapper).

Return Value

TypeDescription
boolTrue if the function was accepted by the controller, False otherwise.

Where to Use the Skill

  • Reusable subroutines — Pre-load helper functions that other URScript programs will call
  • Modular scripting — Separate utility logic from main programs and register them individually

When Not to Use the Skill

Do not use Send Custom Script Function when: