Skip to main content

Crate roslibrust_transforms

Crate roslibrust_transforms 

Source
Expand description

A tf2-like transform library for roslibrust.

This crate provides a TransformManager that subscribes to /tf and /tf_static topics, maintains a transform buffer using the transforms crate, and can publish transforms.

§Features

  • Generic over roslibrust backends (ros1, rosbridge, zenoh, mock)
  • Supports both ROS1 and ROS2 message formats
  • Automatic subscription to /tf and /tf_static topics
  • Ability to publish transforms via add_transform()

§ROS1 vs ROS2

The TransformManager is generic over the message type. Use the appropriate type alias for your ROS version:

  • ROS1: TransformManager::<Ros1TFMessage, _>::new(&ros, buffer_duration)
  • ROS2: TransformManager::<Ros2TFMessage, _>::new(&ros, buffer_duration)

§Example

use roslibrust_transforms::{Quaternion, Ros1TFMessage, Stamp, Timestamp, Transform, TransformManager, Vector3};
use roslibrust::traits::Ros;

// Generic over any roslibrust backend
async fn example<T: Ros>(ros: T)
{
    let manager = TransformManager::<Ros1TFMessage, _>::new(&ros, std::time::Duration::from_secs(10)).await.unwrap();

    // Look up a transform
    let transform = manager.get_transform("base_link", "camera_link", Timestamp::now()).await.unwrap();

    // Build an updated transform from its components
    let updated = Transform::new(
        transform.parent(),
        transform.child(),
        transform.translation() + Vector3::new(1.0, 0.0, 0.0),
        transform.rotation(),
        Stamp::At(Timestamp::now()),
    )
    .unwrap();

    // Update the value in the buffer, and publish it's update to other nodes
    manager.add_transform(updated).await.unwrap();
}

Modules§

messages
Message type definitions for tf2_msgs.

Structs§

Quaternion
A quaternion representing a rotation in 3D space.
Registry
A registry for managing transforms between different frames. It can traverse the parent-child tree and calculate the final transform. It will interpolate between two entries if a time is requested that lies in between.
Timestamp
Default concrete time type used by this crate.
Transform
Where a child frame sits inside its parent frame, and when that holds.
TransformManager
A manager that subscribes to /tf and /tf_static topics, maintains a transform buffer, and can publish transforms.
Vector3
A 3D vector with x, y, and z components.

Enums§

Stamp
When a transform is valid: at one instant, or for all time.
TimeError
Error type for timestamp and time-point operations.
TransformError
Error type for building, composing, interpolating, and applying transforms.
TransformManagerError
Error types for TransformManager operations.

Traits§

FromTransform
Trait for converting a transforms::Transform to a TransformStamped message.
IntoTransform
Trait for converting a TransformStamped message to a transforms::Transform.
RosTimestamp
Conversion between ROS header timestamps and transform timestamps.
TFMessageType
Trait for TFMessage types that contain a list of TransformStamped messages.
TimePoint
Trait describing time-point behavior required by the transform core.

Type Aliases§

Ros1TFMessage
ROS1 TFMessage type alias for convenience.
Ros1TransformStamped
ROS1 TransformStamped type alias for convenience.
Ros2TFMessage
ROS2 TFMessage type alias for convenience.
Ros2TransformStamped
ROS2 TransformStamped type alias for convenience.