setra
Control blocks for mechatronics: PID, filters, motion profiles, state-space control, a Kalman filter and plant models for simulation.
The problem
Rewriting a PID or a Kalman filter in every project leads to different bugs every time. I wanted one tested core that runs the same on a computer and on a microcontroller.
How it is built
The core is Rust with no std and no dynamic memory, so the code tested on the computer is the same code that runs on the microcontroller. On top there is a Python module to simulate and plot. Time is always in seconds and every block gets its own dt: nothing depends on a clock or a platform.
What it includes
| pid | Clamped output, anti-windup integral, filtered derivative and feedforward |
|---|---|
| filter | Low-pass, biquad and slew-rate limiter |
| profile | Trapezoidal profile and jerk-limited S-curve |
| plant | DC motor with dry friction, pendulum, Furuta pendulum and Runge-Kutta 4 |
| states | Discretization, LQR, Luenberger observer |
| identification | Fitting a motor model from a test run |
| kalman | Fixed-size linear Kalman filter |
Where it stands
It works in simulation: a motor follows a trapezoidal profile under a load torque, an inverted pendulum is balanced with LQR and an observer, and a Furuta pendulum runs with the limits of a real rig. It still needs a physical build.
Technologies
- Rust
- no_std
- Python
- PID
- LQR
- Kalman filter
- Motion profiles
Gallery
Photos of this project are coming soon.
Are you interested in any of this?
Write to me and we'll talk it over.
Write to me