Recipes

Complete, production-ready patterns you can copy, adapt, and ship. Unlike tutorials (which teach step-by-step), recipes are pure working programs with inline safety annotations.

Every recipe includes:

  • A complete horus.toml manifest
  • A full src/main.rs with all imports, types, nodes, and fn main()
  • Inline // SAFETY: and // IMPORTANT: comments for critical patterns
  • Expected terminal output

Available Recipes

RecipeWhat It BuildsKey Patterns
Differential Drive2-wheel robot: CmdVel to motor commandsActuator safety, shutdown, execution order
IMU Reader100Hz IMU sensor with orientation publishingSensor node, #[repr(C)], zero-copy
PID ControllerGeneric PID loop with configurable gainsControl theory, rate-based RT
LiDAR Obstacle AvoidanceReactive velocity from LaserScanSensor fusion, safety zones
Servo ControllerMulti-servo bus with safe shutdownMulti-actuator, ordered shutdown
Multi-Sensor FusionIMU + odometry state estimationMulti-topic aggregation, caching
Emergency StopE-stop monitor with safety stateSafety-critical, Miss::SafeMode
Telemetry LoggerLog topics to file via async I/Oasync_io(), non-blocking file writes
Python CV NodePython computer vision with horus.NodePython API, NumPy integration

How to Use a Recipe

horus new my-robot -r
cd my-robot

Copy the horus.toml and src/main.rs from any recipe, then:

horus run

Conventions

  • Execution order: Publishers run before subscribers (lower .order() first)
  • Safety: Every actuator node implements shutdown() that zeros outputs
  • recv() every tick: Always call .recv() on every subscriber, every tick — even if you discard the value
  • No sleep(): Never use std::thread::sleep() — use .rate() on the scheduler
  • No blocking I/O in tick(): Use .async_io() for file/network operations