Python API

EN KO

There are two user-facing ways to use this repository from Python.

Simple wrapper: UR_RTDE

The small wrapper class is designed to be easy to read and easy to copy into application code.

Core class: URRobot

URRobot exposes the lower-level interface used internally by the web interface. Use it when you want a slightly more explicit API.

Typical construction:

from backend.ur_robot import URRobot

robot = URRobot(
    host="192.168.163.128",
    frequency_hz=125.0,
    fields=["timestamp", "actual_q", "actual_TCP_pose"],
)

Async example

Reading values

Both APIs let you read the latest cached value by name:

print(robot["actual_q"])
print(robot["actual_TCP_pose"])

Writing GP inputs

Write only to input_*_register_* fields:

robot["input_int_register_24"] = 33
robot["input_double_register_24"] = 12.5
robot["input_bit_register_64"] = True

Conversion helpers

Useful convenience helpers for display and debugging:

print(robot.q_deg())
print(robot.tcp_mm())
print(robot.tcp_mm_deg())
print(robot.tcp_rpy())
print(robot.tcp_rpy_deg())

Suggested integration pattern

For larger applications:

  • keep one robot object per robot connection,

  • choose the smallest field list that satisfies the application,

  • use the web interface for inspection,

  • use the Python API for automation and logging.