Skip to main content

Modular Python library for controlling a UR5 robot (real/sim)

Project description

ur5lib

Modular Python library for controlling UR5 robots — supports both a real robot (via RTDE) and a built-in simulator.

Requirements

  • Python >= 3.7
  • numpy
  • ur_rtde (only required when connecting to a real robot)

Installation

Clone the repo and install in editable mode:

git clone <repo-url>
cd ur5lib
pip install -e .

Or install directly:

pip install .

For real robot support, also install the RTDE package:

pip install ur_rtde

Quick Start

Simulator mode

from ur5lib.io.simulator import UR5Sim
from ur5lib.motion.executor import MotionExecutor
from ur5lib.types.common_types import JointAngles, Pose

# Create and connect a simulated robot
robot = UR5Sim()
robot.connect_()

executor = MotionExecutor(robot)

# Move to a joint configuration (angles in radians)
target = JointAngles(joints=[0.1, -0.5, 0.3, -1.2, 1.5, 0.0])
executor.move_to_joint_position(target)

# Move to a Cartesian pose (x, y, z, rx, ry, rz)
pose = Pose(0.4, -0.2, 0.3, 0.0, 3.14, 0.0)
executor.move_to_pose(pose)

Real robot mode (RTDE)

from ur5lib.io.ur_rtde import UR5RTDE
from ur5lib.motion.executor import MotionExecutor
from ur5lib.types.common_types import JointAngles

robot = UR5RTDE(config={"robot_ip": "192.168.0.100"})
robot.connect_()

executor = MotionExecutor(robot)
target = JointAngles(joints=[0.0, -1.57, 1.57, -1.57, -1.57, 0.0])
executor.move_to_joint_position(target)

CLI

After installation, a ur5lib-cli command is available:

# Simulator — move joints to specified angles (radians)
ur5lib-cli --sim --move-joints 0.1 -0.5 0.3 -1.2 1.5 0.0

# Real robot — specify IP and target joint angles
ur5lib-cli --ip 192.168.0.100 --move-joints 0.0 -1.57 1.57 -1.57 -1.57 0.0

Key Types

Type Fields Description
JointAngles joints: List[float] Six joint angles in radians
Pose x, y, z, rx, ry, rz TCP pose in meters / axis-angle rotation

Project Structure

ur5lib/
├── core.py              # Abstract base class UR5Base
├── cli.py               # Command-line interface
├── io/
│   ├── simulator.py     # UR5Sim — software-only simulator
│   └── ur_rtde.py       # UR5RTDE — real robot via RTDE
├── motion/
│   ├── planner.py       # MotionPlanner — joint & Cartesian interpolation
│   └── executor.py      # MotionExecutor — plan + execute moves
├── types/
│   └── common_types.py  # JointAngles, Pose
├── examples/
│   └── demo_joint_motion.py
└── config/
    └── default_config.yaml

Running the Example

python examples/demo_joint_motion.py

Extending the Library

To add a new robot backend, subclass UR5Base and implement the three abstract methods:

from ur5lib.core import UR5Base

class MyRobot(UR5Base):
    def connect_rtde(self): ...
    def get_joint_angles(self): ...
    def get_current_pose(self): ...
    def run_motion(self, motion_plan): ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ur5lib-1.0.0.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ur5lib-1.0.0-py3-none-any.whl (34.8 kB view details)

Uploaded Python 3

File details

Details for the file ur5lib-1.0.0.tar.gz.

File metadata

  • Download URL: ur5lib-1.0.0.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for ur5lib-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8fd170b1e000740d24b90409d9ecc51f635114f841e07adc89d7c5b03d173a93
MD5 e3350e5637e3b172851d6c8ca68cfba3
BLAKE2b-256 386683ad7e403b37f462a74a5dfc4f49efe705fe53641c830449c22d7cec2674

See more details on using hashes here.

File details

Details for the file ur5lib-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ur5lib-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 34.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for ur5lib-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a251344a53f13b36f68abd0f3aae20702815c15acd2ba94eb24a8c3a68bb078
MD5 b7a35b36c4c36164bc9ac3ad5d9236bb
BLAKE2b-256 63b1860f0de6fa3028bb9f3338592c1e7fff3eade7bfe87cf399d97fb0be8547

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page