Library implements API for Universal Robots RTDE realtime interface.
Full RTDE description is available on Universal Robots documentation site
RTDE core library
-
rtde.py: RTDE connection management object
-
rtde_config.py: XML configuration files parser
-
rtde_decode.py: Decoders for named RTDE properties (software version, hardware type)
-
csv_writer.py, csv_reader.py: read and write rtde data objects to text csv files
- record.py - example of recording realtime data from selected channels.
- example_control_loop.py - example for controlling robot motion. Program moves robot between 2 setpoints. Copy rtde_control_loop.urp to the robot. Start python script before starting program.
- example_plotting.py - example for using csv_reader, and plotting selected data.
It's recommended to run examples in virtual environment or devcontainer.
# Example for recording realtime data from the robot # NOTE: RTDE interface has to be enabled in the robot security settings cd examples python record.py -h python record.py --host 192.168.0.1 --frequency 10 python record.py --host 192.168.0.1 --frequency 10 --protocol-version 3
Default recording uses record_configuration_v2.xml or record_configuration_v3.xml based on --protocol-version.
RTDE can connect from host system or devcontainer to controller running in a Docker when RTDE port 30004 is forwarded.
# 1. Get latest ursim docker image docker pull universalrobots/ursim_e-series # 2. Run docker container: docker run --rm -dit -p 30004:30004 -p 5900:5900 -p 6080:6080 universalrobots/ursim_e-series # 3. open vnc client in browser, and confirm safety: http://localhost:6080/vnc.html?host=docker_ip&port=6080
More information about ursim docker image is available on Dockerhub
RTDE can connect from host system to controller running in VirtualBox when RTDE port 30004 is forwarded.
- Download simulator from Universal Robots support site
- Run simulator in VirtualBox
- Open menu Devices->Network Settings
- Open Advanced settings for NAT
- Open Port Forwarding
- Add new rule, setting host, and guest ports to 30004. Leave host, and guest IP fields blank.
Building and installing from sources
git clone https://github.com/UniversalRobots/RTDE_Python_Client_Library pip install ./RTDE_Python_Client_Library
Build and install latest from github
# Install from "main" HEAD
pip install git+https://github.com/UniversalRobots/RTDE_Python_Client_Library.git@mainUse pre-built package from github
pip install git+https://github.com/UniversalRobots/RTDE_Python_Client_Library.git@<version-tag> # vX.X.X
Library is compatible with Python 2.7+ and Python 3.6+
mvn package
Create virtual environment, and install wheel package
python -m venv venv source venv/bin/activate pip install wheel # Install pre-built rtde package pip install target/rtde-<version>-release.zip
If Python3 is not installed, then just run python3 from powershell. Microsoft store will launch the installation.
Permission to run scripts in console is needed to activate virtual envrionment.
set-executionpolicy -Scope CurrentUser -ExecutionPolicy Unrestricted python -m venv venv venv/Scripts/Activate.ps1 pip install wheel # Install pre-built rtde package pip install target/rtde-<version>-release.zip
Open project in VSCode and select to "reopen in devcontainer". Execute build command from terminal
Running record.py against simulator:
# first start simulator exposing RTDE port 30004 # docker run --rm -dit -p 30004:30004 -p 5900:5900 -p 6080:6080 universalrobots/ursim_e-series # in devcontainer terminal type cd examples ./record.py --host controller --frequency 10 --verbose
Code is formatted with black. Run code formatter before submitting pull request.
# open project in devcontainer python -m black .