Chapter 6: RTDEIOInterface

About This Chapter

While RTDEControlInterface moves the robot and RTDEReceiveInterface retrieves its state, RTDEIOInterface is the I/O operation interface provided by SDU Robotics’ ur_rtde. It controls the robot’s inputs and outputs (I/O) using writable fields of the official Universal Robots RTDE protocol.

It is used to connect external equipment to the robot, including PLC integration, sensor reading, and control of solenoid valves and grippers.

This chapter covers:

  • Digital I/O

  • Tool I/O

  • Analog I/O


6.1 What Is I/O?

I/O stands for:

Input / Output

In addition to its motors, a robot must communicate with devices such as:

  • Sensors

  • Solenoid valves

  • Solenoids

  • Cylinders

  • Grippers

  • Lamps

  • PLCs

I/O is used to control these devices.


6.2 Types of I/O

UR robots provide several types of I/O.

Type

Purpose

Standard Digital Input

External input

Standard Digital Output

External output

Tool Digital Input

Input at the tool end

Tool Digital Output

Output at the tool end

Analog Input

Analog input

Analog Output

Analog output


6.3 RTDEIOInterface

Creating an instance:

from rtde_io import RTDEIOInterface

rtde_io = RTDEIOInterface(IP)

Typically, the following three interfaces are instantiated together:

RTDEControlInterface

RTDEReceiveInterface

RTDEIOInterface

6.4 Standard Digital Output

This is the most frequently used API.

rtde_io.setStandardDigitalOut(pin, value)

Example:

rtde_io.setStandardDigitalOut(0, True)

This turns DO0 ON.

To turn it OFF:

rtde_io.setStandardDigitalOut(0, False)

6.5 Standard Digital Input

Input states are obtained through RTDEReceiveInterface.

state = rtde_r.getDigitalInState(0)

The return value is:

True

False

6.6 Tool Digital Output

Controls outputs on the tool connector.

rtde_io.setToolDigitalOut(pin, value)

Example:

rtde_io.setToolDigitalOut(0, True)

This can be used to open or close a robot hand.


6.7 Tool Digital Input

Inputs at the tool end are also retrieved through the Receive Interface.

Example:

state = rtde_r.getToolDigitalIn(0)

The API name varies depending on the version.


6.8 Analog Output

Analog voltage output:

rtde_io.setAnalogOutputVoltage(...)

Alternatively, current output:

setAnalogOutputCurrent(...)

These can be used for:

  • Inverters

  • Speed commands

  • Voltage commands


6.9 Analog Input

Analog inputs are obtained through the Receive Interface.

Example:

voltage =

Applications include:

  • Sensor inputs

  • Load cells

  • Displacement gauges


6.10 Gripper Control Example

The simplest sequence is:

OPEN

↓

DO0 ON

↓

Wait 0.5 seconds

↓

DO0 OFF

Python:

rtde_io.setStandardDigitalOut(0, True)

time.sleep(0.5)

rtde_io.setStandardDigitalOut(0, False)

6.11 Toggle Operation

Example of blinking an LED:

while True:

    rtde_io.setStandardDigitalOut(0, True)

    time.sleep(0.5)

    rtde_io.setStandardDigitalOut(0, False)

    time.sleep(0.5)

6.12 Combining Motion and I/O

A typical pick operation:

MoveJ

↓

MoveL

↓

Close Gripper

↓

MoveL

↓

MoveJ

Code example:

robot.move(...)

robot.move(...)

robot.set_do(0, True)

robot.wait_move()

robot.move(...)

6.13 Waiting for an Input

Waiting for a sensor:

while True:

    if rtde_r.getDigitalInState(0):
        break

    time.sleep(0.01)

This can be used for synchronization with a PLC, for example.


6.14 Precautions for I/O Control

Although I/O updates are relatively fast, they are not suitable for precise timing control within a few milliseconds.

When synchronization with robot position is required, consider combining I/O control with URScript or a Robot Program.


6.15 Implementation in ur_ctrl.py

In ur_ctrl.py, it is recommended to wrap the operations in APIs such as:

set_do()

get_di()

set_tool_do()

get_tool_di()

This removes the need for users to interact with RTDEIOInterface directly.


Summary

RTDEIOInterface handles communication with external devices connected to the robot.

Its main uses are:

  • Digital output

  • Digital input

  • Tool I/O

  • Analog I/O

Combining I/O with motion control makes it possible to build practical automated systems.

The next chapter explains the Dashboard Server.