stepper-motion-rs Development Guidelines
You are helping develop **stepper-motion-rs**, a Rust library for stepper motor motion control with embedded-hal 1.0 compatibility.
Project Overview
This project provides trajectory planning and motion control primitives for stepper motors in embedded systems. It follows Rust embedded best practices and maintains compatibility with embedded-hal 1.0.
Technology Stack
**Rust**: 1.70+ (MSRV for embedded-hal 1.0 compatibility)**Target**: Embedded systems (no_std compatible)**HAL**: embedded-hal 1.0Project Structure
```
src/ # Library source code
tests/ # Integration and unit tests
```
Development Workflow
Testing
Run the test suite to verify changes:
```bash
cargo test
```
Linting
Check code quality and style:
```bash
cargo clippy
```
Building
Build the library:
```bash
cargo build
cargo build --release
```
Code Style Guidelines
Rust Conventions
Follow standard Rust naming conventions (snake_case for functions/variables, PascalCase for types)Use `rustfmt` for consistent formattingPrefer explicit types in public APIsDocument all public items with doc comments (`///`)Use `#![no_std]` where appropriate for embedded compatibilityEmbedded Best Practices
Minimize heap allocationsPrefer compile-time configuration over runtimeUse const generics where applicableAvoid panics in library code; use `Result` typesConsider resource constraints (memory, CPU cycles)Motion Control Patterns
Use fixed-point arithmetic for trajectory calculations when appropriateEnsure thread-safe or interrupt-safe implementationsValidate configuration parameters at compile time when possibleProvide clear error types for configuration validationKey Features
Trajectory Configuration (Feature 001)
The library includes trajectory planning with configurable parameters:
Acceleration profilesVelocity limitsPosition targetsMotion interpolationWhen working on trajectory code:
Ensure calculations are deterministicValidate bounds and limitsTest edge cases (zero velocity, maximum acceleration, etc.)Document units clearly (steps, steps/second, steps/second²)Important Constraints
**MSRV**: Maintain compatibility with Rust 1.70+**no_std**: Library must work in no_std environments**embedded-hal**: Follow embedded-hal 1.0 traits and patterns**Safety**: Avoid unsafe code unless absolutely necessary; document justification**Performance**: Optimize for real-time execution on resource-constrained MCUsTesting Requirements
Write unit tests for all trajectory calculationsInclude integration tests for common use casesTest boundary conditions and error casesEnsure tests pass on stable and MSRVRecent Changes
**001-trajectory-config**: Added Rust 1.70+ MSRV requirement for embedded-hal 1.0 compatibilityCommon Tasks
Adding a New Motion Profile
1. Define the profile struct in `src/`
2. Implement trajectory calculation methods
3. Add validation logic
4. Write comprehensive tests
5. Document with examples
Updating Dependencies
1. Check MSRV compatibility
2. Run full test suite
3. Update CHANGELOG.md
4. Verify embedded-hal trait compatibility
Performance Optimization
1. Profile on target hardware if possible
2. Use `cargo bench` for micro-benchmarks
3. Prefer const evaluation
4. Document performance characteristics in docs
Additional Notes
This is an embedded systems project—always consider resource constraints, real-time requirements, and hardware limitations when making design decisions.