Table of Contents
Fetching ...

Code Generation and Conic Constraints for Model-Predictive Control on Microcontrollers with Conic-TinyMPC

Ishaan Mahajan, Khai Nguyen, Sam Schoedel, Elakhya Nedumaran, Moises Mata, Brian Plancher, Zachary Manchester

TL;DR

This work targets real-time model-predictive control on microcontrollers with conic constraints, a domain where conventional solvers struggle due to memory and compute limits. It extends TinyMPC to Conic-TinyMPC by adding SOCP support and high-level code-generation interfaces (Python, MATLAB, Julia), leveraging ADMM with cached precomputations and an infinite-horizon LQR approximation to drastically reduce online complexity and memory footprint. The approach achieves up to $142.7\times$ speedups and enables larger problems to fit on tiny MCUs, with extensive microcontroller benchmarks and hardware experiments on a Crazyflie quadrotor demonstrating predictive safety filtering, attitude-constrained regulation, and conic glide-slope tracking. The work provides open-source tooling and practical demonstrations, enabling safe, real-time embedded conic MPC for robotics and related constrained control tasks, with future directions toward nonlinear models via reachability-based disturbances.

Abstract

Model-predictive control (MPC) is a powerful framework for controlling dynamic systems under constraints, but it remains challenging to deploy on resource-constrained platforms, especially for problems involving conic constraints. To address this, we extend recent work developing fast, structure-exploiting, cached ADMM solvers for embedded applications, to provide support for second-order cones, as well as C++ code generation from Python, MATLAB, and Julia for easy deployment. Microcontroller benchmarks show that our solver provides up to a two-order-of-magnitude speedup, ranging from 10.6x to 142.7x, over state-of-the-art embedded solvers on QP and SOCP problems, and enables us to fit order-of-magnitude larger problems in memory. We validate our solver's deployed performance through simulation and hardware experiments, including conically-constrained trajectory tracking on a 27g Crazyflie quadrotor. To get started with Conic-TinyMPC, visit our documentation, examples, and the open-source codebase at https://tinympc.org.

Code Generation and Conic Constraints for Model-Predictive Control on Microcontrollers with Conic-TinyMPC

TL;DR

This work targets real-time model-predictive control on microcontrollers with conic constraints, a domain where conventional solvers struggle due to memory and compute limits. It extends TinyMPC to Conic-TinyMPC by adding SOCP support and high-level code-generation interfaces (Python, MATLAB, Julia), leveraging ADMM with cached precomputations and an infinite-horizon LQR approximation to drastically reduce online complexity and memory footprint. The approach achieves up to speedups and enables larger problems to fit on tiny MCUs, with extensive microcontroller benchmarks and hardware experiments on a Crazyflie quadrotor demonstrating predictive safety filtering, attitude-constrained regulation, and conic glide-slope tracking. The work provides open-source tooling and practical demonstrations, enabling safe, real-time embedded conic MPC for robotics and related constrained control tasks, with future directions toward nonlinear models via reachability-based disturbances.

Abstract

Model-predictive control (MPC) is a powerful framework for controlling dynamic systems under constraints, but it remains challenging to deploy on resource-constrained platforms, especially for problems involving conic constraints. To address this, we extend recent work developing fast, structure-exploiting, cached ADMM solvers for embedded applications, to provide support for second-order cones, as well as C++ code generation from Python, MATLAB, and Julia for easy deployment. Microcontroller benchmarks show that our solver provides up to a two-order-of-magnitude speedup, ranging from 10.6x to 142.7x, over state-of-the-art embedded solvers on QP and SOCP problems, and enables us to fit order-of-magnitude larger problems in memory. We validate our solver's deployed performance through simulation and hardware experiments, including conically-constrained trajectory tracking on a 27g Crazyflie quadrotor. To get started with Conic-TinyMPC, visit our documentation, examples, and the open-source codebase at https://tinympc.org.
Paper Structure (18 sections, 19 equations, 4 figures, 2 tables, 1 algorithm)

This paper contains 18 sections, 19 equations, 4 figures, 2 tables, 1 algorithm.

Figures (4)

  • Figure 1: We demonstrate our solver using a 27 gram nano quadrotor, the Crazyflie. Top: we track a descending helical reference (red) with its position subject to a 45$^{\circ}$ second-order cone glideslope. This requires the aircraft to perform a spiral landing maneuver (blue). Bottom: we design a predictive safety filter to guarantee safe maneuvers within a box-shaped space (blue) regardless of the nominal controller behavior (red).
  • Figure 2: The tree structure of the generated code. The main program is stored in tinymain.cpp.
  • Figure 3: (a) Predictive safety filtering performance comparison between Conic-TinyMPC and OSQP on an STM32F405 Feather board. Top row shows average iteration times, bottom row shows memory usage. Left column: time horizon kept constant at $N=10$ while state dimension $n$ ranged from 2 to 32 and input dimension was set to half of the state dimension. Right column: state and control input held constant at $n=10$ and $m=5$ while $N$ ranged from 4 to 100. Error bars represent maximum and minimum time taken per iteration for all MPC steps. Black dotted lines denote memory thresholds. (b) Rocket soft-landing performance comparison between Conic-TinyMPC, ECOS, and SCS using a Teensy 4.1 development board. Top plot shows memory usage, bottom plot shows average iteration times. In this SOCP-based experiment $n=6$ and $m=3$ while $N$ varied from 2 to 256. Error bars represent maximum and minimum time taken per iteration for all MPC steps performed. Black dotted lines denote memory thresholds.
  • Figure 4: Attitude/thrust vector regulating performance of different controllers on the Crazyflie. While Conic-TinyMPC was able to constrain the aircraft attitude within the bounds (dashed lines for 0.25 and 0.2 radians), Brescianini and Mellinger exhibited large attitude deviations, causing failures.