Python Guide
Python is ideal for ML pipelines, rapid prototyping, and sensor processing with HORUS. Python nodes share the same shared memory as Rust nodes. Built-in typed messages and pool-backed types (Image, PointCloud, DepthImage) take the zero-copy path; dict topics are MessagePack-encoded and are Python-to-Python only.
Quick Start
import horus
from horus import CmdVel
def my_tick(node):
node.send("cmd_vel", CmdVel(linear=0.5, angular=0.0))
my_node = horus.Node(name="my_node", tick=my_tick, rate=50,
pubs=[CmdVel])
horus.run(my_node)
When to Use Python vs Rust
| Use Python for | Use Rust for |
|---|---|
| ML inference (PyTorch, ONNX) | Motor control loops (1kHz+) |
| Computer vision pipelines | Safety-critical nodes |
| Rapid prototyping | Low-latency sensor processing |
| Data analysis and logging | Production deployment |
| Research experiments | Hard real-time requirements |
Guide Contents
- Nodes & Topics — Creating nodes, pub/sub, mixed Rust+Python communication
- Python Bindings — Full Node, Topic, Scheduler API in Python
- Async Nodes — Async patterns for network and I/O
- ML Integration — PyTorch and ONNX inference in a node
- Custom Messages — Define your own message types
- Memory Types — Image, PointCloud, DepthImage (zero-copy)
- ML Utilities — Tensor and TensorPool, NumPy/PyTorch interop
- Examples — Working Python applications