{"id":8755,"library":"ur-rtde","title":"ur-rtde","description":"ur-rtde is a Python interface for controlling and receiving data from Universal Robots (UR) manipulators using the Real-Time Data Exchange (RTDE) interface of the robot. It is a C++ library with Python bindings, providing fast and lightweight communication. The current version is 1.6.3, released on March 13, 2026. The library is actively maintained with a somewhat regular, though not strictly fixed, release cadence.","status":"active","version":"1.6.3","language":"en","source_language":"en","source_url":"https://gitlab.com/sdurobotics/ur_rtde","tags":["robotics","Universal Robots","RTDE","real-time","industrial automation","hardware interface"],"install":[{"cmd":"pip install ur-rtde","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"The Python interface is built on C++ bindings; the underlying C++ library is required for full functionality and often for development, though `pip install ur-rtde` typically handles this for Python users.","package":"librtde","optional":false}],"imports":[{"symbol":"RTDEControlInterface","correct":"from rtde_control import RTDEControlInterface"},{"symbol":"RTDEReceiveInterface","correct":"from rtde_receive import RTDEReceiveInterface"},{"symbol":"RTDEIOInterface","correct":"from rtde_io import RTDEIOInterface"}],"quickstart":{"code":"import rtde_control\nimport rtde_receive\nimport rtde_io\nimport time\n\n# Replace with your robot's IP address\nROBOT_IP = os.environ.get('UR_ROBOT_IP', '192.168.1.10')\n\ntry:\n    # Initialize RTDE interfaces\n    rtde_r = rtde_receive.RTDEReceiveInterface(ROBOT_IP)\n    rtde_c = rtde_control.RTDEControlInterface(ROBOT_IP)\n    rtde_io_ = rtde_io.RTDEIOInterface(ROBOT_IP)\n\n    if not rtde_r.isConnected():\n        print(f\"Could not connect to RTDE Receive interface at {ROBOT_IP}\")\n        exit()\n    if not rtde_c.isConnected():\n        print(f\"Could not connect to RTDE Control interface at {ROBOT_IP}\")\n        exit()\n\n    print(\"Successfully connected to the robot.\")\n\n    # Start synchronization\n    rtde_r.startFileSynchronization(\"\") # No recipe file for quickstart, use default\n    rtde_c.sendStart()\n\n    # Example: Read a robot state (joint positions)\n    print(f\"Current Joint Positions: {rtde_r.getActualQ()}\")\n\n    # Example: Send a simple move command (blocking)\n    # NOTE: Ensure the robot is in 'Remote Control' mode and 'External Control' URCap is running on the robot.\n    # This example assumes the robot is ready to receive commands.\n    # Make sure this move is safe for your robot setup.\n    # target_q = [-1.5, -1.8, 1.8, -1.8, -1.5, 0.0] # Example joint configuration in radians\n    # if rtde_c.moveJ(target_q, 0.5, 0.3): # speed, acceleration\n    #     print(\"Robot moved to target joint configuration.\")\n    # else:\n    #     print(\"Failed to move robot.\")\n\n    # Example: Set a digital output\n    # rtde_io_.setStandardDigitalOut(0, True)\n    # print(\"Set digital output 0 to True\")\n    # time.sleep(1)\n    # rtde_io_.setStandardDigitalOut(0, False)\n    # print(\"Set digital output 0 to False\")\n\nfinally:\n    # Stop RTDE communication and disconnect\n    if 'rtde_c' in locals() and rtde_c.isConnected():\n        rtde_c.sendPause()\n        rtde_c.disconnect()\n        print(\"Disconnected RTDE Control Interface.\")\n    if 'rtde_r' in locals() and rtde_r.isConnected():\n        rtde_r.disconnect()\n        print(\"Disconnected RTDE Receive Interface.\")","lang":"python","description":"This quickstart demonstrates how to connect to a Universal Robot using the RTDE Receive and Control interfaces, retrieve current joint positions, and prepare for sending commands. Ensure your robot's IP address is correct and the 'External Control' URCap is running on the robot controller for control commands. The commented-out sections show examples of moving the robot and controlling I/O. **Always ensure robot movements are safe before execution.**"},"warnings":[{"fix":"Always check the `ur-rtde` documentation for compatibility with your robot's PolyScope software version. Update `ur-rtde` to the latest version. Monitor Universal Robots' official communication for RTDE protocol updates.","message":"The RTDE protocol may be updated by Universal Robots. New UR software versions can introduce protocol changes, potentially leading to incompatibility with older `ur-rtde` versions or requiring clients to explicitly request compatible protocol versions.","severity":"breaking","affected_versions":"All versions, depending on robot PolyScope software version."},{"fix":"Implement external synchronization mechanisms (e.g., mutexes, locks) if using `RTDEControlInterface` in a multi-threaded application to ensure only one thread accesses it at a time.","message":"The `RTDEControlInterface` is explicitly stated as *not thread-safe*. Concurrent calls from multiple threads without proper synchronization can lead to unpredictable behavior, including connection issues or robot control errors.","severity":"gotcha","affected_versions":"All versions."},{"fix":"For Linux, install and enable a real-time kernel (e.g., `PREEMPT_RT`). Follow OS-specific guides for real-time setup to improve performance and stability.","message":"For precise and safe real-time control, particularly under high system load, `ur-rtde` highly recommends running on an operating system with a real-time kernel.","severity":"gotcha","affected_versions":"All versions."},{"fix":"Upgrade your pip version before installing `ur-rtde`: `pip install --upgrade pip`.","message":"Installation via `pip` can fail if your `pip` version is older than 19.3.","severity":"gotcha","affected_versions":"< 1.6.3, but generally good practice to have a recent pip."},{"fix":"Ensure the robot controller and the computer running `ur-rtde` are on the same IP subnet with compatible IP addresses. Disable firewalls temporarily for testing, then configure rules to allow communication on necessary ports (e.g., 30004, 30001, 50002).","message":"Incorrect network configuration (e.g., robot and PC not in the same IP subnet, active firewalls) is a frequent cause of connection failures.","severity":"gotcha","affected_versions":"All versions."}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Check network cable and connections. Verify the robot's IP and network settings. Ensure no other applications are interfering with the RTDE ports. Restart the robot controller and your Python script. Consider running on a real-time OS.","cause":"Loss of network connection, underlying C++ library issues, or an unexpected state on the robot controller.","error":"RTDEControlInterface: Could not receive data from robot... read: End of file / RTDEControlInterface: Lost connection to robot... write: Broken pipe / Segmentation fault (core dumped)"},{"fix":"Manually start or ensure the 'External Control' URCap (or equivalent PolyScope program) is running on the robot controller. Some `ur-rtde` functions automatically upload and start this script, but a manual check might be necessary after disconnections.","cause":"The external control script required by the RTDEControlInterface is not active on the Universal Robot controller. This often happens after a connection drop and subsequent reconnection attempt.","error":"RTDEControlInterface: RTDE control script is not running!"},{"fix":"Ensure only one client is configured to control a specific input register at a time. Review all running programs on the robot and any other connected RTDE clients.","cause":"Attempting to write to an RTDE input register that is already being controlled by another RTDE client or a URCap on the robot.","error":"RuntimeError: One of the RTDE input registers are already in use!"},{"fix":"Consult the specific `ur-rtde` version's API documentation and examples for I/O handling. Verify the robot's I/O configuration in PolyScope. Test with simpler, known-good I/O examples if available.","cause":"Misunderstanding the scaling or behavior of analog/digital I/O functions, or potential library-specific quirks in certain versions.","error":"Unpredictable Analog Output Voltage / Cannot read Digital Input (values are incorrect or always 0)"}]}