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 ROS 2 wire compatibility for pub/sub, services, and actions.
Architecture
ros-z provides three integration paths to suit different use cases:
Why Choose ros-z?
| Feature | Description | Benefit |
|---|---|---|
| Native Rust | Pure Rust implementation with no C/C++ dependencies | Memory safety, concurrency without data races |
| Zenoh Transport | High-performance pub-sub engine | Low latency, efficient bandwidth usage |
| ROS 2 Compatible | Works seamlessly with standard ROS 2 tools | Integrate with existing robotics ecosystems |
| Flexible Key Expression Formats | Compatible with rmw_zenoh_cpp and zenoh-bridge-ros2dds | Interoperate with different Zenoh-ROS bridges |
| Multiple Serializations | Support for various data representations: CDR (ROS default), Protobuf | Flexible message encoding for different performance and interoperability needs |
| Type Safety | Compile-time message validation | Catch errors before deployment |
| Modern API | Idiomatic Rust patterns | Ergonomic developer experience |
| Safety First | Ownership model prevents common bugs | No data races, null pointers, or buffer overflows at compile time |
| High Productivity | Cargo ecosystem with excellent tooling | Fast development without sacrificing reliability |
ros-z is designed for both new projects and gradual migration. Deploy ros-z nodes alongside existing ROS 2 C++/Python nodes using rmw_zenoh_cpp or zenoh-bridge-ros2dds for interoperability.
Communication Patterns
ros-z supports all essential ROS 2 communication patterns:
| Pattern | Use Case | Learn More |
|---|---|---|
| Pub/Sub | Continuous data streaming, sensor data, status updates | Pub/Sub |
| Services | Request-response operations, remote procedure calls | Services |
| Actions | Long-running tasks with feedback and cancellation support | Actions |
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);
}
Current Scope
ros-z covers the core ROS 2 communication primitives. The following are not yet supported:
| Feature | Status | Alternative |
|---|---|---|
| Parameter server | Not implemented | Use environment variables or custom config |
| Lifecycle nodes | Not implemented | Manage node state in application code |
| tf2 | Not implemented | Publish transforms directly on topics |
| Simulation time | Not implemented | Use wall clock |
| rosbag2 recording | Not implemented | Record via native Zenoh tools or ros2 bag on the ROS 2 side |
| wait_for_service / wait_for_action | Not implemented | Poll manually with a retry loop |
| Component nodes | Not implemented | Run as separate executables |
ros-z is experimental and actively developed. Contributions and feature requests are welcome on GitHub.
Next Step
Ready to build safer, faster robotics applications? Start with the Quick Start Guide.