Skip to main content

Crate robot_control

Crate robot_control 

Source
Expand description

§Robot Control

A Rust library for controlling DC motor robots via PWM motor driver boards.

This crate provides a hardware-abstracted MotorDriver trait, allowing you to control robots in production (with real I2C hardware) and in tests (with a mock driver).

§Features

  • pca9685 — Enables the Pca9685MotorBoard implementation for PCA9685 PWM boards over I2C. Only available on Linux with I2C support.

§Quick Start

use robot_control::{Motor, MotorDriver, Robot, RobotConfig};
use std::sync::Arc;
use tokio::sync::Mutex;

// Use any MotorDriver implementation (mock for testing, Pca9685 for real hardware)
let driver: Arc<Mutex<dyn MotorDriver>> = todo!("create your driver");
let robot = Robot::new(driver, RobotConfig::default())?;
robot.drive(0.5, 0.5).await?;
robot.stop().await?;
robot.shutdown().await;

Re-exports§

pub use error::MotorError;
pub use error::RobotError;
pub use motor::Motor;
pub use motor::MotorDriver;
pub use robot::Robot;
pub use robot::RobotConfig;
pub use robot::RobotOutputState;
pub use robot::RobotPhase;
pub use robot::RobotStatus;

Modules§

error
Error types for the robot-control crate.
motor
Motor driver abstraction and motor definitions.
robot
High-level robot controller with smooth motor ramping.