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.tomlmanifest - Full source code with all imports and entry point
- Inline
// SAFETY:/# SAFETY:and// IMPORTANT:/# IMPORTANT:comments for critical patterns - Expected terminal output
Start Here
| Recipe | What It Builds | Key Patterns |
|---|---|---|
| Real Hardware | I2C IMU + serial motors with real crates.io/pip libraries | Complete hardware path, no stubs |
Rust Recipes
| Recipe | What It Builds | Key Patterns |
|---|---|---|
| Differential Drive | 2-wheel robot: CmdVel to motor commands | Actuator safety, shutdown, execution order |
| IMU Reader | 100Hz IMU sensor with orientation publishing | Sensor node, #[repr(C)], zero-copy |
| PID Controller | Generic PID loop with configurable gains | Control theory, rate-based RT |
| LiDAR Obstacle Avoidance | Reactive velocity from LaserScan | Sensor fusion, safety zones |
| Servo Controller | Multi-servo bus with safe shutdown | Multi-actuator, ordered shutdown |
| Multi-Sensor Fusion | IMU + odometry state estimation | Multi-topic aggregation, caching |
| Emergency Stop | E-stop monitor with safety state | Safety-critical, Miss::SafeMode |
| Telemetry Logger | Log topics to file via async I/O | async_io(), non-blocking file writes |
| Transform Frames | Coordinate frame tree with sensor mounts | TransformFrame, static/dynamic frames, FrameId caching |
| Record & Replay | Record execution, replay, mixed replay for regression | .with_recording(), replay_from(), add_replay(), CLI |
Python Recipes
| Recipe | What It Builds | Key Patterns |
|---|---|---|
| Differential Drive (Python) | 2-wheel robot with kinematics + odometry | CmdVel, RPM clamping, safe shutdown |
| IMU Reader (Python) | 100Hz IMU sensor with orientation | horus.Imu, typed topics, NaN validation |
| PID Controller (Python) | Generic PID with anti-windup | horus.dt(), integral clamping, gain tuning |
| LiDAR Avoidance (Python) | Reactive velocity from LaserScan | Three-zone split, safety stop, CmdVel |
| Servo Controller (Python) | Multi-servo bus with safe shutdown | ServoCommand, JointState, joint limits |
| Multi-Sensor Fusion (Python) | IMU + odometry complementary filter | NumPy, multi-topic aggregation, angle wrapping |
| Emergency Stop (Python) | Safety monitor with fail-safe | EmergencyStop, debounce, stale detection |
| Telemetry Logger (Python) | Async CSV logging | async def tick, aiofiles, non-blocking I/O |
| Coordinate Transforms (Python) | Frame tree with sensor mounts | TransformFrame, static/dynamic, point conversion |
| Python CV Node | Python computer vision with horus.Node | Python API, NumPy integration |
| Record & Replay (Python) | Record execution, replay and diff via CLI | recording=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
- Tutorials — Step-by-step learning path
- Getting Started — First application