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 forUse Rust for
ML inference (PyTorch, ONNX)Motor control loops (1kHz+)
Computer vision pipelinesSafety-critical nodes
Rapid prototypingLow-latency sensor processing
Data analysis and loggingProduction deployment
Research experimentsHard real-time requirements

Guide Contents

  1. Nodes & Topics — Creating nodes, pub/sub, mixed Rust+Python communication
  2. Python Bindings — Full Node, Topic, Scheduler API in Python
  3. Async Nodes — Async patterns for network and I/O
  4. ML Integration — PyTorch and ONNX inference in a node
  5. Custom Messages — Define your own message types
  6. Memory Types — Image, PointCloud, DepthImage (zero-copy)
  7. ML Utilities — Tensor and TensorPool, NumPy/PyTorch interop
  8. Examples — Working Python applications