Universal Robots Real-Time Data Exchange (RTDE) Python Client Library

repository·main·Indexed 41 days ago

https://github.com/universalrobots/rtde_python_client_library

A Python client library for interacting with the Universal Robots Real-Time Data Exchange (RTDE) interface. It enables high-frequency data collection and robot control, supporting Python 2.7+ and 3.6+. The library includes tools for managing RTDE connections, parsing XML configuration files, and reading/writing data objects to CSV files.

Tokens
810
Snippets
3
Records
5
Agent score
3%

What's inside RTDE Python Client Library

  1. Overview of the rtde core library structure

    main

    The rtde package contains the core logic for interacting with the robot:

    • rtde.py: Manages the RTDE connection.
    • rtde_config.py: Parses XML configuration files.
    • csv_writer.py & csv_reader.py: Handles reading and writing RTDE data objects to/from CSV files.

    Available examples in the examples/ directory include:

    • record.py: Recording realtime data.
    • example_control_loop.py: Controlling robot motion between setpoints (requires copying rtde_control_loop.urp to the robot).
    • example_plotting.py: Plotting data using csv_reader.
  2. Install the RTDE Python Client Library

    main

    You can install the library using several methods depending on your requirements:

    From Source (GitHub)

    To install the latest version from the main branch:

    pip install git+https://github.com/UniversalRobots/RTDE_Python_Client_Library.git@main

    To install a specific version tag:

    pip install git+https://github.com/UniversalRobots/RTDE_Python_Client_Library.git@vX.X.X

    Using a Pre-built Release Package

    It is recommended to use a virtual environment for installation.

    Linux & MacOS

    python -m venv venv
    source venv/bin/activate
    pip install wheel
    pip install target/rtde-<version>-release.zip

    Windows PowerShell

    Note: You may need to set the execution policy to run the activation script.

    set-executionpolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
    python -m venv venv
    venv\Scripts\Activate.ps1
    pip install wheel
    pip install target/rtde-<version>-release.zip

    Compatibility

    • Python 2.7+
    • Python 3.6+
    pip install git+https://github.com/UniversalRobots/RTDE_Python_Client_Library.git@main
  3. Set up the UR Simulator using VirtualBox

    main

    To connect to a simulator running in VirtualBox, you must forward the RTDE port 30004 via NAT settings:

    1. Download the simulator from the Universal Robots support site.
    2. Run the simulator in VirtualBox.
    3. In VirtualBox, go to Devices -> Network Settings.
    4. Open Advanced settings for NAT.
    5. Open Port Forwarding.
    6. Add a new rule: set both Host Port and Guest Port to 30004. Leave the IP fields blank.
  4. Set up the UR Simulator using Docker

    main

    You can run a robot simulator in Docker and connect to it via RTDE by forwarding port 30004.

    1. Pull the latest image:
      docker pull universalrobots/ursim_e-series
    2. Run the container with necessary ports forwarded (30004 for RTDE, 5900 for VNC, 6080 for web VNC):
      docker run --rm -dit -p 30004:30004 -p 5900:5900 -p 6080:6080 universalrobots/ursim_e-series
    3. Access the VNC client in your browser to confirm safety: http://localhost:6080/vnc.html?host=docker_ip&port=6080
    docker run --rm -dit -p 30004:30004 -p 5900:5900 -p 6080:6080 universalrobots/ursim_e-series
  5. Run the record.py example to capture robot data

    main

    The record.py script allows you to record realtime data from selected channels on the robot.

    Prerequisite: The RTDE interface must be enabled in the robot's security settings.

    To run the example, navigate to the examples directory and use the --host and --frequency flags:

    cd examples
    python record.py --host <robot_ip> --frequency <hz>
    python record.py --host 192.168.0.1 --frequency 10