{"id":19832040,"url":"https://github.com/danielmartensson/adaptive-control","last_synced_at":"2025-05-01T16:32:53.268Z","repository":{"id":120603998,"uuid":"140183172","full_name":"DanielMartensson/Adaptive-Control","owner":"DanielMartensson","description":"Adaptive control methods developed by Karl Johan Åström and Björn Wittenmark from the 70-80's for industrial use","archived":false,"fork":false,"pushed_at":"2024-01-23T09:25:33.000Z","size":9780,"stargazers_count":101,"open_issues_count":0,"forks_count":32,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-06T15:25:54.592Z","etag":null,"topics":["adaptive-control","kalmanfilter","model-reference-adaptive-control","mras","scilab","self-tuning","simulation","xcos"],"latest_commit_sha":null,"homepage":"","language":"MATLAB","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DanielMartensson.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-08T16:12:14.000Z","updated_at":"2024-12-25T08:26:28.000Z","dependencies_parsed_at":"2024-01-23T10:07:42.368Z","dependency_job_id":null,"html_url":"https://github.com/DanielMartensson/Adaptive-Control","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanielMartensson%2FAdaptive-Control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanielMartensson%2FAdaptive-Control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanielMartensson%2FAdaptive-Control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanielMartensson%2FAdaptive-Control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DanielMartensson","download_url":"https://codeload.github.com/DanielMartensson/Adaptive-Control/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251907048,"owners_count":21663207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adaptive-control","kalmanfilter","model-reference-adaptive-control","mras","scilab","self-tuning","simulation","xcos"],"created_at":"2024-11-12T11:36:06.189Z","updated_at":"2025-05-01T16:32:48.790Z","avatar_url":"https://github.com/DanielMartensson.png","language":"MATLAB","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\n\nThis is a collection of adaptive control methods from the book \"Adaptive Control\" by Karl Johan Åström and Björn Wittenmark.\nThey are the masters of the classical methods for self tuning controllers. The book is made for an industrial audience and PhD students in \ncontrol theory. Those control methods is most used for hydraulic and electrical servo systems in space engineering and flight engineering and also in advanced control engineering problems for robotics at the industry.\n\nThe book has sevral interesting control methods:\n\n\t* Linear Quadratic Regulator (LQR) - For optimal systems\n\t* Linear Quadratic Gaussian (LQG) - With kalman filtering\n\t* Linear Quadratic Estimator (LQE) - Finding the kalman gain matrix\n\t* Generalized Predictive Controller (GPC) - For future prediction\n\t* Self Tuning Regulator (STR) - For deterministic systems\n\t* Minimum Variance Controller (MVC) - For heavy stochastical systems \n\t* Model Reference Adaptive Controller (MRAC) - For smooth reference tracking\n\t* Extended Least Square (ELS) - For estimate stochastical models e.g ARMAX models\n\t* Recursive Least Square (RLS) - For estimate transfer functions\n\nThe book does not contain this, but I have by my self read lots of papes about subspace identification and constrained control. At the bottom of this page, I will present:\n\n\t* Adaptive Constrained MPC (ERAOKIDMPC) - Using Subspace identification methods\n\nThe collection is made by the open source software Scilab and Xcox 6.0.1 and the book \"Adaptive Control\"\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/Adaptive%20Control%20Book.png)\n\n# C code\nIf you want to try adaptive control with C-code. Have a look at this. It also work for embedded systems. MATLAB-files and C-code files as examples is available:\n\nhttps://github.com/DanielMartensson/CControl\n\n# Unscented Kalman Filter\n\nI very good filter for you is the Unscented Kalman Filter for nonlinear and linear systems. Easy to use and easier than regular kalman filter.\n\nhttps://github.com/DanielMartensson/Unscented-Kalman-Filter\n\n# Square Root Uncented Kalman Filter for state estimation and parameter estimation\n\nA very good algorithm located in here.\n\nhttps://github.com/DanielMartensson/MataveID\n\n# Identification library\nIf you want to identify models, then this library is for you - Mataveid. \n\nhttps://github.com/DanielMartensson/mataveid\n\n# Projects\n\nThis is a automatic brewery made of an MRAS adaptive controller. The project contains two controllers. The code is made in FLProg 8.1.0 for the school students at the Institution of Applied Hydraulics 2023. \n\nThe MRAS controller gives a very high accuracy, about +- 0.1 temperature error. \n\nThe project contains:\n\n * 1 x Arduino UNO\n * 6 x Digital inputs\n * 3 x Digital outputs\n * 1 x LCD 16x4 with I2C\n * 2 x MAX31865 PT100 transmitters\n * 3 x SSR DC/AC relay as output for the heating element \n\nThe FLProg 8.1.0 software \n\n![a](https://github.com/DanielMartensson/Adaptive-Control/blob/master/Projects/MRAS/Multi%20Controller%20MRAS/Brewery/Screendump.png?raw=true)\n\nInside of the eletronics\n\n![a](https://github.com/DanielMartensson/Adaptive-Control/blob/master/Projects/MRAS/Multi%20Controller%20MRAS/Brewery/Inside.jpg?raw=true)\n\nOutside of the box. No sensors are connected right now.\n\n![a](https://github.com/DanielMartensson/Adaptive-Control/blob/master/Projects/MRAS/Multi%20Controller%20MRAS/Brewery/Outside.jpg?raw=true)\n\n* Ärvärde = Measurement\n* Börvärde = Setpoint/Reference\n* Räknare = Counter for ON-time at the relays\n* Värde på regulator = ON-time threshold for the regulator\n* Integral summorna (4st med väldigt små värden) = Integral sums (4 pcs with very small values)\n\n![a](https://github.com/DanielMartensson/Adaptive-Control/blob/master/Projects/MRAS/Multi%20Controller%20MRAS/Brewery/Runtime.png?raw=true)\n\n# Linear Quadratic Regulator\n\nDiagram of the LQR system\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/LQR%20diagram.png)\nSimulation of the LQR system. The green signal is the input signal and the black signal is the output signal. Between 0 to 50 seconds, the estimator learn the system behaviour.\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/LQR%20Simulation.png)\nParameter estimation of the LQR system. \n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/LQR%20parameter%20estimation.png)\n\n# Linear Quadratic Gaussian\n\nDiagram of the LQG system. Here we can se that the system has a LQE - Linear Quadratic estimator and a Kalman Filter\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/LQG%20diagram.png)\nSimulation of the LQG system. Green is our input signal, black is our noisy output signal and red is our filtered output signal by using a kalman filter.\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/LQG%20Simulation.png)\n\n# Generalized Predictive Control\n\nDiagram of the GPC system\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/GPC%20diagram.png)\nSimulation of the GPC system. The green line is our reference following line and the black line is the system output.\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/GPC%20simulation.png)\nThere is the input signal. Between 0 to 30 seconds, the GPC controller learns the system behaviour.\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/GPC%20input%20signals.png)\n\n# Self Tuning Regulator - Minimum phase system\n\nDiagram of the STR system with minimum phase. Here I use Recursive Least Square and STR learning the system between 0 to 15 seconds, then tune the STR controller.\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/STR%20Minimum%20phase%20system.png)\n\n# Self Tuning Regulator - Non-Minimum phase system\n\nDiagram of the STR system with non-minimum phase. The difference between non-minimum phase and minimum phase is that non-minimum phase has zeros at the right half plane and minimum phase has zeros on the left half plane. On other words, non-minimum phase is much more difficult to handle.\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/STR%20Non-minimum%20phase%20system.png)\n\n\n# Minimum Variance Controller\n\nDiagram of the MVC system. I'm using Extended Least Square to estimate a ARMAX model, it's a transfer function with disturbance.\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/MVC%20Minimum%20phase%20system%20diagram.png)\n\nSimulation of the MVC system. Here is green the input signal and black the output signal. Between 0 to 70 seconds, the MVC self learning the disturbance. \n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/MVC%20Minimum%20phase%20system%20simulation.png)\n\nHere is the parameter estimation for the ARMAX model.\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/MVC%20Minimum%20phase%20system%20parameter%20estimation.png)\n\n# Model Reference Adaptive Controller - MIT Rule\n\nDiagram of MRAC system with uning of MIT rule\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/MIT-Rule%20diagram%20Xcos.png)\n\nSimulation of MRAC system\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/MIT-Rule%20simulation%20Xcos.png)\n\n# Model Reference Adaptive Controller - Lyapunov Rule\n\nDiagram of MRAC system with uning of Lyapunov rule\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/Lyapunov-Rule%20diagram%20Xcos.png)\n\nSimulation of MRAC system. According to me - Lyapunov is much better than MIT rule.\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/Lyapunov-Rule%20simulation%20Xcos.png)\n\n# Extended Least Square\n\nDiagram of ELS \n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/ELS%20diagram%20Xcos.png)\n\nSimulation of ELS. Here is the green signal our measured signal and the black signal is our estimated signal.\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/ELS%20simulation%20Xcos.png)\n\nParameter estimation\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/ELS%20parameter%20estimation.png)\n\n# Recursive Least Square \n\nDiagram of RLS\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/RLS%20diagram.png)\n\nSimulation of RLS\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/RLS%20simulation.png)\n\nParameter estimation of RLS\n![](https://github.com/DanielMartensson/Classical-Adaptive-Control-/blob/master/Pictures/RLS%20parameter%20estimation.png)\n\n# Adaptive Constrained MPC \nThis simulation uses Eigensystem Realization Algorithm and Observer Kalmanfilter Identifcation to estimate a state space model by using the subspace identification technique. Minimal data is used. The code is available inside the Octave folder.\n\nSecond order system:\n\n![](https://github.com/DanielMartensson/Adaptive-Control/blob/master/Pictures/Adaptive%20Constrained%20MPC.png?raw=true)\n\nFirst order system (no change in the parameters for MPC):\n\n![](https://github.com/DanielMartensson/Adaptive-Control/blob/master/Pictures/Adaptive%20MPC%20-%20First%20order.png?raw=true)\n\nSecond order with heavy time varying damping. It still tune in and follow the reference:\n\n![](https://github.com/DanielMartensson/Adaptive-Control/blob/master/Pictures/Changing%20MPC%20model.png?raw=true)\n\nSecond order with heavy time varying inertia. \n\n![](https://github.com/DanielMartensson/Adaptive-Control/blob/master/Pictures/Varying%20inertia%20MPC.png?raw=true)\n\nThe weakness of this MPC controller have is when it becomes radical changes for the static gain, like a mechanical spring changes its stiffness or a large watertank got extra or less isolation to prevent/increase e.g temperature leaks, or a capacitor changes its capacity. But if the mass of the spring changes, or the density of the water changes or the viscosity of the water changes or the electronic circuit changes its resistance or the coil got changes for the inductance, the adaptive  MPC controller will handle it.  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielmartensson%2Fadaptive-control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielmartensson%2Fadaptive-control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielmartensson%2Fadaptive-control/lists"}