Skip to content

I/O

Digital outputs and inputs, timed pulses, and analogue I/O on contexts that wire it.

Usage

# Set output by channel number
api.io.set_output(1, True)       # sets bit 0 of the DiO word (Digout.o1 is SEND-only readback in the shipped configs)
api.io.set_output(3, False)      # clears bit 2 of the DiO word

# Generic toggle (any per-bit group declared writable in RECEIVE)
api.io.toggle("MyOutputs", "o1", True)

# Read input (Digin.i1 if declared, else bit 0 of the DiL word)
if api.io.get_input(1):
    print("Sensor triggered")

# Timed pulse (blocking)
api.io.pulse(2, duration=0.1)    # 100ms pulse on output 2

# Analogue I/O (Max context: ANIN / MAP2ANOUT objects). Raises if not wired.
value = api.io.read_analog()     # $ANIN[1]
api.io.set_analog(0.5)           # $ANOUT[1]

Reference

IOAPI

IOAPI(client: RSIClient)

Digital I/O control interface for KUKA RSI robot control.

Manages digital input/output signals for coordinating with external systems, controlling pneumatic tools, and synchronizing with sensors.

Initialize IOAPI namespace.

Parameters:

Name Type Description Default
client RSIClient

RSIClient instance for variable access

required

toggle

toggle(group: str, name: str, state: Union[bool, int]) -> str

Set a digital I/O variable to the specified state.

Parameters:

Name Type Description Default
group str

Parent I/O variable group (e.g., 'Digout', 'DiO', 'DiL')

required
name str

I/O channel name or number within the group (e.g., 'o1', '1')

required
state Union[bool, int]

Desired state (True/False or 1/0)

required

Returns:

Type Description
str

Status message indicating success or failure

Raises:

Type Description
RSIVariableError

If the specified I/O group or channel doesn't exist

RSISafetyViolation

If safety checks prevent the operation

Example

api.io.toggle('Digout', 'o1', True) # Turn on output 1 'Updated Digout.o1 to 1' api.io.toggle('DiL', '5', False) # Turn off input latch 5 'Updated DiL.5 to 0'

Note

This method goes through the full safety validation chain. I/O variables can have safety limits configured just like motion axes.

set_output

set_output(channel: int, value: bool, group: Optional[str] = None) -> str

Set digital output by channel number.

Auto-detects the write path from the loaded config (RSI supports both notations): - a per-bit group declared in RECEIVE (e.g. MyOut.o1) is written directly; - otherwise the DiO LONG word (shipped configs) gets bit channel-1 set/cleared via read-modify-write.

Parameters:

Name Type Description Default
channel int

Output channel number (1-based; bit channel-1 of DiO)

required
value bool

Desired state (True = ON, False = OFF)

required
group Optional[str]

Explicit per-bit group name (skips auto-detection)

None

Returns:

Type Description
str

Status message indicating success

Raises:

Type Description
RSIVariableError

If no writable output path exists in the config

RSISafetyViolation

If safety checks prevent the operation

Example

api.io.set_output(1, True) # Turn ON output 1 api.io.set_output(3, False) # Turn OFF output 3

Note

Digout.o* in the shipped configs is the SEND section - the robot's read-back of its own outputs - and is never writable. Outputs are commanded through the RECEIVE side (DiO word wired to MAP2DIGOUT in the RSI context).

get_input

get_input(channel: int, group: Optional[str] = None) -> bool

Read digital input by channel number.

Auto-detects the read path from the loaded config: - a per-bit group in SEND (e.g. Digin.i1, if declared) is read directly; - otherwise bit channel-1 of the DiL LONG word (shipped configs).

Parameters:

Name Type Description Default
channel int

Input channel number (1-based; bit channel-1 of DiL)

required
group Optional[str]

Explicit per-bit group name (skips auto-detection)

None

Returns:

Type Description
bool

True if input is HIGH/ON, False if LOW/OFF

Raises:

Type Description
RSIVariableError

If no input path exists in the config

Example

if api.io.get_input(1): ... print("Sensor triggered!") Sensor triggered!

Note

Inputs come from the robot, so this reads send_variables (what the robot SENDS us), updated every RSI cycle (~4ms).

read_analog

read_analog(index: int = 1) -> float

Read an analogue input ($ANIN) reported by the robot.

Needs a context wiring an ANIN object. context("max") wires ANIN1 ($ANIN[1]) to the tag AnIn1; add further ANIN objects in RSIVisual for more, each with its own Index parameter and channel.

Parameters:

Name Type Description Default
index int

which AnIn tag to read (default 1)

1

Returns:

Type Description
float

The analogue value as reported by the controller

Raises:

Type Description
RSIVariableError

if the config declares no such tag

Example

api.io.read_analog() 0.42

set_analog

set_analog(value: float, index: int = 1) -> str

Set an analogue output ($ANOUT) on the robot.

Needs a context wiring a MAP2ANOUT object. context("max") wires MAP2ANOUT1 ($ANOUT[1]) to the tag AnOut1.

Parameters:

Name Type Description Default
value float

the analogue value to write

required
index int

which AnOut tag to write (default 1)

1

Returns:

Type Description
str

Status message

Raises:

Type Description
RSIVariableError

if the config declares no such tag

Example

api.io.set_analog(0.75) 'AnOut1 set to 0.75'

pulse

pulse(channel: int, duration: float = 0.1, group: Optional[str] = None) -> str

Generate a timed pulse on the specified output channel.

Turns the output ON, waits for the specified duration, then turns it OFF. Useful for triggering pneumatic actuators, solenoids, or signaling events.

Parameters:

Name Type Description Default
channel int

Output channel number (1-based)

required
duration float

Pulse duration in seconds (default: 0.1 = 100ms)

0.1
group Optional[str]

Explicit per-bit group name (default: auto-detect, same rules as set_output)

None

Returns:

Type Description
str

Status message indicating completion

Raises:

Type Description
RSIVariableError

If the output channel doesn't exist

RSISafetyViolation

If safety checks prevent the operation

Example
100ms pulse on output 2

api.io.pulse(2) 'Pulse completed on Digout.o2 (duration: 0.1s)'

500ms pulse on output 5

api.io.pulse(5, duration=0.5) 'Pulse completed on Digout.o5 (duration: 0.5s)'

Trigger pneumatic gripper on custom channel

api.io.pulse(3, duration=0.2, group='DiO') 'Pulse completed on DiO.o3 (duration: 0.2s)'

Warning

This method blocks for the duration of the pulse. For non-blocking pulses, consider using threading or async I/O patterns.

Note

Pulse timing accuracy depends on system load and RSI cycle time. For critical timing requirements, consider hardware-timed outputs or KRL-based pulse generation.