agentic-robotics-core
Core pub/sub messaging and serialization for Agentic Robotics
Part of the Agentic Robotics framework - high-performance robotics middleware with ROS2 compatibility.
Features
- ๐ Sub-microsecond pub/sub: 540ns serialization, 30ns channel messaging
- ๐ก Multiple middleware backends: Zenoh and DDS/RTPS support
- ๐ Zero-copy serialization: Direct CDR encoding to network buffers
- ๐ Type-safe messaging: Rust's type system ensures correctness
- ๐ ROS2 compatible: CDR serialization, DDS protocol support
- โก Lock-free channels: Wait-free fast path for local pub/sub
Installation
Add to your Cargo.toml:
[]
= "0.1.0"
= { = "1", = ["full"] }
Quick Start
Basic Publisher/Subscriber
use ;
use ;
async
Custom Message Types
use ;
use Node;
async
Performance
Real measurements from production hardware:
| Operation | Latency | Throughput |
|---|---|---|
| Serialization (CDR) | 540 ns | 1.85 M ops/sec |
| Channel send+recv | 30 ns | 33 M msgs/sec |
| Pub/sub (local) | < 1 ยตs | > 1 M msgs/sec |
Comparison with ROS2
| Metric | agentic-robotics-core | ROS2 (rclcpp) | Improvement |
|---|---|---|---|
| Serialization | 540 ns | 1-5 ยตs | 2-9x faster |
| Message overhead | ~4 bytes | 12-24 bytes | 3-6x smaller |
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ agentic-robotics-core โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Node (pub/sub management) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Publisher / Subscriber โ โ
โ โ โข Lock-free channels โ โ
โ โ โข Type-safe messaging โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Serialization โ โ
โ โ โข CDR (DDS-standard) โ โ
โ โ โข JSON (human-readable) โ โ
โ โ โข rkyv (zero-copy) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Middleware โ โ
โ โ โข Zenoh (default) โ โ
โ โ โข DDS/RTPS (ROS2 compat) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Serialization Formats
The crate supports multiple serialization formats:
CDR (Common Data Representation)
DDS-standard binary format, compatible with ROS2:
use ;
let data = RobotState ;
let bytes = serialize_cdr?;
let recovered: RobotState = deserialize_cdr?;
Performance: 540 ns per serialization (56-byte struct)
JSON
Human-readable format for debugging:
use ;
let data = RobotState ;
let json = serialize_json?;
println!; // {"position":[1,2,3],...}
Performance: ~1.2 ยตs per serialization (56-byte struct)
Middleware Backends
Zenoh (Default)
Modern pub/sub with automatic peer discovery:
let mut node = new?;
// Zenoh automatically discovers peers on the network
Features:
- Zero-configuration discovery
- Lower latency than traditional DDS
- Built-in reliability
DDS/RTPS (ROS2 Compatible)
Standard DDS protocol for ROS2 interoperability:
use ;
let mut node = with_middleware?;
// Now compatible with ROS2 nodes
Features:
- Full ROS2 compatibility
- Standard RTPS wire protocol
- Works with ros2 topic list/echo
Topics and Message Passing
Topic Naming
Follow ROS2 conventions:
node.?; // โ
Good
node.?; // โ
Good
node.?; // โ ๏ธ No leading slash
Quality of Service (QoS)
Configure reliability and durability:
use ;
let qos = QoS ;
let pub_sensor = node.?;
Error Handling
The crate uses anyhow::Result for ergonomic error handling:
use ;
Examples
See the examples directory for complete working examples:
- hello-robot: Basic pub/sub
- autonomous-navigator: A* pathfinding with obstacle avoidance
- vision-tracking: Multi-object tracking with Kalman filters
- swarm-intelligence: 15-robot swarm coordination
ROS2 Compatibility
Message Type Compatibility
Use standard ROS2 message types:
// Equivalent to std_msgs/String
pub_status.publish.await?;
// Equivalent to geometry_msgs/Pose
Topic Bridging
Bridge with ROS2 nodes:
# Terminal 1: Run your Agentic Robotics node
# Terminal 2: Echo topics from ROS2
# Terminal 3: Publish from ROS2
Performance Tuning
Buffer Pooling
Reuse buffers for zero-allocation messaging:
use BufferPool;
let pool = new; // 128 buffers of 4KB each
node.set_buffer_pool;
Batching
Batch multiple messages for higher throughput:
let mut batch = Vecnew;
for i in 0..100
pub_status.publish_batch.await?;
Testing
# Run unit tests
# Run integration tests
# Run with logging
RUST_LOG=debug
Benchmarks
Run performance benchmarks:
Expected results:
message_serialization/CDR time: [539 ns 541 ns 543 ns]
message_passing/send_recv time: [29 ns 30 ns 31 ns]
Contributing
See CONTRIBUTING.md for guidelines.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Links
- Homepage: ruv.io
- Documentation: docs.rs/agentic-robotics-core
- Repository: github.com/ruvnet/vibecast
- Performance Report: PERFORMANCE_REPORT.md
Part of the Agentic Robotics framework โข Built with โค๏ธ by the Agentic Robotics Team