Indirect MRAC Control of Mass-Spring-Damper System
This example shows how to use an indirect model reference adaptive control (MRAC) system in Simulink® for model parameter estimation of a second-order mass-spring-damper system. The properties of the mass-spring-damper system are unknown. The indirect MRAC controller estimates the plant parameters and implements an inversion-based controller to track a reference model.
Mass-Spring-Damper Model
The mass-spring-damper system consists of two carts of mass and , connected to each other and ground through springs with stiffness coefficients and and dampers with damping coefficient .
The unknown dynamic system defining the spring-mass-damper system can be written as follows.
Here:
is the system state vector.
and are the positions of the masses.
and are the parameters of the unknown system.
Given this unknown nonlinear system, the goal is to design a controller that enables the tracking of the following reference.
Here:
contains the reference model states.
and are the parameters of the reference system.
is the reference signal provided by the user.
Reference-Tracking Controller
The indirect MRAC controller uses an estimator model to compute and , which are estimates of the unknown system parameters and , respectively.
To compute the control action , the controller uses the feedforward gain and feedback gain .
The controller gains are derived from the reference model parameters ( and ) and estimated observer parameters ( and ).
Configure Controller
Specify the true stiffness coefficients, damping coefficient, and masses for the mass-spring-damper system.
% Stiffness c0 = 1; c1 = 1; % Damping d = 1; % Mass m1 = 5; m2 = 1;
Define the actual system dynamics using these system parameters.
A = [0 1 0 0;-(c0+c1)/m1 -2*d/m1 c1/m1 d/m1; 0 0 0 1;c1/m2 d/m2 -c1/m2 -2*d/m2]
A = 4×4
0 1.0000 0 0
-0.4000 -0.4000 0.2000 0.2000
0 0 0 1.0000
1.0000 1.0000 -1.0000 -2.0000
B = [0 0;1/m1 0;0 0;0 1/m2]
B = 4×2
0 0
0.2000 0
0 0
0 1.0000
This true model is unknown to the indirect MRAC controller. Instead, the controller uses an estimator model to estimate the unknown plant dynamics. During operation, the controller can adapt the parameters of this model to improve its estimate of the unknown system parameters.
Ahat = [0 1 0 0;0 0 0 0;0 0 0 1;0 0 0 0]; Bhat = [0 0.1;0.1 0;0 0;0.1 0.1];
The goal of the controller is to track the performance of the reference model. Specify the parameters of the reference model.
Am = [0 1 0 0;-25 -10 0 0;0 0 0 1;0 0 -25 -10]; Bm = [0 0;25 0;0 0;0 25];
Specify the initial condition of the plant.
x_0 = 0;
Specify the learning rates for updating the estimator model parameters.
gamma_a = 0.1; % Ahat learning rate gamma_b = 0.1; % Bhat learning rate
Simulate Controller
Open the Simulink model.
mdl = 'mracMassSpringDamper';
open_system(mdl)
In this model:
The Actual Plant Model block implements the nominal model of the mass-spring-damper system.
The Reference block generates reference signals for both masses.
The Model Reference Adaptive Control block outputs the control action u, which it derives from the using the estimator model.
While an MRAC controller can also estimate unknown disturbances in the controlled system, for this example there are no such disturbances. Instead, the goal of the controller is simply to estimate the parameters of the unknown plant model. For an example that estimates unknown disturbances using a direct MRAC controller, see Model Reference Adaptive Control of Aircraft Undergoing Wing Rock.
Simulate the model.
Tf = 100; sim(mdl);
View the actual plant states, which are the positions of the masses, along with the corresponding reference signals. The controller is able to make the actual plant states track the reference signals.
open_system(mdl + "/p1")
open_system(mdl + "/p2")
The Model Reference Adaptive Controller block is configured to output the parameters and of the estimator model using the Ahat and Bhat output ports, respectively. Plot the parameters.
open_system(mdl + "/Ahat")
open_system(mdl + "/Bhat")
Over time the controller adapts the values of the estimator parameters. However, the estimated parameters do not converge to the true parameters due to a lack of persistency of excitation in the reference signals. Despite the fact that the model parameters do not converge, the controller still converges to the reference behavior.