Skip to main content

Crate mecha10_controllers

Crate mecha10_controllers 

Source
Expand description

Hardware Controller Abstractions for Mecha10

This crate provides a composable layer between hardware drivers and nodes. Controllers wrap device SDKs/libraries and provide standardized interfaces for nodes to manage hardware.

§Architecture

┌─────────────────┐
│     Node        │  (Business logic)
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│   Controller    │  (Device management + SDK abstraction)
└────────┬────────┘
         │
         ▼
  ┌──────────────┐
  │ Hardware SDK │  (realsense-rust, bno055, etc.)
  └──────────────┘

§Core Concepts

  • Controller: Base trait for all hardware controllers
  • Domain-specific traits: CameraController, ImuController, etc.
  • Health monitoring: Built-in health checks and diagnostics
  • Capability discovery: Query what a controller can do
  • Testing support: Mock implementations for easy testing

§Example

use mecha10_controllers::{Controller, CameraController};
use mecha10_controllers::camera::RealSenseController;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Initialize controller
    let config = RealSenseConfig::default();
    let mut camera = RealSenseController::init(config).await?;

    // Start acquisition
    camera.start().await?;

    // Use controller
    let frame = camera.capture_frame().await?;
    println!("Captured frame: {}x{}", frame.width, frame.height);

    // Clean shutdown
    camera.stop().await?;
    Ok(())
}

Re-exports§

pub use camera::CameraController;
pub use imu::ImuController;
pub use lidar::LidarController;
pub use motor::MotorController;
pub use l298n::L298nControllerConfig;
pub use l298n::L298nMotorController;
pub use l298n::L298nMotorPins;

Modules§

camera
Camera controller trait and types
imu
IMU controller trait and types
l298n
L298N Motor Controller
lidar
LiDAR controller trait and types
mock
Mock controller implementations for testing
motor
Motor controller trait and types

Structs§

ControllerCapabilities
Capabilities of a controller

Enums§

ControllerError
Common controller errors
ControllerHealth
Health status of a controller
ControllerState
Common controller states

Traits§

Controller
Base trait for all hardware controllers