Connection and Disconnection
SUMMARY
Connection and Disconnection manages the robot-controller session lifecycle for reliable runtime communication.
This skill ensures robust setup and teardown of robot communication channels before and after task execution.
SUPPORTED ROBOTS
This skill is currently supported on Universal Robots only.
The Skill
robot.connect(ip=robot_ip)
robot.disconnect()The Code
Example 1: Basic connect and disconnect
Create a robot instance, connect to the controller, run your task, then disconnect cleanly.
from telekinesis.synapse.robots.manipulators import universal_robots
robot_ip = "192.168.1.2" # replace with your robot's IP
robot = universal_robots.UniversalRobotsUR10E()
robot.connect(ip=robot_ip)
# ... perform robot tasks here ...
robot.disconnect()Example 2: Connect with error handling
Wrap the connection in a try/except block to handle network or configuration failures gracefully.
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()
try:
robot.connect(ip=robot_ip)
except RuntimeError as e:
logger.error(f"Connection failed: {e}")
raise
# ... perform robot tasks here ...
robot.disconnect()The Explanation of the Code
connect opens the communication session between Synapse and the robot controller. For Universal Robots, this establishes two RTDE (Real-Time Data Exchange) interfaces — one for control commands and one for receiving robot state. The call blocks until the session is ready or raises a RuntimeError if it cannot reach the controller.
disconnect closes the session and stops the RTDE script running on the controller. If disconnect is called before a connection was established, a RuntimeWarning is logged but no exception is raised.
IP address. Pass the IP address of the robot controller as a string. The robot must be powered on, reachable on the network, and configured to allow remote control before calling connect.
Error handling. connect raises a RuntimeError if the connection attempt fails — for example due to an incorrect IP address, a network routing issue, or the robot not being in remote-control mode. Wrapping the call in a try/except block (as in Example 2) is recommended in production code.
How to Tune the Parameters
connect
| Parameter | Type | Default | Description |
|---|---|---|---|
ip | str | — | IP address of the robot controller. Must be reachable from the host machine. |
disconnect
No parameters.
TIP
Always call disconnect after task execution to cleanly release the controller session. Leaving sessions open can prevent other processes from connecting.
WARNING
connect will raise a RuntimeError if the robot is not powered on, the IP address is wrong, or remote control is not enabled on the teach pendant. Verify all three before calling.
Where to Use the Skill
- Session setup — Call
connectonce at the start of every script before issuing any motion or query commands - Session teardown — Call
disconnectat the end of every script to release the controller session - Error recovery — Re-connect after a communication fault to restore the control session without restarting the process
When Not to Use the Skill
Do not call connect or disconnect when:
- The robot is already connected — calling
connectagain on an active session will overwrite the existing RTDE interfaces; disconnect first if reconnecting intentionally - Inside a tight control loop — establishing an RTDE session has latency; connect once at startup and reuse the session throughout execution

