Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction

ros-z is a native Rust ROS 2 implementation powered by Zenoh, delivering high-performance robotics communication with type safety and zero-cost abstractions. Build reliable robot applications using modern Rust idioms while maintaining full ROS 2 compatibility.

Architecture

ros-z provides three integration paths to suit different use cases:

Why Choose ros-z?

FeatureDescriptionBenefit
Native RustPure Rust implementation with no C/C++ dependenciesMemory safety, concurrency without data races
Zenoh TransportHigh-performance pub-sub engineLow latency, efficient bandwidth usage
ROS 2 CompatibleWorks seamlessly with standard ROS 2 toolsIntegrate with existing robotics ecosystems
Multiple SerializationsSupport for various data representations: CDR (ROS default), ProtobufFlexible message encoding for different performance and interoperability needs
Type SafetyCompile-time message validationCatch errors before deployment
Modern APIIdiomatic Rust patternsErgonomic developer experience
Safety FirstOwnership model prevents common bugsNo data races, null pointers, or buffer overflows at compile time
High ProductivityCargo ecosystem with excellent toolingFast development without sacrificing reliability

Note

ros-z is designed for both new projects and gradual migration. Deploy ros-z nodes alongside existing ROS 2 C++/Python nodes with full interoperability.

Communication Patterns

ros-z supports all essential ROS 2 communication patterns:

PatternUse CaseLearn More
Pub/SubContinuous data streaming, sensor data, status updatesPub/Sub
ServicesRequest-response operations, remote procedure callsServices
ActionsLong-running tasks with feedback and cancellation supportActions

Tip

Start with pub/sub for data streaming, use services for request-response operations, and leverage actions for long-running tasks that need progress feedback.

Ergonomic API Design

ros-z provides flexible, idiomatic Rust APIs that adapt to your preferred programming style:

Flexible Builder Pattern:

let pub = node.create_pub::<Vector3>("vector")
    // Quality of Service settings
    .with_qos(QosProfile {
        reliability: QosReliability::Reliable,
        ..Default::default()
    })
    // custom serialization
    .with_serdes::<ProtobufSerdes<Vector3>>()
    .build()?;

Async & Sync Patterns:

// Publishers: sync and async variants
zpub.publish(&msg)?;
zpub.async_publish(&msg).await?;

// Subscribers: sync and async receiving
let msg = zsub.recv()?;
let msg = zsub.async_recv().await?;

Callback or Polling Style for Subscribers:

// Callback style - process messages with a closure
let sub = node.create_sub::<RosString>("topic")
    .build_with_callback(|msg| {
        println!("Received: {}", msg);
    })?;

// Polling style - receive messages on demand
let sub = node.create_sub::<RosString>("topic").build()?;
while let Ok(msg) = sub.recv() {
    println!("Received: {}", msg);
}

Next Step

Ready to build safer, faster robotics applications? Start with the Quick Start Guide.