# Model Reference Adaptive Control of Satellite Spin

This example shows how to control satellite spin using model reference adaptive control (MRAC) to make the unknown controlled system match an ideal reference model. The satellite system is modeled in Simulink® and the MRAC controller is implemented using the Model Reference Adaptive Control block provided by Simulink Control Design™ software.

### Satellite-Spin Control System

In the model for this example, the cylindrical body of the satellite spins around its axis of symmetry (*z* axis) with constant angular rate $\Omega $ [1]. The goal is to independently control the angular rates ${\omega}_{\mathit{x}}$ and ${\omega}_{\mathit{y}\text{\hspace{0.17em}}}$ around the $\mathit{x}$ and $\mathit{y}$ axes using torques ${\mathit{u}}_{\mathit{x}}$ and ${\mathit{u}}_{\mathit{y}}$. The equations of motion produce a second-order model with two inputs and two outputs.

$$\left[\begin{array}{c}{\dot{\omega \text{\hspace{0.17em}}}}_{\mathit{x}}\\ \dot{{\omega}_{\mathit{y}}}\end{array}\right]=\left[\begin{array}{cc}0& \mathit{a}\\ -\mathit{a}& -0.5\mathit{a}\end{array}\right]\left[\begin{array}{c}{\omega}_{\mathit{x}}\\ {\omega}_{\mathit{y}}\end{array}\right]+\left[\begin{array}{c}{\mathit{u}}_{\mathit{x}}\\ {\mathit{u}}_{\mathit{y}}\end{array}\right]$$

In this system, the controller does not observe the plant states directly. Instead, it views the states indirectly through following measurement model.

$$\left[\begin{array}{c}{\nu}_{1}\\ {\nu}_{2}\end{array}\right]=\left[\begin{array}{cc}1& \mathit{a}\\ -\mathit{a}& 1\end{array}\right]\left[\begin{array}{c}{\omega}_{\mathit{x}}\\ {\omega}_{\mathit{y}}\end{array}\right]$$

For this example, assume that the actual plant model is unknown and that the MRAC controller uses the following nominal model of the plant dynamics.

$$\left[\begin{array}{c}{\dot{\omega \text{\hspace{0.17em}}}}_{\mathit{x}}\\ \dot{{\omega}_{\mathit{y}}}\end{array}\right]=\left[\begin{array}{cc}0& 0.5\mathit{a}\\ -0.5\mathit{a}& -0.5\mathit{a}\end{array}\right]\left[\begin{array}{c}{\omega}_{\mathit{x}}\\ {\omega}_{\mathit{y}}\end{array}\right]+\left[\begin{array}{c}{\mathit{u}}_{\mathit{x}}\\ {\mathit{u}}_{\mathit{y}}\end{array}\right]$$

Given this uncertain nonlinear system, your goal is to design a controller that enables the system to track the following decoupled reference model.

$$\left[\begin{array}{c}\dot{\text{\hspace{0.17em}}\mathit{x}{\text{\hspace{0.17em}}}_{\mathrm{m1}}}\\ \dot{\text{\hspace{0.17em}}\mathit{x}{\text{\hspace{0.17em}}}_{\mathrm{m2}}}\end{array}\right]=\left[\begin{array}{cc}-5& 0\\ 0& -5\end{array}\right]\left[\begin{array}{c}{\mathit{x}}_{\mathrm{m1}}\\ {\mathit{x}}_{\mathrm{m2}}\end{array}\right]+\left[\begin{array}{c}{\mathit{r}}_{1}\\ {\mathit{r}}_{2}\end{array}\right]$$

Here:

${\mathit{x}}_{\mathit{m}}$ is the reference model state vector.

$\mathit{r}\left(\mathit{t}\right)$ contains the angular rate reference signals.

### Define Nominal and Reference Models

Define the dynamic model for the satellite system. For this system, `A`

represents the true state matrix.

a = 10; % System Constant A = [0 a;-a -a/2]; % True model parameters B = eye(2); C = [1 a;-a 1]; D = zeros(2,2);

Specify a plant mismatch matrix. This matrix is subtracted from the true `A`

matrix to define the nominal plant used by the controller. The goal of the controller is to model this plant uncertainty.

`deltaA = [0 0.5*a; -0.5*a 0]; % Plant mismatch`

