yourdfpy
yourdfpy is a Python library designed for simpler and easier loading, manipulation, saving, and visualization of URDF (Universal Robot Description Format) files. It is currently at version 0.0.60 and is actively maintained with frequent micro-releases addressing bug fixes and minor improvements.
Warnings
- gotcha The interactive visualization (`.show()`) relies on `pyglet`, which may require specific OpenGL drivers or X server configurations, especially in headless environments or on certain operating systems (e.g., WSL, virtual machines).
- gotcha When loading URDF files with relative paths to meshes or other assets, `yourdfpy` expects the assets to be resolvable relative to the URDF file's location or through a configured filename handler. Incorrect paths are a common source of 'mesh not found' errors.
- gotcha The library is still in its `0.0.x` version series, indicating it's pre-1.0. While API stability is generally good, minor updates (`0.0.x` to `0.0.y`) could still introduce subtle behavior changes or require small adjustments, particularly concerning numerical precision or input data types.
- gotcha Passing joint configurations for `update_cfg` can be sensitive to the dictionary keys. It expects string keys that exactly match the joint names defined in the URDF. Mismatches will lead to joints not updating as expected.
Install
-
pip install yourdfpy
Imports
- URDF
from yourdfpy import URDF
- urdf_to_scene
from yourdfpy.visualization import urdf_to_scene
Quickstart
from yourdfpy import URDF, primitives
# Create a simple demo URDF programmatically (e.g., a multi-link chain)
robot = primitives.create_urdf(joints=['prismatic', 'revolute', 'fixed'])
# Alternatively, load from a file (replace 'path/to/robot.urdf' with your file)
# from yourdfpy import URDF
# robot = URDF.load('path/to/robot.urdf')
# You can update joint configurations
robot.update_cfg({'prismatic_0': 0.5, 'revolute_1': 0.785}) # move prismatic joint by 0.5 and revolute by 45 degrees
# Display the robot model in an interactive viewer
robot.show()
# Access robot properties
print(f"Robot name: {robot.name}")
print(f"Number of joints: {len(robot.joint_map)}")
print(f"Current configuration: {robot.config}")