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

Sam Schoedel,Khai Nguyen,Elakhya Nedumaran,Brian Plancher,Zachary Manchester
2024-03-27
Abstract:Conic constraints appear in many important control applications like legged locomotion, robotic manipulation, and autonomous rocket landing. However, current solvers for conic optimization problems have relatively heavy computational demands in terms of both floating-point operations and memory footprint, making them impractical for use on small embedded devices. We extend TinyMPC, an open-source, high-speed solver targeting low-power embedded control applications, to handle second-order cone constraints. We also present code-generation software to enable deployment of TinyMPC on a variety of microcontrollers. We benchmark our generated code against state-of-the-art embedded QP and SOCP solvers, demonstrating a two-order-of-magnitude speed increase over ECOS while consuming less memory. Finally, we demonstrate TinyMPC's efficacy on the Crazyflie, a lightweight, resource-constrained quadrotor with fast dynamics. TinyMPC and its code-generation tools are publicly available at
Robotics,Systems and Control,Optimization and Control
What problem does this paper attempt to address?
### Problems the Paper Aims to Solve The paper aims to address the computational and memory bottlenecks encountered when executing real-time Model Predictive Control (MPC) on resource-constrained microcontrollers. Specifically, the paper focuses on how to efficiently handle optimization problems with Second-Order Cone (SOC) constraints on these microcontrollers. ### Main Problem Background 1. **Importance of Second-Order Cone Constraints**: - Second-order cone constraints appear in many important control applications, such as legged robot locomotion, robotic manipulation, and autonomous rocket landing. These constraints are often used to describe physical characteristics like friction, posture, and thrust limits. 2. **Limitations of Existing Solvers**: - Current second-order cone optimization solvers have relatively high computational demands, including floating-point operations and memory usage, making them impractical for small embedded devices. - Existing solvers typically do not support warm starts, failing to fully utilize the computational results from previous time steps, leading to poor performance. - Most solvers are not optimized for embedded systems and cannot run efficiently on resource-constrained microcontrollers. 3. **Need for TinyMPC**: - TinyMPC is an open-source high-performance solver designed for low-power embedded control applications. The paper extends TinyMPC to handle second-order cone constraints and provides code generation tools for deployment on various microcontrollers. ### Solution 1. **Extension of TinyMPC**: - The paper extends TinyMPC to handle second-order cone constraints on states and inputs, enabling real-time second-order cone model predictive control. - By precomputing and caching expensive matrix decompositions, TinyMPC reduces online computational load and improves computational speed. 2. **Code Generation Tools**: - The paper develops an open-source code generation package with interfaces for Python, MATLAB, and Julia, making it easy for users to deploy TinyMPC on various microcontrollers. 3. **Performance Validation**: - The paper demonstrates TinyMPC's performance advantages on ARM Cortex M4 and M7 microcontrollers through benchmark tests and hardware experiments, particularly in terms of memory usage and computational speed. - Experiments include multiple control tasks on the Crazyflie nano quadrotor drone, validating the effectiveness and practicality of TinyMPC. ### Main Contributions 1. **Open-Source Implementation**: - Provides an open-source implementation of TinyMPC supporting second-order cone constraints, making it the fastest low-memory embedded SOCP solver. 2. **User-Friendly Interfaces**: - Offers easy-to-use code generation and solution validation interfaces, supporting Python, MATLAB, and Julia. 3. **Experimental Validation**: - Conducts hardware experiments on multiple benchmark control problems to validate the effectiveness of TinyMPC. Through these improvements, TinyMPC can efficiently execute model predictive control with second-order cone constraints on resource-constrained microcontrollers, providing a new solution for real-time control in embedded systems.