#transform #transformation #frame #robotics #coordinate #computer-vision #timestamp

transforms

A transform library to track reference frames and provide transforms between them

21 releases

new 0.3.3 Jan 15, 2025
0.3.2 Jan 14, 2025
0.2.2 Dec 25, 2024
0.1.13 Nov 29, 2024
0.1.5 Oct 31, 2024

#164 in Math

Download history 290/week @ 2024-10-04 8/week @ 2024-10-11 132/week @ 2024-10-25 275/week @ 2024-11-01 234/week @ 2024-11-08 248/week @ 2024-11-15 160/week @ 2024-11-22 152/week @ 2024-11-29 42/week @ 2024-12-06 241/week @ 2024-12-13 143/week @ 2024-12-20 19/week @ 2024-12-27 208/week @ 2025-01-03 235/week @ 2025-01-10

610 downloads per month

MIT license

130KB
2.5K SLoC

Transforms Library

tests Documentation Crates.io License: MIT unsafe forbidden Downloads

A blazingly fast and efficient coordinate transform library for robotics and computer vision applications.

Overview

This library provides functionality for managing coordinate transformations between different frames of reference. It supports both synchronous and asynchronous operations through feature flags, making it suitable for both real-time and event-driven applications.

For more detailed information, please refer to the documentation.

⚠️ DEPRECATED: To view the async-specific documentation, use:

cargo doc --open --features async

Features

  • Interpolation: Smooth linear interpolation between transforms at different timestamps.
  • Transform Chaining: Automatic computation of transforms between indirectly connected frames.
  • Thread-safe Operations: Safe concurrent access to the transform registry.
  • Time-based Buffer Management: Automatic cleanup of old transforms.

Usage

use std::time::Duration;
use transforms::{
    geometry::{Quaternion, Transform, Vector3},
    time::Timestamp,
    Registry,
};

let mut registry = Registry::new(Duration::from_secs(60));
let timestamp = Timestamp::now();

// Create a transform from frame "base" to frame "sensor"
let transform = Transform {
    translation: Vector3::new(1.0, 0.0, 0.0),
    rotation: Quaternion::identity(),
    timestamp,
    parent: "base".into(),
    child: "sensor".into(),
};

// Add the transform to the registry
registry.add_transform(transform).unwrap();

// Retrieve the transform
let result = registry.get_transform("base", "sensor", timestamp).unwrap();

Relationship with ROS2's tf2

This library draws inspiration from ROS2's tf2 (Transform Framework 2), a widely-used transform library in the robotics community. While this crate aims to solve the same fundamental problem of transformation tracking, it does so in its own way.

Similarities with tf2

  • Maintains relationships between coordinate frames in a tree structure.
  • Buffers transforms over time.
  • Supports transform lookups between arbitrary frames.
  • Handles interpolation between transforms.
  • Provides both synchronous and asynchronous APIs.

Key Differences

  • Is a pure Rust implementation, not a wrapper around tf2.
  • Makes no attempt to perfectly match the ROS2/tf2 API.
  • Focuses on providing an ergonomic Rust-first experience.
  • Is independent of ROS2's middleware and communication system.

Non-Goals

This library intentionally limits its scope to rigid body transformations (translation and rotation) commonly used in robotics and computer vision. The following transformations are explicitly not supported and will not be considered for future implementation:

  • Scaling transformations
  • Skew transformations
  • Perspective transformations
  • Non-rigid transformations
  • Affine transformations beyond rigid body motion
  • Converge to parity with ROS2 / tf2
  • Extrapolation

Roadmap

The current goals are twofold.

  • Make this library no_std compatible and allow the std functionality behind a feature flag.
  • Removal of async, to allow users to implement the async functionality their own way. See issue

License

This project is licensed under the MIT License - see the LICENSE file for details.

Dependencies

~1.1–8MB
~51K SLoC