-
C codegen considered unnecessary: go directly to binary, do not pass C. Compilation of Julia code for deployment in model-based engineering
Authors:
Fredrik Bagge Carlson,
Cody Tapscott,
Gabriel Baraldi,
Chris Rackauckas
Abstract:
Since time immemorial an old adage has always seemed to ring true: you cannot use a high-level productive programming language like Python or R for real-time control and embedded-systems programming, you must rewrite your program in C. We present a counterexample to this mantra by demonstrating how recent compiler developments in the Julia programming language allow users of Julia and the equation…
▽ More
Since time immemorial an old adage has always seemed to ring true: you cannot use a high-level productive programming language like Python or R for real-time control and embedded-systems programming, you must rewrite your program in C. We present a counterexample to this mantra by demonstrating how recent compiler developments in the Julia programming language allow users of Julia and the equation-based modeling language ModelingToolkit to compile and deploy binaries for real-time model-based estimation and control. Contrary to the approach taken by a majority of modeling and simulation tools, we do not generate C code, and instead demonstrate how we may use the native Julia code-generation pipeline through LLVM to compile architecture-specific binaries from high-level code. This approach avoids many of the restrictions typically placed on high-level languages to enable C-code generation. As case studies, we include a nonlinear state estimator derived from an equation-based model which is compiled into a program that performs state estimation for deployment onto a Raspberry Pi, as well as a PID controller library implemented in Julia and compiled into a shared library callable from a C program.
△ Less
Submitted 7 February, 2025; v1 submitted 3 February, 2025;
originally announced February 2025.
-
Linear ADRC is equivalent to PID with set-point weighting and measurement filter
Authors:
Fredrik Bagge Carlson
Abstract:
We show that linear Active Disturbance-Rejection Control (ADRC) tuned using the "bandwidth method" is equivalent to PI(D) control with set-point weighting and a lowpass filter on the measurement signal. We also provide simple expressions that make it possible to implement linear ADRC for first and second-order systems using commonplace two degree-of-freedom PID implementations. The expressions are…
▽ More
We show that linear Active Disturbance-Rejection Control (ADRC) tuned using the "bandwidth method" is equivalent to PI(D) control with set-point weighting and a lowpass filter on the measurement signal. We also provide simple expressions that make it possible to implement linear ADRC for first and second-order systems using commonplace two degree-of-freedom PID implementations. The expressions are equivalent to ADRC in the response from measurements, and a slight approximation in the response from references.
△ Less
Submitted 20 January, 2025;
originally announced January 2025.
-
ModelPredictiveControl.jl: advanced process control made easy in Julia
Authors:
Francis Gagnon,
Alex Thivierge,
André Desbiens,
Fredrik Bagge Carlson
Abstract:
Proprietary closed-source software is still the norm in advanced process control. Transparency and reproducibility are key aspects of scientific research. Free and open-source toolkit can contribute to the development, sharing and advancement of new and efficient control approaches, and the industrial sector will certainly benefit from them. This paper presents ModelPredictiveControl.jl, an open-s…
▽ More
Proprietary closed-source software is still the norm in advanced process control. Transparency and reproducibility are key aspects of scientific research. Free and open-source toolkit can contribute to the development, sharing and advancement of new and efficient control approaches, and the industrial sector will certainly benefit from them. This paper presents ModelPredictiveControl.jl, an open-source software package for designing model predictive controllers in the Julia programming language. It is designed to be easy to use and modular, while providing advanced features like nonlinear control and moving horizon estimation. It relies on powerful control system and mathematical optimization frameworks to simplify the construction and testing of state estimators and predictive controllers. It also integrates with the standard plotting library to quickly visualize closed-loop data. The paper presents the main functionalities and illustrates them with two case studies in simulation. The first example is a continuously stirred tank reactor described by linear dynamics. The second one implements a nonlinear, an economic, and a successive linearization model predictive controllers for an inverted pendulum. The solving times are benchmarked against equivalent implementations in MATLAB to show the efficiency of the package.
△ Less
Submitted 24 November, 2024; v1 submitted 14 November, 2024;
originally announced November 2024.
-
New Metrics Between Rational Spectra and their Connection to Optimal Transport
Authors:
Fredrik Bagge Carlson,
Mandar Chitre
Abstract:
We propose a series of metrics between pairs of signals, linear systems or rational spectra, based on optimal transport and linear-systems theory. The metrics operate on the locations of the poles of rational functions and admit very efficient computation of distances, barycenters, displacement interpolation and projections. We establish the connection to the Wasserstein distance between rational…
▽ More
We propose a series of metrics between pairs of signals, linear systems or rational spectra, based on optimal transport and linear-systems theory. The metrics operate on the locations of the poles of rational functions and admit very efficient computation of distances, barycenters, displacement interpolation and projections. We establish the connection to the Wasserstein distance between rational spectra, and demonstrate the use of the metrics in tasks such as signal classification, clustering, detection and approximation.
△ Less
Submitted 20 April, 2020;
originally announced April 2020.
-
Machine Learning and System Identification for Estimation in Physical Systems
Authors:
Fredrik Bagge Carlson
Abstract:
In this thesis, we draw inspiration from both classical system identification and modern machine learning in order to solve estimation problems for real-world, physical systems. The main approach to estimation and learning adopted is optimization based. Concepts such as regularization will be utilized for encoding of prior knowledge and basis-function expansions will be used to add nonlinear model…
▽ More
In this thesis, we draw inspiration from both classical system identification and modern machine learning in order to solve estimation problems for real-world, physical systems. The main approach to estimation and learning adopted is optimization based. Concepts such as regularization will be utilized for encoding of prior knowledge and basis-function expansions will be used to add nonlinear modeling power while keeping data requirements practical. The thesis covers a wide range of applications, many inspired by applications within robotics, but also extending outside this already wide field. Usage of the proposed methods and algorithms are in many cases illustrated in the real-world applications that motivated the research. Topics covered include dynamics modeling and estimation, model-based reinforcement learning, spectral estimation, friction modeling and state estimation and calibration in robotic machining. In the work on modeling and identification of dynamics, we develop regularization strategies that allow us to incorporate prior domain knowledge into flexible, overparameterized models. We make use of classical control theory to gain insight into training and regularization while using flexible tools from modern deep learning. A particular focus of the work is to allow use of modern methods in scenarios where gathering data is associated with a high cost. In the robotics-inspired parts of the thesis, we develop methods that are practically motivated and ensure that they are implementable also outside the research setting. We demonstrate this by performing experiments in realistic settings and providing open-source implementations of all proposed methods and algorithms.
△ Less
Submitted 5 June, 2019;
originally announced June 2019.
-
Tangent-Space Regularization for Neural-Network Models of Dynamical Systems
Authors:
Fredrik Bagge Carlson,
Rolf Johansson,
Anders Robertsson
Abstract:
This work introduces the concept of tangent space regularization for neural-network models of dynamical systems. The tangent space to the dynamics function of many physical systems of interest in control applications exhibits useful properties, e.g., smoothness, motivating regularization of the model Jacobian along system trajectories using assumptions on the tangent space of the dynamics. Without…
▽ More
This work introduces the concept of tangent space regularization for neural-network models of dynamical systems. The tangent space to the dynamics function of many physical systems of interest in control applications exhibits useful properties, e.g., smoothness, motivating regularization of the model Jacobian along system trajectories using assumptions on the tangent space of the dynamics. Without assumptions, large amounts of training data are required for a neural network to learn the full non-linear dynamics without overfitting. We compare different network architectures on one-step prediction and simulation performance and investigate the propensity of different architectures to learn models with correct input-output Jacobian. Furthermore, the influence of $L_2$ weight regularization on the learned Jacobian eigenvalue spectrum, and hence system stability, is investigated.
△ Less
Submitted 26 June, 2018;
originally announced June 2018.
-
Identification of LTV Dynamical Models with Smooth or Discontinuous Time Evolution by means of Convex Optimization
Authors:
Fredrik Bagge Carlson,
Anders Robertsson,
Rolf Johansson
Abstract:
We establish a connection between trend filtering and system identification which results in a family of new identification methods for linear, time-varying (LTV) dynamical models based on convex optimization. We demonstrate how the design of the cost function promotes a model with either a continuous change in dynamics over time, or causes discontinuous changes in model coefficients occurring at…
▽ More
We establish a connection between trend filtering and system identification which results in a family of new identification methods for linear, time-varying (LTV) dynamical models based on convex optimization. We demonstrate how the design of the cost function promotes a model with either a continuous change in dynamics over time, or causes discontinuous changes in model coefficients occurring at a finite (sparse) set of time instances. We further discuss the introduction of priors on the model parameters for situations where excitation is insufficient for identification. The identification problems are cast as convex optimization problems and are applicable to, e.g., ARX models and state-space models with time-varying parameters. We illustrate usage of the methods in simulations of jump-linear systems, a nonlinear robot arm with non-smooth friction and stiff contacts as well as in model-based, trajectory centric reinforcement learning on a smooth nonlinear system.
△ Less
Submitted 27 February, 2018;
originally announced February 2018.