Skip to content

4.5 IO Signals

Overview

The Signals module offers a unified read/write interface to the controller’s I/O, covering digital/analog inputs and outputs, multi-channel batch operations, and timed triggering.
Via signals you can query current signal states, batch-write DO/RO/GO ports, or generate pulses at specified intervals, enabling coordination with external grippers, sensors, or production-line equipment.

4.5.1 Read the Value of a Specified Type and Port IO

Method Namesignals.read( signal_type : SignalType, index : int) -> tuple[float, StatusCodeEnum]
DescriptionRead the value of an IO of a specified type and port (supports DI/DO/UI/UO/RI/RO/GI/GO/TAI/TDI/TDO/AI/AO).
Request Parameterssignal_type : SignalType The type of IO to read.
index : int The index of the IO to read, starting from 1.
Return Valuefloat: IO value. DI/DO/RI/RO/TAI/TDI/TDO/AI/AO return 0 or 1, and GI/GO return integer values (negative for Off).
StatusCodeEnum: Result of the function execution.
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+
NoteUI/UO can only be read, not written.

4.5.2 Write the Value of a Specified Type and Port IO

Method Namesignals.write( signal_type : SignalType, index : int, value : float) -> StatusCodeEnum
DescriptionWrite the value of an IO of a specified type and port. Currently only DO/RO/GO/TDO/AO are supported.
Request Parameterssignal_type : SignalType The type of IO to write.
index : int The index of the IO to write, starting from 1.
value : float DO/RO/TDO accept 0 or 1, GO expects an integer value, and AO accepts floating-point analog values.
Return ValueStatusCodeEnum: Result of the function execution.
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+

Example Code

signals/signals.py
py
#!python
"""
Copyright © 2016 Agilebot Robotics Ltd. All rights reserved.
Instruction: 单信号IO读写示例 / Example of single-signal I/O reading and writing
"""

from Agilebot import Arm, SignalType, SignalValue, StatusCodeEnum

# [ZH] 初始化捷勃特机器人
# [EN] Initialize the robot
arm = Arm()
# [ZH] 连接捷勃特机器人
# [EN] Connect to the robot
ret = arm.connect("10.27.1.254")
if ret == StatusCodeEnum.OK:
    print("机器人连接成功 / Robot connected successfully")
else:
    print(f"机器人连接失败,错误代码 / Robot connection failed, error code: {ret.errmsg}")
    arm.disconnect()
    exit(1)

# [ZH] 读取IO
# [EN] Read IO
do_value, ret = arm.signals.read(SignalType.DO, 1)
if ret == StatusCodeEnum.OK:
    print("读取IO成功 / Read IO successfully")
    print(f"DO 1 状态 / DO 1 status:{do_value}")
else:
    print(f"读取IO失败,错误代码 / Read IO failed, error code: {ret.errmsg}")
    arm.disconnect()
    exit(1)

# [ZH] 写入IO
# [EN] Write IO
ret = arm.signals.write(SignalType.DO, 1, SignalValue.ON)
if ret == StatusCodeEnum.OK:
    print("写入IO成功 / Write IO successfully")
else:
    print(f"写入IO失败,错误代码 / Write IO failed, error code: {ret.errmsg}")
    arm.disconnect()
    exit(1)

# [ZH] 断开捷勃特机器人连接
# [EN] Disconnect from the robot
arm.disconnect()
print("机器人断开连接成功 / Robot disconnected successfully")

4.5.3 Batch-read DO (Digital Output) Port Values

Method Namesignals.multi_read( signal_type : SignalType, io_list : list) -> tuple[list, StatusCodeEnum]
DescriptionBatch-read DO (digital output) port values.
Request Parameterssignal_type : SignalType The IO type to read; currently only DO is supported.
io_list : list of port numbers to read and must not be empty.
Return Valuelist: Controller response in the form [port1, state1, port2, state2, ...]
StatusCodeEnum: Result of the function execution.
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+
NoteUI/UO can only be read, not written.

4.5.4 Batch-write DO (Digital Output) Signals

Method Namesignals.multi_write( signal_type : SignalType, io_list : list) -> StatusCodeEnum
DescriptionBatch-write DO (digital output) signals.
Request Parameterssignal_type : SignalType The IO type to write; currently only DO is supported.
io_list : list of port numbers and values in the form [port1, state1, port2, state2]; the list length must be even and greater than zero.
Return ValueStatusCodeEnum: Result of the function execution.
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+

Example Code

signals/multi_read_write.py
py
#!python
"""
Copyright © 2016 Agilebot Robotics Ltd. All rights reserved.
Instruction: 多信号IO读写示例 / Example of multi-signal I/O reading and writing
"""

from Agilebot import Arm, SignalType, SignalValue, StatusCodeEnum

# [ZH] 初始化捷勃特机器人
# [EN] Initialize the robot
arm = Arm()
# [ZH] 连接捷勃特机器人
# [EN] Connect to the robot
ret = arm.connect("10.27.1.254")
if ret == StatusCodeEnum.OK:
    print("机器人连接成功 / Robot connected successfully")
else:
    print(f"机器人连接失败,错误代码 / Robot connection failed, error code: {ret.errmsg}")
    arm.disconnect()
    exit(1)

# [ZH] 读取IO
# [EN] Read IO
do_value, ret = arm.signals.multi_read(SignalType.DO, [1, 2])
if ret == StatusCodeEnum.OK:
    print("读取IO成功 / Read IO successfully")
    print(f"DO 1 状态 / DO 1 status:{do_value}")
else:
    print(f"读取IO失败,错误代码 / Read IO failed, error code: {ret.errmsg}")
    arm.disconnect()
    exit(1)

# [ZH] 写入IO
# [EN] Write IO
ret = arm.signals.multi_write(SignalType.DO, [1, SignalValue.ON, 2, SignalValue.ON])
if ret == StatusCodeEnum.OK:
    print("写入IO成功 / Write IO successfully")
else:
    print(f"写入IO失败,错误代码 / Write IO failed, error code: {ret.errmsg}")
    arm.disconnect()
    exit(1)

# [ZH] 断开捷勃特机器人连接
# [EN] Disconnect from the robot
arm.disconnect()
print("机器人断开连接成功 / Robot disconnected successfully")

4.5.5 Trigger IO Channels with Time Intervals

Method Namesignals.trigger_io_with_intervals( in_port : int = -1, intervals : list, out_ports : list, pulse_duration : int) -> StatusCodeEnum
DescriptionTrigger multiple output ports according to a set of time intervals, optionally waiting for a rising edge on a DI port before starting.
Request Parametersin_port : int Input port number, default -1 (no input trigger).
intervals : list Time intervals in milliseconds, counted after the input trigger.
out_ports : list Output port numbers to toggle.
pulse_duration : int Pulse duration in milliseconds.
Return ValueStatusCodeEnum: Result of the function execution.
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+