The reference system is the following stable second order system.

Am = [-5 0; 0 -5]; % Second-order decoupled integrator model Bm = diag([5 5]); % Nominal control effective matrix

Define the initial conditions for the satellite spin rates and reference model states.

x1_0 = 0.5; % Initial x-axis angular rate (rad/s) x2_0 = 0.5; % Initial y-axis angular rate (rad/s) xm_0 = [0;0]; % Initial conditions of the reference plant model

### Model Reference Adaptive Control Structure

The goal of the MRAC controller is to achieve asymptotic convergence of the tracking error $\mathit{e}\left(\mathit{t}\right)=\mathit{x}\left(\mathit{t}\right)-{\mathit{x}}_{\mathit{m}}\left(\mathit{t}\right)$.

$$\underset{t\to \infty}{\mathrm{lim}}(x(t)-{x}_{m}(t))\to 0$$

The MRAC controller has the following structure.

$$u(t)=-{k}_{x}x(t)+{k}_{r}r(t)-{u}_{ad}$$

Here:

$${k}_{x}$$ contains feedback control gains.

$${k}_{r}$$ contains feedforward control gains.

$${u}_{ad}$$ is an adaptive control term that cancels the model uncertainty.

The Model Reference Adaptive Control block adjusts the adaptive control term to achieve the desired reference model tracking. Optionally, you can also adapt the feedback and feedforward control gains.

For this example, the controller adapts the feedback gains and keeps the feedforward gains static.

The initial feedback gain and the static feedforward gain are computed to satisfy the following model matching condition:

$$\begin{array}{l}{A}_{m}=A-B{k}_{x}\\ {B}_{m}=B{k}_{r}\end{array}$$

Specify the computed controller gains and the feedback gain learning rate.

Kx = -place(A,B,eig(Am)); % State feedback gain for pole placement gain_kx = 1; % Feedback gain learning rate Kr = Bm; % Feedforward gain for ref model matching

### Configure Uncertainty Estimation Parameters

The MRAC controller estimates the model uncertainty online and generates an adaptive control action ${\mathit{u}}_{\mathrm{ad}}$ that cancels the uncertainty to recover the nominal system for the baseline controller. The adaptive control term models the system uncertainty using the following model.

$${u}_{ad}={w}^{T}\varphi (x)$$

Here:

$$w$$ contains the network weights that are adjusted by the controller.

$\varphi \left(\mathit{x}\right)$ is the uncertainty model feature vector.

Using the Model Reference Adaptive Control block, you can select one of the following feature vector definitions.

System states, where $\varphi \left(\mathit{x}\right)=\mathit{x}\left(\mathit{t}\right)$

Radial basis functions with Gaussian kernels

Custom features provided by an optional input port.

For this example, the controller is configured to use the system states as the disturbance model features.

Define the model estimation learning rate `gamma_w`

and tracking error weight `Q`

.

gamma_w = 100; % Learning rate Q = 10; % Tracking error weight

### Simulate Controller

Open the Simulink model of the satellite-spin control system.

```
mdl = "satellitespin";
open_system(mdl)
```

Simulate the model.

```
Tf = 35; % Duration (s)
sim(mdl);
```

View the controller performance by comparing the spin response (top plot) and spin-rate response (bottom plot) to their respective reference signals.

The MRAC controller tracks the reference signals well. The first step response has an initial transient, which reduces in size as the disturbance estimate of the controller improves.

View the uncertainty estimated by the controller and compare it to the true uncertainty.

The controller estimates an accurate y-axis uncertainty model. The uncertainty model for the x-axis has the correct sign, though the magnitude is lower than that of the true uncertainty. Both uncertainty models show significant transients in the uncertainty estimate, especially during the first step change in the reference signals.

To reduce the transients in the estimated uncertainty responses, you can reduce the value of the tracking error rate `Q`

. For example, reduce the value of `Q`

to 1 and simulate the model.

Q = 1; sim(mdl);

The model estimate responses have fewer transients. The tradeoff is that the spin and spin-rate responses have longer settling times.

### Reference

[1] Zhou, Kemin, John Comstock Doyle, and K. Glover. *Robust and Optimal Control*. Englewood Cliffs, N.J: Prentice Hall, 1996.