Automatically compute and apply coordinate frame transformations
Project description
frame-transforms
frame-transforms is a lightweight, thread-safe, Python-native package to simplify frame transforms in robotics. With it, you can manage and translate between coordinate frames with ease. It features:
- Automatic computation of transitive transforms.
- Registration and update of relative coordinate frames.
- An intuitive, object-oriented API.
Though in beta, the library is extensively tested.
This package was inspired by the interface of posetree and shares much of its functionality but offers a more batteries-included experience. Similarly to posetree's nomenclature, Pose is a location and orientation in space, whereas Transform is an action that describes the change in position and orientation to get from one Pose to another.
Installation
pip install frame-transforms
Application
Consider a simple robot consisting of a mobile base and a camera mounted on a gimbal.
The camera detects an object in its coordinate frame. Where is it in world frame?
# Setup
registry.update(Frame.WORLD, Frame.BASE, base_transform)
registry.update(Frame.BASE, Frame.CAMERA, camera_transform)
# Define the Pose
object_pose = Pose(
Transform(
np.array([1, 0, 0]),
Rotation.from_euler("xyz", [0, 0, 0], degrees=True),
),
parent_frame=Frame.CAMERA,
registry=registry,
)
# Get the position and orientation of the object in world frame
position_in_world = object_pose.get_position(Frame.WORLD)
orientation_in_world = object_pose.get_orientation(Frame.WORLD)
ROS Integration
Simply wrap the Register in a ROS node, subscribing to pose updates and publishing/service-calling the poses. The Register is thread-safe, so callbacks are simple.
Alternatives
tf2: Heavyweight, requires ROS.posetree: RequiresPoseTreesubclass implementation.
Examples
Development Setup
- Clone and
cdinto this repository. - Set up virtual environment.
python -m venv venvsource venv/bin/activate(Linux/Mac) orvenv\Scripts\activate(Windows)
- Install package with dev and test dependencies
pip install -e '.[dev,test]'
Implementation Details
- Transforms are stored as a tree starting from the world frame (provided at
Registryinitialization). - To optimize run-time performance, the paths between all pairs of frames are eagerly precomputed and stored when a frame is added.
- Therefore, the runtime complexity on request is proportional to the shortest path, instead of all frames in the case of a full graph search.
- Transitive transforms themselves are only computed on-demand because an intermediate transform can change.
- This is preferred because poses often change more often than they are requested.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file frame_transforms-0.3.1.tar.gz.
File metadata
- Download URL: frame_transforms-0.3.1.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c8952c8bb95e109aa0eb0449a57bff7074cfd1fb200983c3125123685865941
|
|
| MD5 |
eac7762a15751f771e580ecdb8e45bcd
|
|
| BLAKE2b-256 |
570e26f01ace1c79183085664775507345671eaa739df233f4a21e0bf35efa1c
|
Provenance
The following attestation bundles were made for frame_transforms-0.3.1.tar.gz:
Publisher:
publish-to-pypi.yml on MinhxNguyen7/FrameTransforms
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
frame_transforms-0.3.1.tar.gz -
Subject digest:
9c8952c8bb95e109aa0eb0449a57bff7074cfd1fb200983c3125123685865941 - Sigstore transparency entry: 424634343
- Sigstore integration time:
-
Permalink:
MinhxNguyen7/FrameTransforms@2f6dcb7c8e37728a09434ed476cd0d4eb61dc531 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MinhxNguyen7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@2f6dcb7c8e37728a09434ed476cd0d4eb61dc531 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file frame_transforms-0.3.1-py3-none-any.whl.
File metadata
- Download URL: frame_transforms-0.3.1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2e95ffb8500422d9f277bffc5fd1b6ea6d49aa63b8f5f5c38d4fd7f363917ca
|
|
| MD5 |
beb034650f1cd95a304d0a943a10edae
|
|
| BLAKE2b-256 |
feead0a08b78102cfb0f055cdcfab1b234ee6774bd7783a49715d2ddfc093321
|
Provenance
The following attestation bundles were made for frame_transforms-0.3.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on MinhxNguyen7/FrameTransforms
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
frame_transforms-0.3.1-py3-none-any.whl -
Subject digest:
c2e95ffb8500422d9f277bffc5fd1b6ea6d49aa63b8f5f5c38d4fd7f363917ca - Sigstore transparency entry: 424634355
- Sigstore integration time:
-
Permalink:
MinhxNguyen7/FrameTransforms@2f6dcb7c8e37728a09434ed476cd0d4eb61dc531 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MinhxNguyen7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@2f6dcb7c8e37728a09434ed476cd0d4eb61dc531 -
Trigger Event:
workflow_dispatch
-
Statement type: