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
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.
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
| Parameter | Type | Default | Description |
|---|---|---|---|
function_name | str | — | Name for the URScript function as it will be registered on the controller. |
script | str | — | The function body as a URScript string (without the def/end wrapper). |
Return Value
| Type | Description |
|---|---|
bool | True 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:
- You want to run a full program — use Send Custom Script or Send Custom Script File instead
- The function does not need to be callable by name — inline it with
send_custom_scriptinstead

