Recipes

Copy-paste-ready patterns for common robotics tasks. Each recipe is a complete, self-contained program you can 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
  • Full source code with all imports and entry point
  • Inline // SAFETY: / # SAFETY: and // IMPORTANT: / # IMPORTANT: comments for critical patterns
  • Expected terminal output

Start Here

RecipeWhat It BuildsKey Patterns
Real HardwareI2C IMU + serial motors with real crates.io/pip librariesComplete hardware path, no stubs

Rust 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
Transform FramesCoordinate frame tree with sensor mountsTransformFrame, static/dynamic frames, FrameId caching
Record & ReplayRecord execution, replay, mixed replay for regression.with_recording(), replay_from(), add_replay(), CLI

Python Recipes

RecipeWhat It BuildsKey Patterns
Differential Drive (Python)2-wheel robot with kinematics + odometryCmdVel, RPM clamping, safe shutdown
IMU Reader (Python)100Hz IMU sensor with orientationhorus.Imu, typed topics, NaN validation
PID Controller (Python)Generic PID with anti-winduphorus.dt(), integral clamping, gain tuning
LiDAR Avoidance (Python)Reactive velocity from LaserScanThree-zone split, safety stop, CmdVel
Servo Controller (Python)Multi-servo bus with safe shutdownServoCommand, JointState, joint limits
Multi-Sensor Fusion (Python)IMU + odometry complementary filterNumPy, multi-topic aggregation, angle wrapping
Emergency Stop (Python)Safety monitor with fail-safeEmergencyStop, debounce, stale detection
Telemetry Logger (Python)Async CSV loggingasync def tick, aiofiles, non-blocking I/O
Coordinate Transforms (Python)Frame tree with sensor mountsTransformFrame, static/dynamic, point conversion
Python CV NodePython computer vision with horus.NodePython API, NumPy integration
Record & Replay (Python)Record execution, replay and diff via CLIrecording=True, CLI replay, export to CSV

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

See Also