diff --git a/figs/first_order_weight.pdf b/figs/first_order_weight.pdf new file mode 100644 index 0000000..502fd81 Binary files /dev/null and b/figs/first_order_weight.pdf differ diff --git a/figs/first_order_weight.png b/figs/first_order_weight.png new file mode 100644 index 0000000..d662c31 Binary files /dev/null and b/figs/first_order_weight.png differ diff --git a/figs/gang_of_four_feedback.pdf b/figs/gang_of_four_feedback.pdf new file mode 100644 index 0000000..c55c9ce Binary files /dev/null and b/figs/gang_of_four_feedback.pdf differ diff --git a/figs/gang_of_four_feedback.png b/figs/gang_of_four_feedback.png new file mode 100644 index 0000000..f767ce8 Binary files /dev/null and b/figs/gang_of_four_feedback.png differ diff --git a/figs/gang_of_four_feedback.svg b/figs/gang_of_four_feedback.svg new file mode 100644 index 0000000..47e5aa6 --- /dev/null +++ b/figs/gang_of_four_feedback.svg @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figs/h-infinity-spec-S.pdf b/figs/h-infinity-spec-S.pdf new file mode 100644 index 0000000..5db59be Binary files /dev/null and b/figs/h-infinity-spec-S.pdf differ diff --git a/figs/h-infinity-spec-S.png b/figs/h-infinity-spec-S.png new file mode 100644 index 0000000..e18c950 Binary files /dev/null and b/figs/h-infinity-spec-S.png differ diff --git a/figs/h-infinity-spec-S.svg b/figs/h-infinity-spec-S.svg new file mode 100644 index 0000000..3f9d32d --- /dev/null +++ b/figs/h-infinity-spec-S.svg @@ -0,0 +1,504 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figs/high_order_weight.pdf b/figs/high_order_weight.pdf new file mode 100644 index 0000000..d1df809 Binary files /dev/null and b/figs/high_order_weight.pdf differ diff --git a/figs/high_order_weight.png b/figs/high_order_weight.png new file mode 100644 index 0000000..a87558b Binary files /dev/null and b/figs/high_order_weight.png differ diff --git a/figs/loop_shaping_S_with_W.pdf b/figs/loop_shaping_S_with_W.pdf new file mode 100644 index 0000000..07039c9 Binary files /dev/null and b/figs/loop_shaping_S_with_W.pdf differ diff --git a/figs/loop_shaping_S_with_W.png b/figs/loop_shaping_S_with_W.png new file mode 100644 index 0000000..02eddc3 Binary files /dev/null and b/figs/loop_shaping_S_with_W.png differ diff --git a/figs/loop_shaping_S_with_W.svg b/figs/loop_shaping_S_with_W.svg new file mode 100644 index 0000000..bec365a --- /dev/null +++ b/figs/loop_shaping_S_with_W.svg @@ -0,0 +1,273 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figs/loop_shaping_S_without_W.pdf b/figs/loop_shaping_S_without_W.pdf new file mode 100644 index 0000000..7a735d9 Binary files /dev/null and b/figs/loop_shaping_S_without_W.pdf differ diff --git a/figs/loop_shaping_S_without_W.png b/figs/loop_shaping_S_without_W.png new file mode 100644 index 0000000..5c2371d Binary files /dev/null and b/figs/loop_shaping_S_without_W.png differ diff --git a/figs/loop_shaping_S_without_W.svg b/figs/loop_shaping_S_without_W.svg new file mode 100644 index 0000000..9adafd7 --- /dev/null +++ b/figs/loop_shaping_S_without_W.svg @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figs/open_loop_shaping_shape.pdf b/figs/open_loop_shaping_shape.pdf new file mode 100644 index 0000000..1ee3813 Binary files /dev/null and b/figs/open_loop_shaping_shape.pdf differ diff --git a/figs/open_loop_shaping_shape.png b/figs/open_loop_shaping_shape.png new file mode 100644 index 0000000..c638274 Binary files /dev/null and b/figs/open_loop_shaping_shape.png differ diff --git a/figs/open_loop_shaping_shape.svg b/figs/open_loop_shaping_shape.svg new file mode 100644 index 0000000..0cdbbfc --- /dev/null +++ b/figs/open_loop_shaping_shape.svg @@ -0,0 +1,314 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figs/results_sensitivity_hinf.pdf b/figs/results_sensitivity_hinf.pdf new file mode 100644 index 0000000..7a1e52d Binary files /dev/null and b/figs/results_sensitivity_hinf.pdf differ diff --git a/figs/results_sensitivity_hinf.png b/figs/results_sensitivity_hinf.png new file mode 100644 index 0000000..073bbba Binary files /dev/null and b/figs/results_sensitivity_hinf.png differ diff --git a/index.html b/index.html index 675ef0d..c78c361 100644 --- a/index.html +++ b/index.html @@ -3,9 +3,9 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + -Robust Control - \(\mathcal{H}_\infty\) Synthesis +A brief and practical introduction to \(\mathcal{H}_\infty\) Control @@ -25,54 +25,77 @@ | HOME
-

Robust Control - \(\mathcal{H}_\infty\) Synthesis

+

A brief and practical introduction to \(\mathcal{H}_\infty\) Control

Table of Contents

-
-

1 Introduction to the Control Methodology - Model Based Control

+
+

1 Introduction to the Control Methodology - Model Based Control

+

+ +

-
-

1.1 Control Methodology

+ +
+

1.1 Model Based Control - Methodology

-The typical methodology when applying Model Based Control to a plant is schematically shown in Figure 1. + +

+ +

+The typical methodology when applying Model Based Control to a plant is schematically shown in Figure 1. It consists of three steps:

    @@ -86,7 +109,7 @@ It consists of three steps:
-
+

control-procedure.png

Figure 1: Typical Methodoly for Model Based Control

@@ -98,10 +121,14 @@ In this document, we will mainly focus on steps 2 and 3.
-
-

1.2 Some Background: From Classical Control to Robust Control

+
+

1.2 Some Background: From Classical Control to Robust Control

- +

+ +

+ +
@@ -242,23 +269,27 @@ In this document, we will mainly focus on steps 2 and 3. -
-

1.3 Example System

+
+

1.3 Example System

-Let’s consider the model shown in Figure 2. + +

+ +

+Let’s consider the model shown in Figure 2. It could represent a suspension system with a payload to position or isolate using an force actuator and an inertial sensor. -The notations used are listed in Table 2. +The notations used are listed in Table 2.

-
+

mech_sys_1dof_inertial_contr.png

Figure 2: Test System consisting of a payload with a mass \(m\) on top of an active system with a stiffness \(k\), damping \(c\) and an actuator. A feedback controller \(K(s)\) is added to position / isolate the payload.

-
Table 1: Table summurazing the main differences between classical, modern and robust control
+
@@ -344,7 +375,7 @@ The notations used are listed in Table 2.
Table 2: Example system variables
-
+

Derive the following open-loop transfer functions:

@@ -375,13 +406,37 @@ You can follow this generic procedure:
+

+Hi Musa, +Thank you very much for sharing this awesome package. +For a long time, I am dreaming of being abble to export source blocks to HTML tha are surounded by <details> blocks. +

-Having obtained \(G(s)\) and \(G_d(s)\), we can transform the system shown in Figure 2 into a classical feedback form as shown in Figure 6. +For now, I am manually adding #+HTML: <details><summary>Code</summary> and #+HTML: </details> around the source blocks I want to hide… +This is a very simple solution, but not so elegent nor practical. +

+ +

+Do you have any idea if it would be easy to extend to org-mode export of source blocks to add such functionallity?

-
+

+Similarly, I would love to be able to export a <span> block with the name of the file corresponding to the source block. +For instance, if a particular source block is tangled to script.sh, it would be so nice to display the filename when exporting! +

+ +

+Thanks in advance +

+ +

+Having obtained \(G(s)\) and \(G_d(s)\), we can transform the system shown in Figure 2 into a classical feedback form as shown in Figure 6. +

+ + +

classical_feedback_test_system.png

Figure 3: Block diagram corresponding to the example system

@@ -399,7 +454,7 @@ Let’s define the system parameters on Matlab.

-And now the system dynamics \(G(s)\) and \(G_d(s)\) (their bode plots are shown in Figures 4 and 5). +And now the system dynamics \(G(s)\) and \(G_d(s)\) (their bode plots are shown in Figures 4 and 5).

4: G = 1/(m*s^2 + c*s + k); % Plant
@@ -408,14 +463,14 @@ And now the system dynamics \(G(s)\) and \(G_d(s)\) (their bode plots are shown
 
-
+

bode_plot_example_afm.png

Figure 4: Bode plot of the plant \(G(s)\)

-
+

bode_plot_example_Gd.png

Figure 5: Magnitude of the disturbance transfer function \(G_d(s)\)

@@ -424,23 +479,38 @@ And now the system dynamics \(G(s)\) and \(G_d(s)\) (their bode plots are shown
-
-

2 Classical Open Loop Shaping

+
+

2 Classical Open Loop Shaping

-
-
-

2.1 Introduction to Open Loop Shaping

-
-

-The Loop Gain \(L(s)\) usually refers to as the product of the controller and the plant (Figure 6): + +

+
+ +
+

2.1 Introduction to Loop Shaping

+
+

+ +

+ +
+

+Loop Shaping refers to a design procedure that involves explicitly shaping the magnitude of the Loop Transfer Function \(L(s)\). +

+ +
+ +
+

+The Loop Gain \(L(s)\) usually refers to as the product of the controller and the plant (“Gain around the loop”, see Figure 6):

\begin{equation} L(s) = G(s) \cdot K(s) \label{eq:loop_gain} \end{equation} -
+

open_loop_shaping.png

Figure 6: Classical Feedback Architecture

@@ -448,15 +518,8 @@ The Loop Gain \(L(s)\) usually refers to as the product of the controller
-

-Open Loop Shaping refers to a control design technique where the controller \(K(s)\) is designed such that the Open Loop Gain \(L(s)\) has desirable shape. -

- -
- -

-This synthesis method is widely used as many characteristics of the closed-loop system depend on the shape of the open loop gain \(L(s)\): +This synthesis method is widely used as many characteristics of the closed-loop system depend on the shape of the open loop gain \(L(s)\) such as:

  • Performance: \(L\) large
  • @@ -472,15 +535,26 @@ The Open Loop shape is usually done manually has the loop gain \(L(s)\) depends

    -\(K(s)\) then consists of a combination of leads, lags, notches, etc. such that \(L(s)\) has the wanted shape. +\(K(s)\) then consists of a combination of leads, lags, notches, etc. such that \(L(s)\) has the wanted shape (an example is shown in Figure 7).

    + + +
    +

    open_loop_shaping_shape.png +

    +

    Figure 7: Typical Wanted Shape for the Loop Gain \(L(s)\)

    +
-
-

2.2 Example of Open Loop Shaping

+
+

2.2 Example of Open Loop Shaping

-
+

+ +

+ +

Let’s take our example system and try to apply the Open-Loop shaping strategy to design a controller that fulfils the following specifications:

@@ -492,7 +566,7 @@ Let’s take our example system and try to apply the Open-Loop shaping strat
-
+

Using SISOTOOL, design a controller that fulfill the specifications.

@@ -509,7 +583,7 @@ In order to have the wanted Roll-off, two integrators are used, a lead is also a

-The obtained controller is shown below, and the bode plot of the Loop Gain is shown in Figure 7. +The obtained controller is shown below, and the bode plot of the Loop Gain is shown in Figure 8.

K = 14e8 * ... % Gain
@@ -520,10 +594,10 @@ The obtained controller is shown below, and the bode plot of the Loop Gain is sh
 
-
+

loop_gain_manual_afm.png

-

Figure 7: Bode Plot of the obtained Loop Gain \(L(s) = G(s) K(s)\)

+

Figure 8: Bode Plot of the obtained Loop Gain \(L(s) = G(s) K(s)\)

@@ -544,7 +618,7 @@ And we can verify that we have the wanted stability margins: -  +Requirements Manual Method @@ -568,9 +642,13 @@ And we can verify that we have the wanted stability margins:

-
-

2.3 \(\mathcal{H}_\infty\) Loop Shaping Synthesis

+
+

2.3 \(\mathcal{H}_\infty\) Loop Shaping Synthesis

+

+ +

+

The Open Loop Shaping synthesis can be performed using the \(\mathcal{H}_\infty\) Synthesis.

@@ -580,7 +658,7 @@ Even though we will not go into details, we will provide one example.

-Using Matlab, the \(\mathcal{H}_\infty\) synthesis of a controller based on the wanted open loop shape can be performed using the loopsyn command: +Using Matlab, the \(\mathcal{H}_\infty\) Loop Shaping Synthesis can be performed using the loopsyn command:

K = loopsyn(G, Gd);
@@ -595,7 +673,7 @@ where:
 
  • K is the synthesize controller
  • -
    +

    Matlab documentation of loopsyn (link).

    @@ -604,9 +682,13 @@ Matlab documentation of loopsyn ( -

    2.4 Example of the \(\mathcal{H}_\infty\) Loop Shaping Synthesis

    +
    +

    2.4 Example of the \(\mathcal{H}_\infty\) Loop Shaping Synthesis

    +

    + +

    +

    Let’s reuse the previous plant.

    @@ -628,7 +710,7 @@ Translate the specification into the wanted shape of the open loop gain.

    -The \(\mathcal{H}_\infty\) optimal open loop shaping is performed using the loopsyn command: +The \(\mathcal{H}_\infty\) optimal open loop shaping synthesis is performed using the loopsyn command:

    [K, ~, GAM] = loopsyn(G, Lw);
    @@ -636,10 +718,10 @@ The \(\mathcal{H}_\infty\) optimal open loop shaping is performed using the 
     
     

    -The Bode plot of the obtained controller is shown in Figure 8. +The Bode plot of the obtained controller is shown in Figure 9.

    -
    +

    It is always important to analyze the controller after the synthesis is performed.

    @@ -660,28 +742,28 @@ Let’s briefly analyze this controller: -
    +

    open_loop_shaping_hinf_K.png

    -

    Figure 8: Obtained controller \(K\) using the open-loop \(\mathcal{H}_\infty\) shaping

    +

    Figure 9: Obtained controller \(K\) using the open-loop \(\mathcal{H}_\infty\) shaping

    -The obtained Loop Gain is shown in Figure 9. +The obtained Loop Gain is shown in Figure 10.

    -
    +

    open_loop_shaping_hinf_L.png

    -

    Figure 9: Obtained Open Loop Gain \(L(s) = G(s) K(s)\) and comparison with the wanted Loop gain \(L_w\)

    +

    Figure 10: Obtained Open Loop Gain \(L(s) = G(s) K(s)\) and comparison with the wanted Loop gain \(L_w\)

    -Let’s now compare the obtained stability margins of the \(\mathcal{H}_\infty\) controller and of the manually developed controller in Table 3. +Let’s now compare the obtained stability margins of the \(\mathcal{H}_\infty\) controller and of the manually developed controller in Table 3.

    - +
    @@ -722,14 +804,22 @@ Let’s now compare the obtained stability margins of the \(\mathcal{H}_\inf -
    -

    3 First Step in the \(\mathcal{H}_\infty\) world

    +
    +

    3 First Steps in the \(\mathcal{H}_\infty\) world

    +

    + +

    -
    -

    3.1 The \(\mathcal{H}_\infty\) Norm

    + +
    +

    3.1 The \(\mathcal{H}_\infty\) Norm

    -
    +

    + +

    + +

    The \(\mathcal{H}_\infty\) norm is defined as the peak of the maximum singular value of the frequency response

    @@ -746,9 +836,9 @@ For a SISO system \(G(s)\), it is simply the peak value of \(|G(j\omega)|\) as a
    -
    +

    -And compute its \(\mathcal{H}_\infty\) norm using the hinfnorm function: +Let’s compute the \(\mathcal{H}_\infty\) norm of our test plant \(G(s)\) using the hinfnorm function:

    hinfnorm(G)
    @@ -761,61 +851,100 @@ And compute its \(\mathcal{H}_\infty\) norm using the hinfnorm func
     
     
     

    -The magnitude \(|G(j\omega)|\) of the plant \(G(s)\) as a function of frequency is shown in Figure 10. -The maximum value of the magnitude over all frequencies does correspond to the \(\mathcal{H}_\infty\) norm of \(G(s)\) as Equation \eqref{eq:hinf_norm_siso} implies. +We can see that the \(\mathcal{H}_\infty\) norm of \(G(s)\) does corresponds to the peak value of \(|G(j\omega)|\) as a function of frequency as shown in Figure 11.

    -
    +

    hinfinity_norm_siso_bode.png

    -

    Figure 10: Example of the \(\mathcal{H}_\infty\) norm of a SISO system

    +

    Figure 11: Example of the \(\mathcal{H}_\infty\) norm of a SISO system

    -
    -

    3.2 \(\mathcal{H}_\infty\) Synthesis

    +
    +

    3.2 \(\mathcal{H}_\infty\) Synthesis

    -Optimization problem: -\(\mathcal{H}_\infty\) synthesis is a method that uses an algorithm (LMI optimization, Riccati equation) to find a controller of the same order as the system so that the \(\mathcal{H}_\infty\) norms of defined transfer functions are minimized. +

    +

    -Engineer work: +\(\mathcal{H}_\infty\) synthesis is a method that uses an algorithm (LMI optimization, Riccati equation) to find a controller that stabilize the system and that minimizes the \(\mathcal{H}_\infty\) norms of defined transfer functions. +

    + +
    + +

    +Why optimizing the \(\mathcal{H}_\infty\) norm of transfer functions is a pertinent choice will become clear when we will translate the typical control specifications into the \(\mathcal{H}_\infty\) norm of transfer functions. +

    + + +

    +Then applying the \(\mathcal{H}_\infty\) synthesis to a plant, the engineer work usually consists of the following steps

    1. Write the problem as standard \(\mathcal{H}_\infty\) problem
    2. -
    3. Translate the specifications as \(\mathcal{H}_\infty\) norms
    4. +
    5. Translate the specifications as \(\mathcal{H}_\infty\) norms of transfer functions
    6. Make the synthesis and analyze the obtain controller
    7. Reduce the order of the controller for implementation
    +

    -Many ways to use the \(\mathcal{H}_\infty\) Synthesis: +Note that there are many ways to use the \(\mathcal{H}_\infty\) Synthesis:

      -
    • Traditional \(\mathcal{H}_\infty\) Synthesis
    • -
    • Mixed Sensitivity Loop Shaping
    • -
    • Fixed-Structure \(\mathcal{H}_\infty\) Synthesis
    • +
    • Traditional \(\mathcal{H}_\infty\) Synthesis (hinfsyn doc)
    • +
    • Open Loop Shaping \(\mathcal{H}_\infty\) Synthesis (loopsyn doc)
    • +
    • Mixed Sensitivity Loop Shaping (mixsyn doc)
    • +
    • Fixed-Structure \(\mathcal{H}_\infty\) Synthesis (hinfstruct doc)
    • Signal Based \(\mathcal{H}_\infty\) Synthesis
    -
    -

    3.3 The Generalized Plant

    +
    +

    3.3 The Generalized Plant

    +

    + +

    -
    +

    +The first step when applying the \(\mathcal{H}_\infty\) synthesis is usually to write the problem as a standard \(\mathcal{H}_\infty\) problem. +This consist of deriving the Generalized Plant for the current problem. +It makes things much easier for the following steps. +

    + +

    +The generalized plant, usually noted \(P(s)\), is shown in Figure 12. +It has two inputs and two outputs (both could contains many signals). +The meaning of the inputs and outputs are summarized in Table 4. +

    + +

    +Note that this generalized plant is as its name implies, quite general. +It can indeed represent feedback as well as feedforward control architectures. +

    + +\begin{equation} + \begin{bmatrix} z \\ v \end{bmatrix} = P \begin{bmatrix} w \\ u \end{bmatrix} = \begin{bmatrix} P_{11} & P_{12} \\ P_{21} & P_{22} \end{bmatrix} \begin{bmatrix} w \\ u \end{bmatrix} +\end{equation} + + +

    general_plant.png

    +

    Figure 12: Inputs and Outputs of the generalized Plant

    -
    Table 3: Comparison of the characteristics obtained with the two methods
    +
    +
    @@ -857,94 +986,96 @@ The maximum value of the magnitude over all frequencies does correspond to the \
    Table 4: Notations for the general configuration
    -\begin{equation} - \begin{bmatrix} z \\ v \end{bmatrix} = P \begin{bmatrix} w \\ u \end{bmatrix} = \begin{bmatrix} P_{11} & P_{12} \\ P_{21} & P_{22} \end{bmatrix} \begin{bmatrix} w \\ u \end{bmatrix} -\end{equation} +
    -
    -

    3.4 From a Classical Feedback Architecture to a Generalized Plant

    +
    +

    3.4 The General Synthesis Problem Formulation

    - -
    -

    classical_feedback.png +

    +

    -

    Figure 12: Classical Feedback Architecture

    -
    - - - - --- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Table 5: Notations for the Classical Feedback Architecture
    NotationMeaning
    \(G\)Plant model
    \(K\)Controller
    \(r\)Reference inputs
    \(y\)Plant outputs
    \(u\)Control signals
    \(d\)Input Disturbance
    \(\epsilon\)Tracking Error

    -The procedure is: +Once the generalized plant is obtained, the \(\mathcal{H}_\infty\) synthesis problem can be stated as follows: +

    + +
    +
    +
    \(\mathcal{H}_\infty\) Synthesis applied on the generalized plant
    +
    +

    +Find a stabilizing controller \(K\) that, using the sensed output \(v\), generates a control signal \(u\) such that the \(\mathcal{H}_\infty\) norm of the closed-loop transfer function from \(w\) to \(z\) is minimized. +

    + +

    +After \(K\) is found, the system is robustified by adjusting the response around the unity gain frequency to increase stability margins. +

    + +
    + + +
    +

    general_control_names.png +

    +

    Figure 13: General Control Configuration

    +
    + +

    +Note that the closed-loop transfer function from \(w\) to \(z\) is: +

    +\begin{equation} + \frac{z}{w} = P_{11} + P_{12} K \big( I - P_{22} K \big)^{-1} P_{21} \triangleq F_l(P, K) +\end{equation} + +

    +Using Matlab, the \(\mathcal{H}_\infty\) Synthesis applied on a Generalized plant can be applied using the hinfsyn command (documentation): +

    +
    +
    K = hinfsyn(P, nmeas, ncont);
    +
    +
    +

    +where: +

    +
      +
    • P is the generalized plant transfer function matrix
    • +
    • nmeas is the number of sensed output (size of \(v\))
    • +
    • ncont is the number of control signals (size of \(u\))
    • +
    • K obtained controller that minimized the \(\mathcal{H}_\infty\) norm from \(w\) to \(z\)
    • +
    +
    +
    + +
    +

    3.5 From a Classical Feedback Architecture to a Generalized Plant

    +
    +

    + +

    + +

    +The procedure to convert a typical control architecture as the one shown in Figure 14 to a generalized Plant is as follows:

      -
    1. define signals of the generalized plant
    2. -
    3. Remove \(K\) and rearrange the inputs and outputs
    4. +
    5. Define signals (\(w\), \(z\), \(u\) and \(v\)) of the generalized plant
    6. +
    7. Remove \(K\) and rearrange the inputs and outputs to match the generalized configuration
    -
    +

    -Let’s find the Generalized plant of corresponding to the tracking control architecture shown in Figure 13 +Compute the Generalized plant of corresponding to the tracking control architecture shown in Figure 14

    -
    +

    classical_feedback_tracking.png

    -

    Figure 13: Classical Feedback Control Architecture (Tracking)

    +

    Figure 14: Classical Feedback Control Architecture (Tracking)

    +
    Hint

    First, define the signals of the generalized plant:

    @@ -957,14 +1088,22 @@ First, define the signals of the generalized plant:

    Then, Remove \(K\) and rearrange the inputs and outputs. -We obtain the generalized plant shown in Figure 14. +

    +
    + +
    Answer +

    +The obtained generalized plant shown in Figure 15.

    -
    +

    mixed_sensitivity_ref_tracking.png

    -

    Figure 14: Generalized plant of the Classical Feedback Control Architecture (Tracking)

    +

    Figure 15: Generalized plant of the Classical Feedback Control Architecture (Tracking)

    +
    +
    +

    @@ -974,60 +1113,54 @@ Using Matlab, the generalized plant can be defined as follows:

    P = [1 -G;
          0  1;
          1 -G]
    +P.InputName = {'w', 'u'};
    +P.OutputName = {'e', 'u', 'v'};
     
    -
    - -
    -

    3.5 The General Synthesis Problem Formulation

    -
    -
    -

    -The \(\mathcal{H}_\infty\) Synthesis objective is to find all stabilizing controllers \(K\) which minimize -

    -\begin{equation} - \| F_l(P, K) \|_\infty = \max_{\omega} \overline{\sigma} \big( F_l(P, K)(j\omega) \big) -\end{equation} - -
    - - -
    -

    general_control_names.png -

    -

    Figure 15: General Control Configuration

    -
    -
    -
    -
    - - -
    -

    4 Modern Interpretation of the Control Specifications

    +
    +

    4 Modern Interpretation of the Control Specifications

    +

    + +

    -
    -

    4.1 Introduction

    + +
    +

    4.1 Introduction

    +

    +The +

    + + +
    +

    gang_of_four_feedback.png +

    +

    Figure 16: Simple Feedback Architecture

    +
    +
      -
    • Reference tracking Overshoot, Static error, Setling time +
    • Reference tracking Overshoot, Static error, Settling time
        -
      • \(S(s) = T_{r \rightarrow \epsilon}\)
      • +
      • From \(r\) to \(\epsilon\)
    • Disturbances rejection
        +
      • From \(d\) to \(y\)
      • \(G(s) S(s) = T_{d \rightarrow \epsilon}\)
    • Measurement noise filtering
        +
      • From \(n\) to \(y\)
      • \(T(s) = T_{n \rightarrow \epsilon}\)
    • Small command amplitude
        +
      • From \(n, r, d\) to \(u\)
      • \(K(s) S(s) = T_{r \rightarrow u}\)
    • Stability @@ -1037,18 +1170,501 @@ The \(\mathcal{H}_\infty\) Synthesis objective is to find all stabilizing contro
    • Robustness to plant uncertainty (stability margins)
    • Controller implementation
    +
    +
    + +
    +

    4.2 Closed Loop Transfer Functions

    +
    +

    + +

    -** +As the performances of a controlled system depend on the closed loop transfer functions, it is very important to derive these closed-loop transfer functions as a function of the plant \(G(s)\) and controller \(K(s)\). +

    + + +
    +

    gang_of_four_feedback.png +

    +

    Figure 17: Simple Feedback Architecture

    +
    + +
    +

    +Write the output signals \([\epsilon, u, y]\) as a function of the systems \(K(s), G(s)\) and of the input signals \([r, d, n]\) as shown in Figure 16. +

    + +
    Hint +

    +Take one of the output (e.g. \(y\)), and write it as a function of the inputs \([d, r, n]\) going step by step around the loop: +

    +\begin{aligned} + y &= G u \\ + &= G (d + K \epsilon) \\ + &= G \big(d + K (r - n - y) \big) \\ + &= G d + GK r - GK n - GK y +\end{aligned} + +

    +Isolate \(y\) at the right hand side, and finally obtain: +\[ y = \frac{GK}{1+ GK} r + \frac{G}{1 + GK} d - \frac{GK}{1 + GK} n \] +

    + +

    +Do the same procedure for \(u\) and \(\epsilon\) +

    +
    + +
    Anwser +

    +The following equations should be obtained: +

    +\begin{align} + y &= \frac{GK}{1 + GK} r + \frac{G}{1 + GK} d - \frac{GK}{1 + GK} n \\ + \epsilon &= \frac{1 }{1 + GK} r - \frac{G}{1 + GK} d - \frac{G }{1 + GK} n \\ + u &= \frac{K }{1 + GK} r - \frac{1}{1 + GK} d - \frac{K }{1 + GK} n +\end{align} +
    + +
    + +

    +We can see that their are 4 different transfer functions describing the behavior of the system in Figure 16. +They are called the Gang of Four: +

    +\begin{align} + S &= \frac{1 }{1 + GK}, \quad \text{the sensitivity function} \\ + T &= \frac{GK}{1 + GK}, \quad \text{the complementary sensitivity function} \\ + GS &= \frac{G }{1 + GK}, \quad \text{the load disturbance sensitivity function} \\ + KS &= \frac{K }{1 + GK}, \quad \text{the noise sensitivity function} +\end{align} + +
    +

    +If a feedforward controller is included, a Gang of Six transfer functions can be defined. +More on that in this short video. +

    + +
    + +

    +And we have: +

    +\begin{align} + \epsilon &= S r - GS d - GS n \\ + y &= T r + GS d - T n \\ + u &= KS r - S d - KS n +\end{align} +
    +
    + +
    +

    4.3 Sensitivity Transfer Function

    +
    +

    + +

    + +
    +
    K1 = 14e8 * ... % Gain
    +     1/(s^2) * ... % Double Integrator
    +     (1 + s/(2*pi*10/sqrt(8)))/(1 + s/(2*pi*10*sqrt(8))); % Lead
    +
    +K2 = 1e8 * ... % Gain
    +     1/(s^2) * ... % Double Integrator
    +     (1 + s/(2*pi*1/sqrt(8)))/(1 + s/(2*pi*1*sqrt(8))); % Lead
    +
    +K3 = 1e8 * ... % Gain
    +     1/(s^2) * ... % Double Integrator
    +     (1 + s/(2*pi*1/sqrt(2)))/(1 + s/(2*pi*1*sqrt(2))); % Lead
    +
    +S1 = 1/(1 + K1*G);
    +S2 = 1/(1 + K2*G);
    +S3 = 1/(1 + K3*G);
    +
    +T1 = K1*G/(1 + K1*G);
    +T2 = K2*G/(1 + K2*G);
    +T3 = K3*G/(1 + K3*G);
    +
    +bodeFig({S1, S2, S3})
    +
    +
    + +
    +
    freqs = logspace(-1, 2, 1000);
    +
    +figure;
    +tiledlayout(1, 2, 'TileSpacing', 'None', 'Padding', 'None');
    +
    +ax1 = nexttile;
    +hold on;
    +plot(freqs, abs(squeeze(freqresp(S1, freqs, 'Hz'))), 'DisplayName', '$L(s)$');
    +plot(freqs, abs(squeeze(freqresp(S2, freqs, 'Hz'))), 'DisplayName', '$L_w(s)$');
    +plot(freqs, abs(squeeze(freqresp(S3, freqs, 'Hz'))), 'DisplayName', '$L_w(s) / \gamma$, $L_w(s) \cdot \gamma$');
    +hold off;
    +set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
    +xlabel('Frquency [Hz]'); ylabel('Sensitivity Magnitude');
    +hold off;
    +
    +ax2 = nexttile;
    +t = linspace(0, 1, 1000);
    +y1 = step(T1, t);
    +y2 = step(T2, t);
    +y3 = step(T3, t);
    +hold on;
    +plot(t, y1)
    +plot(t, y2)
    +plot(t, y3)
    +hold off
    +xlabel('Time [s]'); ylabel('Step Response');
    +
    +
    + + +
    +

    h-infinity-spec-S.png +

    +

    Figure 18: Typical wanted shape of the Sensitivity transfer function

    +
    +
    +
    + +
    +

    4.4 Robustness: Module Margin

    +
    +

    + +

    + +
      +
    • [ ] Definition of Module margin
    • +
    • [ ] Why it represents robustness
    • +
    • [ ] Example
    • +
    + +

    +\[ M_S < 2 \Rightarrow \text{GM} > 2 \text{ and } \text{PM} > 29^o \]

    + +
    +

    4.5 How to Shape transfer function? Using of Weighting Functions!

    +
    +

    + +

    + +

    +Let’s say we want to shape the sensitivity transfer function corresponding to the transfer function from \(r\) to \(\epsilon\) of the control architecture shown in Figure 19. +

    + + +
    +

    loop_shaping_S_without_W.png +

    +

    Figure 19: Generalized Plant

    -
    -

    5 Resources

    +

    +If the \(\mathcal{H}_\infty\) synthesis is directly applied on the generalized plant \(P(s)\) shown in Figure 19, if will minimize the \(\mathcal{H}_\infty\) norm of transfer function from \(r\) to \(\epsilon\) (the sensitivity transfer function). +

    + +

    +However, as the \(\mathcal{H}_\infty\) norm is the maximum peak value of the transfer function’s magnitude, it does not allow to shape the norm over all frequencies. +

    + + + +

    +A trick is to include a weighting function in the generalized plant as shown in Figure 20. +Applying the \(\mathcal{H}_\infty\) synthesis to the weighted generalized plant \(\tilde{P}(s)\) (Figure 20) will generate a controller \(K(s)\) that minimizes the \(\mathcal{H}_\infty\) norm between \(r\) and \(\tilde{\epsilon}\): +

    +\begin{equation} +\begin{aligned} + & \left\| \frac{\tilde{\epsilon}}{r} \right\|_\infty < \gamma (=1) \\ + \Leftrightarrow & \left\| W_s(s) S(s) \right\|_\infty < 1 \\ + \Leftrightarrow & \left| W_s(j\omega) S(j\omega) \right| < 1 \quad \forall \omega \\ + \Leftrightarrow & \left| S(j\omega) \right| < \frac{1}{\left| W_s(j\omega) \right|} \quad \forall \omega +\end{aligned}\label{eq:sensitivity_shaping} +\end{equation} + +
    +

    +As shown in Equation \eqref{eq:sensitivity_shaping}, the \(\mathcal{H}_\infty\) synthesis allows to shape the magnitude of the sensitivity transfer function. +Therefore, the choice of the weighting function \(W_s(s)\) is very important. +Its inverse magnitude will define the frequency dependent upper bound of the sensitivity transfer function magnitude. +

    + +
    + + +
    +

    loop_shaping_S_with_W.png +

    +

    Figure 20: Weighted Generalized Plant

    +
    + +

    +Once the weighting function is designed, it should be added to the generalized plant as shown in Figure 20. +

    + +

    +The weighted generalized plant can be defined in Matlab by either re-defining all the inputs or by pre-multiplying the (non-weighted) generalized plant by a block-diagonal MIMO transfer function containing the weights for the outputs \(z\) and 1 for the outputs \(v\). +

    + +
    +
    Pw = [Ws -Ws*G;
    +      1  -G]
    +
    +% Alternative
    +Pw = blkdiag(Ws, 1)*P;
    +
    +
    +
    +
    + +
    +

    4.6 Design of Weighting Functions

    +
    +

    + +

    + +

    +Weighting function used must be proper, stable and minimum phase transfer functions. +

    +
    +
    proper
    more poles than zeros, this implies \(\lim_{\omega \to \infty} |W(j\omega)| < \infty\)
    +
    stable
    no poles in the right half plane
    +
    minimum phase
    no zeros in the right half plane
    +
    + +

    +Matlab is providing the makeweight function that creates a first-order weights by specifying the low frequency gain, high frequency gain, and a gain at a specific frequency: +

    +
    +
    W = makeweight(dcgain,[freq,mag],hfgain)
    +
    +
    +

    +with: +

    +
      +
    • dcgain
    • +
    • freq
    • +
    • mag
    • +
    • hfgain
    • +
    + +
    +

    +The Matlab code below produces a weighting function with a magnitude shape shown in Figure 21. +

    + +
    +
    Ws = makeweight(1e2, [2*pi*10, 1], 1/2);
    +
    +
    + + +
    +

    first_order_weight.png +

    +

    Figure 21: Obtained Magnitude of the Weighting Function

    +
    + +
    + +
    +

    +Quite often, higher orders weights are required. +

    + +

    +In such case, the following formula can be used the design of these weights: +

    + +\begin{equation} + W(s) = \left( \frac{ + \frac{1}{\omega_0} \sqrt{\frac{1 - \left(\frac{G_0}{G_c}\right)^{\frac{2}{n}}}{1 - \left(\frac{G_c}{G_\infty}\right)^{\frac{2}{n}}}} s + \left(\frac{G_0}{G_c}\right)^{\frac{1}{n}} + }{ + \left(\frac{1}{G_\infty}\right)^{\frac{1}{n}} \frac{1}{\omega_0} \sqrt{\frac{1 - \left(\frac{G_0}{G_c}\right)^{\frac{2}{n}}}{1 - \left(\frac{G_c}{G_\infty}\right)^{\frac{2}{n}}}} s + \left(\frac{1}{G_c}\right)^{\frac{1}{n}} + }\right)^n \label{eq:weight_formula_advanced} +\end{equation} + +

    +The parameters permit to specify: +

    +
      +
    • the low frequency gain: \(G_0 = lim_{\omega \to 0} |W(j\omega)|\)
    • +
    • the high frequency gain: \(G_\infty = lim_{\omega \to \infty} |W(j\omega)|\)
    • +
    • the absolute gain at \(\omega_0\): \(G_c = |W(j\omega_0)|\)
    • +
    • the absolute slope between high and low frequency: \(n\)
    • +
    + +

    +A Matlab function implementing Equation \eqref{eq:weight_formula_advanced} is shown below: +

    + +
    +
    function [W] = generateWeight(args)
    +    arguments
    +        args.G0 (1,1) double {mustBeNumeric, mustBePositive} = 0.1
    +        args.G1 (1,1) double {mustBeNumeric, mustBePositive} = 10
    +        args.Gc (1,1) double {mustBeNumeric, mustBePositive} = 1
    +        args.wc (1,1) double {mustBeNumeric, mustBePositive} = 2*pi
    +        args.n  (1,1) double {mustBeInteger, mustBePositive} = 1
    +    end
    +
    +    if (args.Gc <= args.G0 && args.Gc <= args.G1) || (args.Gc >= args.G0 && args.Gc >= args.G1)
    +        eid = 'value:range';
    +        msg = 'Gc must be between G0 and G1';
    +        throwAsCaller(MException(eid,msg))
    +    end
    +
    +    s = zpk('s');
    +
    +    W = (((1/args.wc)*sqrt((1-(args.G0/args.Gc)^(2/args.n))/(1-(args.Gc/args.G1)^(2/args.n)))*s + (args.G0/args.Gc)^(1/args.n))/((1/args.G1)^(1/args.n)*(1/args.wc)*sqrt((1-(args.G0/args.Gc)^(2/args.n))/(1-(args.Gc/args.G1)^(2/args.n)))*s + (1/args.Gc)^(1/args.n)))^args.n;
    +
    +end
    +
    +
    + +

    +Let’s use this function to generate three weights with the same high and low frequency gains, but but different slopes. +

    + +
    +
    W1 = generateWeight('G0', 1e2, 'G1', 1/2, 'Gc', 1, 'wc', 2*pi*10, 'n', 1);
    +W2 = generateWeight('G0', 1e2, 'G1', 1/2, 'Gc', 1, 'wc', 2*pi*10, 'n', 2);
    +W3 = generateWeight('G0', 1e2, 'G1', 1/2, 'Gc', 1, 'wc', 2*pi*10, 'n', 3);
    +
    +
    + +

    +The obtained shapes are shown in Figure 22. +

    + + +
    +

    high_order_weight.png +

    +

    Figure 22: Higher order weights using Equation \eqref{eq:weight_formula_advanced}

    +
    + +
    +
    +
    + +
    +

    4.7 Sensitivity Function Shaping - Example

    +
    +

    + +

    + +
      +
    • Robustness: Module margin > 2 (\(\Rightarrow \text{GM} > 2 \text{ and } \text{PM} > 29^o\))
    • +
    • Bandwidth:
    • +
    • Slope of -2
    • +
    + +

    +First, the weighting functions is generated. +

    +
    +
    Ws = generateWeight('G0', 1e3, 'G1', 1/2, 'Gc', 1, 'wc', 2*pi*10, 'n', 2);
    +
    +
    + +

    +It is then added to the generalized plant. +

    +
    +
    Pw = blkdiag(Ws, 1)*P;
    +
    +
    + +

    +And the \(\mathcal{H}_\infty\) synthesis is performed. +

    +
    +
    K = hinfsyn(Pw, 1, 1, 'Display', 'on');
    +
    +
    + +
    +K = hinfsyn(Pw, 1, 1, 'Display', 'on');
    +
    +  Test bounds:  0.5 <=  gamma  <=  0.51
    +
    +   gamma        X>=0        Y>=0       rho(XY)<1    p/f
    +  5.05e-01     0.0e+00     0.0e+00     4.497e-28     p
    +  Limiting gains...
    +  5.05e-01     0.0e+00     0.0e+00     0.000e+00     p
    +  5.05e-01    -1.8e+01 #  -2.9e-15     1.514e-15     f
    +
    +  Best performance (actual): 0.504
    +
    + +

    +The obtained \(\gamma \approx 0.5\) means that it found a controller \(K(s)\) that stabilize the closed-loop system, and such that: +

    +\begin{aligned} + & \| W_s(s) S(s) \|_\infty < 0.5 \\ + & \Leftrightarrow |S(j\omega)| < \frac{0.5}{|W_s(j\omega)|} \quad \forall \omega +\end{aligned} + +

    +This is indeed what we can see by comparing \(|S|\) and \(|W_S|\) in Figure 23. +

    + + +
    +

    results_sensitivity_hinf.png +

    +

    Figure 23: Weighting function and obtained closed-loop sensitivity

    +
    +
    +
    +
    + +
    +

    5 \(\mathcal{H}_\infty\) Mixed-Sensitivity Synthesis

    + +

    +
    + +
    +

    5.1 Problem

    +
    + +
    +

    5.2 Typical Procedure

    +
    + +
    +

    5.3 Step 1 - Shaping of the Sensitivity Function

    +
    + +
    +

    5.4 Step 2 - Shaping of

    +
    +
    + +
    +

    6 Conclusion

    +
    + +
    +

    7 Resources

    +
    +

    @@ -1060,7 +1676,7 @@ The \(\mathcal{H}_\infty\) Synthesis objective is to find all stabilizing contro

    Author: Dehaeze Thomas

    -

    Created: 2020-11-27 ven. 23:12

    +

    Created: 2020-11-30 lun. 17:44

    diff --git a/index.org b/index.org index fe0d511..ddfecfc 100644 --- a/index.org +++ b/index.org @@ -1,4 +1,4 @@ -#+TITLE: Robust Control - $\mathcal{H}_\infty$ Synthesis +#+TITLE: A brief and practical introduction to $\mathcal{H}_\infty$ Control :DRAWER: #+STARTUP: overview @@ -31,6 +31,7 @@ #+PROPERTY: header-args:latex+ :imoutoptions -quality 100 #+PROPERTY: header-args:latex+ :results file raw replace #+PROPERTY: header-args:latex+ :buffer no +#+PROPERTY: header-args:latex+ :tangle no #+PROPERTY: header-args:latex+ :eval no-export #+PROPERTY: header-args:latex+ :exports results #+PROPERTY: header-args:latex+ :mkdirp yes @@ -48,8 +49,15 @@ <> #+end_src +#+begin_src matlab :tangle no + addpath('matlab') +#+end_src + * Introduction to the Control Methodology - Model Based Control -** Control Methodology +<> + +** Model Based Control - Methodology +<> The typical methodology when applying Model Based Control to a plant is schematically shown in Figure [[fig:control-procedure]]. It consists of three steps: @@ -94,6 +102,7 @@ It consists of three steps: In this document, we will mainly focus on steps 2 and 3. ** Some Background: From Classical Control to Robust Control +<> #+name: tab:comparison_control_methods #+caption: Table summurazing the main differences between classical, modern and robust control @@ -122,6 +131,7 @@ In this document, we will mainly focus on steps 2 and 3. | | Only SISO | Difficult Rejection of Perturbations | Need a reasonably good model of the system | ** Example System +<> Let's consider the model shown in Figure [[fig:mech_sys_1dof_inertial_contr]]. It could represent a suspension system with a payload to position or isolate using an force actuator and an inertial sensor. @@ -204,6 +214,20 @@ You can follow this generic procedure: \end{align} #+HTML: #+end_exercice +Hi Musa, +Thank you very much for sharing this awesome package. +For a long time, I am dreaming of being abble to export source blocks to HTML tha are surounded by
    blocks. + +For now, I am manually adding #+HTML:
    Code and #+HTML:
    around the source blocks I want to hide... +This is a very simple solution, but not so elegent nor practical. + +Do you have any idea if it would be easy to extend to org-mode export of source blocks to add such functionallity? + + +Similarly, I would love to be able to export a block with the name of the file corresponding to the source block. +For instance, if a particular source block is tangled to script.sh, it would be so nice to display the filename when exporting! + +Thanks in advance Having obtained $G(s)$ and $G_d(s)$, we can transform the system shown in Figure [[fig:mech_sys_1dof_inertial_contr]] into a classical feedback form as shown in Figure [[fig:open_loop_shaping]]. @@ -302,10 +326,17 @@ And now the system dynamics $G(s)$ and $G_d(s)$ (their bode plots are shown in F [[file:figs/bode_plot_example_Gd.png]] * Classical Open Loop Shaping -** Introduction to Open Loop Shaping +<> + +** Introduction to Loop Shaping +<> #+begin_definition -The *Loop Gain* $L(s)$ usually refers to as the product of the controller and the plant (Figure [[fig:open_loop_shaping]]): +*Loop Shaping* refers to a design procedure that involves explicitly shaping the magnitude of the *Loop Transfer Function* $L(s)$. +#+end_definition + +#+begin_definition +The *Loop Gain* $L(s)$ usually refers to as the product of the controller and the plant ("Gain around the loop", see Figure [[fig:open_loop_shaping]]): \begin{equation} L(s) = G(s) \cdot K(s) \label{eq:loop_gain} \end{equation} @@ -336,11 +367,7 @@ The *Loop Gain* $L(s)$ usually refers to as the product of the controller and th [[file:figs/open_loop_shaping.png]] #+end_definition -#+begin_definition -*Open Loop Shaping* refers to a control design technique where the controller $K(s)$ is designed such that the *Open Loop Gain* $L(s)$ has desirable shape. -#+end_definition - -This synthesis method is widely used as many characteristics of the closed-loop system depend on the shape of the open loop gain $L(s)$: +This synthesis method is widely used as many characteristics of the closed-loop system depend on the shape of the open loop gain $L(s)$ such as: - *Performance*: $L$ large - *Good disturbance rejection*: $L$ large - *Limitation of measurement noise on plant output*: $L$ small @@ -350,9 +377,52 @@ This synthesis method is widely used as many characteristics of the closed-loop The Open Loop shape is usually done manually has the loop gain $L(s)$ depends linearly on $K(s)$ eqref:eq:loop_gain. -$K(s)$ then consists of a combination of leads, lags, notches, etc. such that $L(s)$ has the wanted shape. +$K(s)$ then consists of a combination of leads, lags, notches, etc. such that $L(s)$ has the wanted shape (an example is shown in Figure [[fig:open_loop_shaping_shape]]). + +#+begin_src latex :file open_loop_shaping_shape.pdf + \begin{tikzpicture} + % Phase Axis + \draw[->] (-0.3, -0.5) -- ++(8, 0) node[above]{$\omega$}; \draw[<-] (0, 0) + node[left]{$\angle L(j\omega)$} -- ++(0, -2.3); + + % Gain Axis + \draw[->] (-0.3, 2) -- ++(8, 0) node[above]{$\omega$}; \draw[->] (0, 0.5) -- + ++(0, 3) node[left]{$\left|L(j\omega)\right|$}; + + % Gain Slopes + \draw[shift={(0,2)}] (0.5, 1.25) -- node[midway, above]{$-2$} (2, 0.5) -- + node[midway, above]{$-1$} (6, -0.5) -- node[midway, below left]{$-2$} (7.5, + -1.25); + + % Forbiden region + \path[shift={(0,1.8)}, fill=red!50!white] (0.5, 1.25) -- (2, 0.5) -| coordinate[near start](lfshaping) cycle; + \path[shift={(0,2.2)}, fill=red!50!white] (6, -0.5) -- (7.5, -1.25) |- coordinate[near end](hfshaping) cycle; + + \draw[<-] (lfshaping) -- ++(0, -0.8) node[below, align=center]{Reference\\Tracking}; + \draw[<-] (hfshaping) -- ++(0, 0.8) node[above, align=center]{Noise\\Rejection}; + + % Crossover frequency + \node[below] (wc) at (4,2){$\omega_c$}; + \draw[<-] (wc.south) -- ++(0, -0.4) node[below, align=center]{Bandwidth}; + + % Phase + \draw[] (0.5, -2) -- (2, -2)[out=0, in=-180] to (4, -1.25)[out=0, in=-180] to + (6, -2) -- (7.5, -2); \draw[] (0.5, -2) -- (2, -2)[out=0, in=-180] to (4, + -1.25)[out=0, in=-180] to (6, -2) -- (7.5, -2); + + % Phase Margin + \draw[->, dashed] (4, -2) -- (4, -1.25) node[above]{Phase Margin}; + \draw[dashed] (0, -2) node[left]{$-\pi$} -- (7.5, -2); + \end{tikzpicture} +#+end_src + +#+name: fig:open_loop_shaping_shape +#+caption: Typical Wanted Shape for the Loop Gain $L(s)$ +#+RESULTS: +[[file:figs/open_loop_shaping_shape.png]] ** Example of Open Loop Shaping +<> #+begin_exampl Let's take our example system and try to apply the Open-Loop shaping strategy to design a controller that fulfils the following specifications: @@ -421,23 +491,24 @@ And we can verify that we have the wanted stability margins: #+end_src #+begin_src matlab :exports results :results value table replace :tangle no :post addhdr(*this*) - data2orgtable([Gm; Pm; Wc/2/pi], {'Gain Margin $> 3$ [dB]', 'Phase Margin $> 30$ [deg]', 'Crossover $\approx 10$ [Hz]'}, {'Manual Method'}, ' %.1f '); + data2orgtable([Gm; Pm; Wc/2/pi], {'Gain Margin $> 3$ [dB]', 'Phase Margin $> 30$ [deg]', 'Crossover $\approx 10$ [Hz]'}, {'Requirements', 'Manual Method'}, ' %.1f '); #+end_src #+RESULTS: -| | Manual Method | +| Requirements | Manual Method | |-----------------------------+---------------| | Gain Margin $> 3$ [dB] | 3.1 | | Phase Margin $> 30$ [deg] | 35.4 | | Crossover $\approx 10$ [Hz] | 10.1 | ** $\mathcal{H}_\infty$ Loop Shaping Synthesis +<> The Open Loop Shaping synthesis can be performed using the $\mathcal{H}_\infty$ Synthesis. Even though we will not go into details, we will provide one example. -Using Matlab, the $\mathcal{H}_\infty$ synthesis of a controller based on the wanted open loop shape can be performed using the =loopsyn= command: +Using Matlab, the $\mathcal{H}_\infty$ Loop Shaping Synthesis can be performed using the =loopsyn= command: #+begin_src matlab :eval no K = loopsyn(G, Gd); #+end_src @@ -451,6 +522,7 @@ where: #+end_seealso ** Example of the $\mathcal{H}_\infty$ Loop Shaping Synthesis +<> Let's reuse the previous plant. @@ -465,7 +537,7 @@ Translate the specification into the wanted shape of the open loop gain. (1 + s/(2*pi*10/sqrt(3)))/(1 + s/(2*pi*10*sqrt(3))); % Lead #+end_src -The $\mathcal{H}_\infty$ optimal open loop shaping is performed using the =loopsyn= command: +The $\mathcal{H}_\infty$ optimal open loop shaping synthesis is performed using the =loopsyn= command: #+begin_src matlab [K, ~, GAM] = loopsyn(G, Lw); #+end_src @@ -575,8 +647,11 @@ Let's now compare the obtained stability margins of the $\mathcal{H}_\infty$ con | Phase Margin $> 30$ [deg] | 35.4 | 54.7 | | Crossover $\approx 10$ [Hz] | 10.1 | 9.9 | -* First Step in the $\mathcal{H}_\infty$ world +* First Steps in the $\mathcal{H}_\infty$ world +<> + ** The $\mathcal{H}_\infty$ Norm +<> #+begin_definition The $\mathcal{H}_\infty$ norm is defined as the peak of the maximum singular value of the frequency response @@ -591,7 +666,7 @@ Let's now compare the obtained stability margins of the $\mathcal{H}_\infty$ con #+end_definition #+begin_exampl -And compute its $\mathcal{H}_\infty$ norm using the =hinfnorm= function: +Let's compute the $\mathcal{H}_\infty$ norm of our test plant $G(s)$ using the =hinfnorm= function: #+begin_src matlab :results value replace hinfnorm(G) #+end_src @@ -599,8 +674,7 @@ And compute its $\mathcal{H}_\infty$ norm using the =hinfnorm= function: #+RESULTS: : 7.9216e-06 -The magnitude $|G(j\omega)|$ of the plant $G(s)$ as a function of frequency is shown in Figure [[fig:hinfinity_norm_siso_bode]]. -The maximum value of the magnitude over all frequencies does correspond to the $\mathcal{H}_\infty$ norm of $G(s)$ as Equation eqref:eq:hinf_norm_siso implies. +We can see that the $\mathcal{H}_\infty$ norm of $G(s)$ does corresponds to the peak value of $|G(j\omega)|$ as a function of frequency as shown in Figure [[fig:hinfinity_norm_siso_bode]]. #+begin_src matlab :exports none freqs = logspace(0, 3, 1000); @@ -626,23 +700,47 @@ The maximum value of the magnitude over all frequencies does correspond to the $ #+end_exampl ** $\mathcal{H}_\infty$ Synthesis +<> -*Optimization problem*: -$\mathcal{H}_\infty$ synthesis is a method that uses an *algorithm* (LMI optimization, Riccati equation) to find a controller of the same order as the system so that the $\mathcal{H}_\infty$ norms of defined transfer functions are minimized. +#+begin_definition + $\mathcal{H}_\infty$ synthesis is a method that uses an *algorithm* (LMI optimization, Riccati equation) to find a controller that stabilize the system and that *minimizes* the $\mathcal{H}_\infty$ norms of defined transfer functions. +#+end_definition -*Engineer work*: +Why optimizing the $\mathcal{H}_\infty$ norm of transfer functions is a pertinent choice will become clear when we will translate the typical control specifications into the $\mathcal{H}_\infty$ norm of transfer functions. + + +Then applying the $\mathcal{H}_\infty$ synthesis to a plant, the engineer work usually consists of the following steps 1. Write the problem as standard $\mathcal{H}_\infty$ problem -2. Translate the specifications as $\mathcal{H}_\infty$ norms +2. Translate the specifications as $\mathcal{H}_\infty$ norms of transfer functions 3. Make the synthesis and analyze the obtain controller 4. Reduce the order of the controller for implementation -*Many ways to use the $\mathcal{H}_\infty$ Synthesis*: -- Traditional $\mathcal{H}_\infty$ Synthesis -- Mixed Sensitivity Loop Shaping -- Fixed-Structure $\mathcal{H}_\infty$ Synthesis + +Note that there are many ways to use the $\mathcal{H}_\infty$ Synthesis: +- Traditional $\mathcal{H}_\infty$ Synthesis (=hinfsyn= [[https://www.mathworks.com/help/robust/ref/hinfsyn.html][doc]]) +- Open Loop Shaping $\mathcal{H}_\infty$ Synthesis (=loopsyn= [[https://www.mathworks.com/help/robust/ref/loopsyn.html][doc]]) +- Mixed Sensitivity Loop Shaping (=mixsyn= [[https://www.mathworks.com/help/robust/ref/lti.mixsyn.html][doc]]) +- Fixed-Structure $\mathcal{H}_\infty$ Synthesis (=hinfstruct= [[https://www.mathworks.com/help/robust/ref/lti.hinfstruct.html][doc]]) - Signal Based $\mathcal{H}_\infty$ Synthesis ** The Generalized Plant +<> + +The first step when applying the $\mathcal{H}_\infty$ synthesis is usually to write the problem as a standard $\mathcal{H}_\infty$ problem. +This consist of deriving the *Generalized Plant* for the current problem. +It makes things much easier for the following steps. + +The generalized plant, usually noted $P(s)$, is shown in Figure [[fig:general_plant]]. +It has two inputs and two outputs (both could contains many signals). +The meaning of the inputs and outputs are summarized in Table [[tab:notation_general]]. + +Note that this generalized plant is as its name implies, quite /general/. +It can indeed represent feedback as well as feedforward control architectures. + +\begin{equation} + \begin{bmatrix} z \\ v \end{bmatrix} = P \begin{bmatrix} w \\ u \end{bmatrix} = \begin{bmatrix} P_{11} & P_{12} \\ P_{21} & P_{22} \end{bmatrix} \begin{bmatrix} w \\ u \end{bmatrix} +\end{equation} + #+begin_src latex :file general_plant.pdf \begin{tikzpicture} \node[block={2.0cm}{2.0cm}] (P) {$P$}; @@ -663,9 +761,12 @@ $\mathcal{H}_\infty$ synthesis is a method that uses an *algorithm* (LMI optimiz \end{tikzpicture} #+end_src +#+name: fig:general_plant +#+caption: Inputs and Outputs of the generalized Plant #+RESULTS: [[file:figs/general_plant.png]] +#+begin_important #+name: tab:notation_general #+caption: Notations for the general configuration | Notation | Meaning | @@ -675,50 +776,68 @@ $\mathcal{H}_\infty$ synthesis is a method that uses an *algorithm* (LMI optimiz | $z$ | Exogenous outputs: signals to be minimized | | $v$ | Controller inputs: measurements | | $u$ | Control signals | +#+end_important -\begin{equation} - \begin{bmatrix} z \\ v \end{bmatrix} = P \begin{bmatrix} w \\ u \end{bmatrix} = \begin{bmatrix} P_{11} & P_{12} \\ P_{21} & P_{22} \end{bmatrix} \begin{bmatrix} w \\ u \end{bmatrix} -\end{equation} +** The General Synthesis Problem Formulation +<> -** From a Classical Feedback Architecture to a Generalized Plant +Once the generalized plant is obtained, the $\mathcal{H}_\infty$ synthesis problem can be stated as follows: -#+begin_src latex :file classical_feedback.pdf +#+begin_important + - $\mathcal{H}_\infty$ Synthesis applied on the generalized plant :: + Find a stabilizing controller $K$ that, using the sensed output $v$, generates a control signal $u$ such that the $\mathcal{H}_\infty$ norm of the closed-loop transfer function from $w$ to $z$ is minimized. + + After $K$ is found, the system is /robustified/ by adjusting the response around the unity gain frequency to increase stability margins. +#+end_important + +#+begin_src latex :file general_control_names.pdf \begin{tikzpicture} - \node[addb={+}{}{}{}{-}] (addfb) at (0, 0){}; - \node[block, right=0.8 of addfb] (K){$K(s)$}; - \node[addb={+}{}{}{}{}, right=0.8 of K] (addu){}; - \node[block, right=0.8 of addu] (G){$G(s)$}; - \draw[<-] (addfb.west) -- ++(-0.8, 0) node[above right]{$r$}; - \draw[->] (addfb.east) -- (K.west) node[above left]{$\epsilon$}; - \draw[->] (K.east) -- (addu.west) node[above left]{$u$}; - \draw[->] (addu.east) -- (G.west); - \draw[<-] (addu.north) -- ++(0, 0.8) node[below right]{$d$}; - \draw[->] (G.east) -- ++(1.2, 0); - \draw[->] ($(G.east) + (0.6, 0)$) node[branch]{} node[above]{$y$} -- ++(0, -0.8) -| (addfb.south); + % Blocs + \node[block={2.0cm}{2.0cm}] (P) {$P$}; + \node[block={1.5cm}{1.5cm}, below=0.7 of P] (K) {$K$}; + + % Input and outputs coordinates + \coordinate[] (inputw) at ($(P.south west)!0.75!(P.north west)$); + \coordinate[] (inputu) at ($(P.south west)!0.25!(P.north west)$); + \coordinate[] (outputz) at ($(P.south east)!0.75!(P.north east)$); + \coordinate[] (outputv) at ($(P.south east)!0.25!(P.north east)$); + + % Connections and labels + \draw[<-] (inputw) node[above left, align=right]{(weighted)\\exogenous inputs\\$w$} -- ++(-1.5, 0); + \draw[<-] (inputu) -- ++(-0.8, 0) |- node[left, near start, align=right]{control signals\\$u$} (K.west); + + \draw[->] (outputz) node[above right, align=left]{(weighted)\\exogenous outputs\\$z$} -- ++(1.5, 0); + \draw[->] (outputv) -- ++(0.8, 0) |- node[right, near start, align=left]{sensed output\\$v$} (K.east); \end{tikzpicture} #+end_src -#+name: fig:classical_feedback -#+caption: Classical Feedback Architecture +#+name: fig:general_control_names +#+caption: General Control Configuration #+RESULTS: -[[file:figs/classical_feedback.png]] +[[file:figs/general_control_names.png]] -#+name: table:notation_conventional -#+caption: Notations for the Classical Feedback Architecture -| Notation | Meaning | -|------------+-------------------| -| $G$ | Plant model | -| $K$ | Controller | -| $r$ | Reference inputs | -| $y$ | Plant outputs | -| $u$ | Control signals | -| $d$ | Input Disturbance | -| $\epsilon$ | Tracking Error | +Note that the closed-loop transfer function from $w$ to $z$ is: +\begin{equation} + \frac{z}{w} = P_{11} + P_{12} K \big( I - P_{22} K \big)^{-1} P_{21} \triangleq F_l(P, K) +\end{equation} -The procedure is: -1. define signals of the generalized plant -2. Remove $K$ and rearrange the inputs and outputs +Using Matlab, the $\mathcal{H}_\infty$ Synthesis applied on a Generalized plant can be applied using the =hinfsyn= command ([[https://www.mathworks.com/help/robust/ref/hinfsyn.html][documentation]]): +#+begin_src matlab :eval no + K = hinfsyn(P, nmeas, ncont); +#+end_src +where: +- =P= is the generalized plant transfer function matrix +- =nmeas= is the number of sensed output (size of $v$) +- =ncont= is the number of control signals (size of $u$) +- =K= obtained controller that minimized the $\mathcal{H}_\infty$ norm from $w$ to $z$ + +** From a Classical Feedback Architecture to a Generalized Plant +<> + +The procedure to convert a typical control architecture as the one shown in Figure [[fig:classical_feedback_tracking]] to a generalized Plant is as follows: +1. Define signals ($w$, $z$, $u$ and $v$) of the generalized plant +2. Remove $K$ and rearrange the inputs and outputs to match the generalized configuration #+begin_src latex :file classical_feedback_tracking.pdf \begin{tikzpicture} @@ -765,12 +884,13 @@ The procedure is: #+end_src #+begin_exercice - Let's find the Generalized plant of corresponding to the tracking control architecture shown in Figure [[fig:classical_feedback_tracking]] + Compute the Generalized plant of corresponding to the tracking control architecture shown in Figure [[fig:classical_feedback_tracking]] #+name: fig:classical_feedback_tracking #+caption: Classical Feedback Control Architecture (Tracking) [[file:figs/classical_feedback_tracking.png]] +#+HTML:
    Hint First, define the signals of the generalized plant: - Exogenous inputs: $w = r$ - Signals to be minimized: $z_1 = \epsilon$, $z_2 = u$ @@ -778,76 +898,550 @@ The procedure is: - Control inputs: $u$ Then, Remove $K$ and rearrange the inputs and outputs. - We obtain the generalized plant shown in Figure [[fig:mixed_sensitivity_ref_tracking]]. +#+HTML:
    + +#+HTML:
    Answer + The obtained generalized plant shown in Figure [[fig:mixed_sensitivity_ref_tracking]]. #+name: fig:mixed_sensitivity_ref_tracking #+caption: Generalized plant of the Classical Feedback Control Architecture (Tracking) [[file:figs/mixed_sensitivity_ref_tracking.png]] - - Using Matlab, the generalized plant can be defined as follows: - #+begin_src matlab :tangle no :eval no - P = [1 -G; - 0 1; - 1 -G] - #+end_src +#+HTML:
    #+end_exercice - -** The General Synthesis Problem Formulation - -#+begin_important - The $\mathcal{H}_\infty$ Synthesis objective is to find all stabilizing controllers $K$ which minimize - \begin{equation} - \| F_l(P, K) \|_\infty = \max_{\omega} \overline{\sigma} \big( F_l(P, K)(j\omega) \big) - \end{equation} - -#+end_important - -#+begin_src latex :file general_control_names.pdf - \begin{tikzpicture} - - % Blocs - \node[block={2.0cm}{2.0cm}] (P) {$P$}; - \node[block={1.5cm}{1.5cm}, below=0.7 of P] (K) {$K$}; - - % Input and outputs coordinates - \coordinate[] (inputw) at ($(P.south west)!0.75!(P.north west)$); - \coordinate[] (inputu) at ($(P.south west)!0.25!(P.north west)$); - \coordinate[] (outputz) at ($(P.south east)!0.75!(P.north east)$); - \coordinate[] (outputv) at ($(P.south east)!0.25!(P.north east)$); - - % Connections and labels - \draw[<-] (inputw) node[above left, align=right]{(weighted)\\exogenous inputs\\$w$} -- ++(-1.5, 0); - \draw[<-] (inputu) -- ++(-0.8, 0) |- node[left, near start, align=right]{control signals\\$u$} (K.west); - - \draw[->] (outputz) node[above right, align=left]{(weighted)\\exogenous outputs\\$z$} -- ++(1.5, 0); - \draw[->] (outputv) -- ++(0.8, 0) |- node[right, near start, align=left]{sensed output\\$v$} (K.east); - \end{tikzpicture} +Using Matlab, the generalized plant can be defined as follows: +#+begin_src matlab :tangle no :eval no + P = [1 -G; + 0 1; + 1 -G] + P.InputName = {'w', 'u'}; + P.OutputName = {'e', 'u', 'v'}; #+end_src -#+name: fig:general_control_names -#+caption: General Control Configuration -#+RESULTS: -[[file:figs/general_control_names.png]] - - * Modern Interpretation of the Control Specifications -** Introduction +<> -- *Reference tracking* Overshoot, Static error, Setling time - - $S(s) = T_{r \rightarrow \epsilon}$ +** Introduction +The + +#+name: fig:gang_of_four_feedback +#+caption: Simple Feedback Architecture +#+RESULTS: +[[file:figs/gang_of_four_feedback.png]] + +- *Reference tracking* Overshoot, Static error, Settling time + - From $r$ to $\epsilon$ - *Disturbances rejection* + - From $d$ to $y$ - $G(s) S(s) = T_{d \rightarrow \epsilon}$ - *Measurement noise filtering* + - From $n$ to $y$ - $T(s) = T_{n \rightarrow \epsilon}$ - *Small command amplitude* + - From $n, r, d$ to $u$ - $K(s) S(s) = T_{r \rightarrow u}$ - *Stability* - $S(s)$, $T(s)$, $K(s)S(s)$, $G(s)S(s)$ - *Robustness to plant uncertainty* (stability margins) - *Controller implementation* -** +** Closed Loop Transfer Functions +<> + +As the performances of a controlled system depend on the *closed* loop transfer functions, it is very important to derive these closed-loop transfer functions as a function of the plant $G(s)$ and controller $K(s)$. + +#+begin_src latex :file gang_of_four_feedback.pdf + \begin{tikzpicture} + \node[addb={+}{}{}{}{-}] (addfb) at (0, 0){}; + \node[block, right=0.8 of addfb] (K){$K(s)$}; + \node[addb, right=0.8 of K] (addd){}; + \node[block, right=0.8 of addd] (G){$G(s)$}; + \node[addb, below right=0.4 and 0.2 of G] (addn){}; + + \draw[<-] (addfb.west) -- ++(-0.8, 0) node[above right]{$r$}; + \draw[->] (addfb.east) -- (K.west) node[above left]{$\epsilon$}; + \draw[->] (K.east) -- (addd.west); + \draw[<-] (addd.north) -- ++(0, 0.6) node[below right]{$d$}; + \draw[->] (addd.east) -- (G.west) node[above left]{$u$}; + \draw[->] (G.east) -- ++(1.6, 0) node[above left]{$y$}; + \draw[->] (G-|addn) node[branch]{} -- (addn.north); + \draw[<-] (addn.east) -- ++(0.8, 0) node[above left]{$n$}; + \draw[->] (addn.west) -| (addfb.south); + \end{tikzpicture} +#+end_src + +#+name: fig:gang_of_four_feedback +#+caption: Simple Feedback Architecture +#+RESULTS: +[[file:figs/gang_of_four_feedback.png]] + +#+begin_exercice +Write the output signals $[\epsilon, u, y]$ as a function of the systems $K(s), G(s)$ and of the input signals $[r, d, n]$ as shown in Figure [[fig:gang_of_four_feedback]]. + +#+HTML:
    Hint +Take one of the output (e.g. $y$), and write it as a function of the inputs $[d, r, n]$ going step by step around the loop: +\begin{aligned} + y &= G u \\ + &= G (d + K \epsilon) \\ + &= G \big(d + K (r - n - y) \big) \\ + &= G d + GK r - GK n - GK y +\end{aligned} + +Isolate $y$ at the right hand side, and finally obtain: +\[ y = \frac{GK}{1+ GK} r + \frac{G}{1 + GK} d - \frac{GK}{1 + GK} n \] + +Do the same procedure for $u$ and $\epsilon$ +#+HTML:
    + +#+HTML:
    Anwser +The following equations should be obtained: +\begin{align} + y &= \frac{GK}{1 + GK} r + \frac{G}{1 + GK} d - \frac{GK}{1 + GK} n \\ + \epsilon &= \frac{1 }{1 + GK} r - \frac{G}{1 + GK} d - \frac{G }{1 + GK} n \\ + u &= \frac{K }{1 + GK} r - \frac{1}{1 + GK} d - \frac{K }{1 + GK} n +\end{align} +#+HTML:
    +#+end_exercice + +We can see that their are 4 different transfer functions describing the behavior of the system in Figure [[fig:gang_of_four_feedback]]. +They are called the *Gang of Four*: +\begin{align} + S &= \frac{1 }{1 + GK}, \quad \text{the sensitivity function} \\ + T &= \frac{GK}{1 + GK}, \quad \text{the complementary sensitivity function} \\ + GS &= \frac{G }{1 + GK}, \quad \text{the load disturbance sensitivity function} \\ + KS &= \frac{K }{1 + GK}, \quad \text{the noise sensitivity function} +\end{align} + +#+begin_seealso +If a feedforward controller is included, a *Gang of Six* transfer functions can be defined. +More on that in this [[https://www.youtube.com/watch?v=b_8v8scghh8][short video]]. +#+end_seealso + +And we have: +\begin{align} + \epsilon &= S r - GS d - GS n \\ + y &= T r + GS d - T n \\ + u &= KS r - S d - KS n +\end{align} + +** Sensitivity Transfer Function +<> + +#+begin_src matlab + K1 = 14e8 * ... % Gain + 1/(s^2) * ... % Double Integrator + (1 + s/(2*pi*10/sqrt(8)))/(1 + s/(2*pi*10*sqrt(8))); % Lead + + K2 = 1e8 * ... % Gain + 1/(s^2) * ... % Double Integrator + (1 + s/(2*pi*1/sqrt(8)))/(1 + s/(2*pi*1*sqrt(8))); % Lead + + K3 = 1e8 * ... % Gain + 1/(s^2) * ... % Double Integrator + (1 + s/(2*pi*1/sqrt(2)))/(1 + s/(2*pi*1*sqrt(2))); % Lead + + S1 = 1/(1 + K1*G); + S2 = 1/(1 + K2*G); + S3 = 1/(1 + K3*G); + + T1 = K1*G/(1 + K1*G); + T2 = K2*G/(1 + K2*G); + T3 = K3*G/(1 + K3*G); + + bodeFig({S1, S2, S3}) +#+end_src + +#+begin_src matlab + freqs = logspace(-1, 2, 1000); + + figure; + tiledlayout(1, 2, 'TileSpacing', 'None', 'Padding', 'None'); + + ax1 = nexttile; + hold on; + plot(freqs, abs(squeeze(freqresp(S1, freqs, 'Hz'))), 'DisplayName', '$L(s)$'); + plot(freqs, abs(squeeze(freqresp(S2, freqs, 'Hz'))), 'DisplayName', '$L_w(s)$'); + plot(freqs, abs(squeeze(freqresp(S3, freqs, 'Hz'))), 'DisplayName', '$L_w(s) / \gamma$, $L_w(s) \cdot \gamma$'); + hold off; + set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log'); + xlabel('Frquency [Hz]'); ylabel('Sensitivity Magnitude'); + hold off; + + ax2 = nexttile; + t = linspace(0, 1, 1000); + y1 = step(T1, t); + y2 = step(T2, t); + y3 = step(T3, t); + hold on; + plot(t, y1) + plot(t, y2) + plot(t, y3) + hold off + xlabel('Time [s]'); ylabel('Step Response'); +#+end_src + +#+begin_src latex :file h-infinity-spec-S.pdf + \begin{tikzpicture} + \begin{axis}[% + width=8cm, + height=4cm, + at={(0,0)}, + xmode=log, + xmin=0.01, + xmax=10000, + ymin=-80, + ymax=40, + ylabel={Magnitude [dB]}, + xlabel={Frequency [Hz]}, + ytick={40, 20, 0, -20, -40, -60, -80}, + xminorgrids, + yminorgrids + ] + \addplot [thick, color=black, forget plot] + table[row sep=crcr]{% + 0.01 -60\\ + 0.1 -60\\ + 190 6\\ + 10000 6\\ + }; + \draw[<-] (0.05, -60) -- (0.1, -70); + \draw (0.1, -70) -- (2, -70) node[right, fill=white, draw]{$\SI{-60}{\decibel} \rightarrow$ \footnotesize{Static error}}; + \draw[<-] (1, -40) -- (10, -40) node[right, fill=white, draw]{$\SI{20}{\decibel/dec} \rightarrow$ \footnotesize{Ref. track.}}; + \draw[<-] (100, 0) -- (3, 0) node[left, fill=white, draw]{$\omega_c \rightarrow$ \footnotesize{Speed}}; + + \draw[<-] (300, 6) -- (200, 20); + \draw (200, 20) -- (10, 20) node[left, fill=white, draw]{$\SI{6}{\decibel} \rightarrow$ \footnotesize{Module margin}}; + \end{axis} + \end{tikzpicture} +#+end_src + +#+name: fig:h-infinity-spec-S +#+caption: Typical wanted shape of the Sensitivity transfer function +#+RESULTS: +[[file:figs/h-infinity-spec-S.png]] + +** Robustness: Module Margin +<> + +- [ ] Definition of Module margin +- [ ] Why it represents robustness +- [ ] Example + +\[ M_S < 2 \Rightarrow \text{GM} > 2 \text{ and } \text{PM} > 29^o \] + +** How to *Shape* transfer function? Using of Weighting Functions! +<> + +Let's say we want to shape the sensitivity transfer function corresponding to the transfer function from $r$ to $\epsilon$ of the control architecture shown in Figure [[fig:loop_shaping_S_without_W]]. + +#+begin_src latex :file loop_shaping_S_without_W.pdf + \begin{tikzpicture} + \node[block] (G) {$G(s)$}; + \node[addb={+}{-}{}{}{}, right=0.6 of G] (addw) {}; + \coordinate[above right=1.0 and 1.4 of addw] (epsilon); + + \coordinate[] (w) at ($(epsilon-|G.west)+(-1.0, 0)$); + + \node[block, below left=0.8 and 0 of addw] (K) {$K(s)$}; + + % Connections + \draw[->] (G.east) -- (addw.west); + \draw[->] ($(addw.east)+(0.4, 0)$)node[branch]{} |- (epsilon) node[above left](z1){$\epsilon$}; + + \draw[->] (addw.east) -- (addw-|z1) |- node[near start, right]{$v$} (K.east); + \draw[->] (K.west) -| node[near end, left]{$u$} ($(G-|w)+(0.4, 0)$) -- (G.west); + + \draw[->] (w) node[above]{$w = r$} -| (addw.north); + + \begin{scope}[on background layer] + \node[fit={(G.south west) ($(z1.north west)+(-0.4, 0)$)}, inner sep=12pt, draw, dashed, fill=black!20!white] (P) {}; + \node[below] at (P.north) {Generalized Plant $P(s)$}; + \end{scope} + \end{tikzpicture} +#+end_src + +#+name: fig:loop_shaping_S_without_W +#+caption: Generalized Plant +#+RESULTS: +[[file:figs/loop_shaping_S_without_W.png]] + +If the $\mathcal{H}_\infty$ synthesis is directly applied on the generalized plant $P(s)$ shown in Figure [[fig:loop_shaping_S_without_W]], if will minimize the $\mathcal{H}_\infty$ norm of transfer function from $r$ to $\epsilon$ (the sensitivity transfer function). + +However, as the $\mathcal{H}_\infty$ norm is the maximum peak value of the transfer function's magnitude, it does not allow to *shape* the norm over all frequencies. + + + +A /trick/ is to include a *weighting function* in the generalized plant as shown in Figure [[fig:loop_shaping_S_with_W]]. +Applying the $\mathcal{H}_\infty$ synthesis to the /weighted/ generalized plant $\tilde{P}(s)$ (Figure [[fig:loop_shaping_S_with_W]]) will generate a controller $K(s)$ that minimizes the $\mathcal{H}_\infty$ norm between $r$ and $\tilde{\epsilon}$: +\begin{equation} +\begin{aligned} + & \left\| \frac{\tilde{\epsilon}}{r} \right\|_\infty < \gamma (=1) \\ + \Leftrightarrow & \left\| W_s(s) S(s) \right\|_\infty < 1 \\ + \Leftrightarrow & \left| W_s(j\omega) S(j\omega) \right| < 1 \quad \forall \omega \\ + \Leftrightarrow & \left| S(j\omega) \right| < \frac{1}{\left| W_s(j\omega) \right|} \quad \forall \omega +\end{aligned}\label{eq:sensitivity_shaping} +\end{equation} + +#+begin_important + As shown in Equation eqref:eq:sensitivity_shaping, the $\mathcal{H}_\infty$ synthesis allows to *shape* the magnitude of the sensitivity transfer function. + Therefore, the choice of the weighting function $W_s(s)$ is very important. + Its inverse magnitude will define the frequency dependent upper bound of the sensitivity transfer function magnitude. +#+end_important + +#+begin_src latex :file loop_shaping_S_with_W.pdf + \begin{tikzpicture} + \node[block] (G) {$G(s)$}; + \node[addb={+}{-}{}{}{}, right=0.6 of G] (addw) {}; + \node[block, above right=1.0 and 1.0 of addw] (Ws) {$W_s(s)$}; + \coordinate[right=0.8 of Ws] (epsilon); + + \coordinate[] (w) at ($(epsilon-|G.west)+(-1.0, 0)$); + + \begin{scope}[on background layer] + \node[fit={(G.south west) (Ws.north east)}, inner sep=8pt, draw, dashed, fill=black!20!white] (P) {}; + \node[above] at (P.north) {Weighted Generalized Plant $\tilde{P}(s)$}; + \end{scope} + + \node[block, below=0.4 of P] (K) {$K(s)$}; + + % Connections + \draw[->] (G.east) -- (addw.west); + \draw[->] ($(addw.east)+(0.4, 0)$)node[branch]{} |- (Ws.west)node[above left]{$\epsilon$}; + \draw[->] (Ws.east) -- (epsilon) node[above left](z1){$\tilde{\epsilon}$}; + + \draw[->] (addw.east) -- (addw-|z1) |- node[near start, right]{$v$} (K.east); + \draw[->] (K.west) -| node[near end, left]{$u$} ($(G-|w)+(0.4, 0)$) -- (G.west); + + \draw[->] (w) node[above]{$w = r$} -| (addw.north); + \end{tikzpicture} +#+end_src + +#+name: fig:loop_shaping_S_with_W +#+caption: Weighted Generalized Plant +#+RESULTS: +[[file:figs/loop_shaping_S_with_W.png]] + +Once the weighting function is designed, it should be added to the generalized plant as shown in Figure [[fig:loop_shaping_S_with_W]]. + +The weighted generalized plant can be defined in Matlab by either re-defining all the inputs or by pre-multiplying the (non-weighted) generalized plant by a block-diagonal MIMO transfer function containing the weights for the outputs $z$ and =1= for the outputs $v$. + +#+begin_src matlab :tangle no :eval no + Pw = [Ws -Ws*G; + 1 -G] + + % Alternative + Pw = blkdiag(Ws, 1)*P; +#+end_src + +** Design of Weighting Functions +<> + +Weighting function used must be *proper*, *stable* and *minimum phase* transfer functions. +- proper :: + more poles than zeros, this implies $\lim_{\omega \to \infty} |W(j\omega)| < \infty$ +- stable :: + no poles in the right half plane +- minimum phase :: + no zeros in the right half plane + +Matlab is providing the =makeweight= function that creates a first-order weights by specifying the low frequency gain, high frequency gain, and a gain at a specific frequency: +#+begin_src matlab :tangle no :eval no + W = makeweight(dcgain,[freq,mag],hfgain) +#+end_src +with: +- =dcgain= +- =freq= +- =mag= +- =hfgain= + +#+begin_exampl +The Matlab code below produces a weighting function with a magnitude shape shown in Figure [[fig:first_order_weight]]. + +#+begin_src matlab + Ws = makeweight(1e2, [2*pi*10, 1], 1/2); +#+end_src + +#+begin_src matlab :exports none + freqs = logspace(-2, 2, 1000); + + figure; + hold on; + plot(freqs, abs(squeeze(freqresp(Ws, freqs, 'Hz'))), 'k-'); + hold off; + set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log'); + xlabel('Frquency [Hz]'); ylabel('Magnitude'); + hold off; +#+end_src + +#+begin_src matlab :tangle no :exports results :results file replace + exportFig('figs/first_order_weight.pdf', 'width', 'wide', 'height', 'normal'); +#+end_src + +#+name: fig:first_order_weight +#+caption: Obtained Magnitude of the Weighting Function +#+RESULTS: +[[file:figs/first_order_weight.png]] +#+end_exampl + +#+begin_seealso +Quite often, higher orders weights are required. + +In such case, the following formula can be used the design of these weights: + +\begin{equation} + W(s) = \left( \frac{ + \frac{1}{\omega_0} \sqrt{\frac{1 - \left(\frac{G_0}{G_c}\right)^{\frac{2}{n}}}{1 - \left(\frac{G_c}{G_\infty}\right)^{\frac{2}{n}}}} s + \left(\frac{G_0}{G_c}\right)^{\frac{1}{n}} + }{ + \left(\frac{1}{G_\infty}\right)^{\frac{1}{n}} \frac{1}{\omega_0} \sqrt{\frac{1 - \left(\frac{G_0}{G_c}\right)^{\frac{2}{n}}}{1 - \left(\frac{G_c}{G_\infty}\right)^{\frac{2}{n}}}} s + \left(\frac{1}{G_c}\right)^{\frac{1}{n}} + }\right)^n \label{eq:weight_formula_advanced} +\end{equation} + +The parameters permit to specify: +- the low frequency gain: $G_0 = lim_{\omega \to 0} |W(j\omega)|$ +- the high frequency gain: $G_\infty = lim_{\omega \to \infty} |W(j\omega)|$ +- the absolute gain at $\omega_0$: $G_c = |W(j\omega_0)|$ +- the absolute slope between high and low frequency: $n$ + +A Matlab function implementing Equation eqref:eq:weight_formula_advanced is shown below: + +#+name: lst:generateWeight +#+caption: Matlab Function that can be used to generate Weighting functions +#+begin_src matlab :tangle matlab/generateWeight.m :comments none :eval no + function [W] = generateWeight(args) + arguments + args.G0 (1,1) double {mustBeNumeric, mustBePositive} = 0.1 + args.G1 (1,1) double {mustBeNumeric, mustBePositive} = 10 + args.Gc (1,1) double {mustBeNumeric, mustBePositive} = 1 + args.wc (1,1) double {mustBeNumeric, mustBePositive} = 2*pi + args.n (1,1) double {mustBeInteger, mustBePositive} = 1 + end + + if (args.Gc <= args.G0 && args.Gc <= args.G1) || (args.Gc >= args.G0 && args.Gc >= args.G1) + eid = 'value:range'; + msg = 'Gc must be between G0 and G1'; + throwAsCaller(MException(eid,msg)) + end + + s = zpk('s'); + + W = (((1/args.wc)*sqrt((1-(args.G0/args.Gc)^(2/args.n))/(1-(args.Gc/args.G1)^(2/args.n)))*s + (args.G0/args.Gc)^(1/args.n))/((1/args.G1)^(1/args.n)*(1/args.wc)*sqrt((1-(args.G0/args.Gc)^(2/args.n))/(1-(args.Gc/args.G1)^(2/args.n)))*s + (1/args.Gc)^(1/args.n)))^args.n; + + end +#+end_src + +Let's use this function to generate three weights with the same high and low frequency gains, but but different slopes. + +#+begin_src matlab + W1 = generateWeight('G0', 1e2, 'G1', 1/2, 'Gc', 1, 'wc', 2*pi*10, 'n', 1); + W2 = generateWeight('G0', 1e2, 'G1', 1/2, 'Gc', 1, 'wc', 2*pi*10, 'n', 2); + W3 = generateWeight('G0', 1e2, 'G1', 1/2, 'Gc', 1, 'wc', 2*pi*10, 'n', 3); +#+end_src + +The obtained shapes are shown in Figure [[fig:high_order_weight]]. + +#+begin_src matlab :exports none + freqs = logspace(-2, 2, 1000); + + figure; + hold on; + plot(freqs, abs(squeeze(freqresp(W1, freqs, 'Hz'))), ... + 'DisplayName', '$n = 1$'); + plot(freqs, abs(squeeze(freqresp(W2, freqs, 'Hz'))), ... + 'DisplayName', '$n = 2$'); + plot(freqs, abs(squeeze(freqresp(W3, freqs, 'Hz'))), ... + 'DisplayName', '$n = 3$'); + hold off; + set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log'); + xlabel('Frquency [Hz]'); ylabel('Magnitude'); + legend('location', 'northeast'); +#+end_src + +#+begin_src matlab :tangle no :exports results :results file replace + exportFig('figs/high_order_weight.pdf', 'width', 'wide', 'height', 'normal'); +#+end_src + +#+name: fig:high_order_weight +#+caption: Higher order weights using Equation eqref:eq:weight_formula_advanced +#+RESULTS: +[[file:figs/high_order_weight.png]] +#+end_seealso + +** Sensitivity Function Shaping - Example +<> + +- Robustness: Module margin > 2 ($\Rightarrow \text{GM} > 2 \text{ and } \text{PM} > 29^o$) +- Bandwidth: +- Slope of -2 + +First, the weighting functions is generated. +#+begin_src matlab + Ws = generateWeight('G0', 1e3, 'G1', 1/2, 'Gc', 1, 'wc', 2*pi*10, 'n', 2); +#+end_src + +It is then added to the generalized plant. +#+begin_src matlab + Pw = blkdiag(Ws, 1)*P; +#+end_src + +And the $\mathcal{H}_\infty$ synthesis is performed. +#+begin_src matlab :results output replace + K = hinfsyn(Pw, 1, 1, 'Display', 'on'); +#+end_src + +#+RESULTS: +#+begin_example +K = hinfsyn(Pw, 1, 1, 'Display', 'on'); + + Test bounds: 0.5 <= gamma <= 0.51 + + gamma X>=0 Y>=0 rho(XY)<1 p/f + 5.05e-01 0.0e+00 0.0e+00 4.497e-28 p + Limiting gains... + 5.05e-01 0.0e+00 0.0e+00 0.000e+00 p + 5.05e-01 -1.8e+01 # -2.9e-15 1.514e-15 f + + Best performance (actual): 0.504 +#+end_example + +The obtained $\gamma \approx 0.5$ means that it found a controller $K(s)$ that stabilize the closed-loop system, and such that: +\begin{aligned} + & \| W_s(s) S(s) \|_\infty < 0.5 \\ + & \Leftrightarrow |S(j\omega)| < \frac{0.5}{|W_s(j\omega)|} \quad \forall \omega +\end{aligned} + +This is indeed what we can see by comparing $|S|$ and $|W_S|$ in Figure [[fig:results_sensitivity_hinf]]. + +#+begin_src matlab :exports none + figure; + hold on; + plot(freqs, 1./abs(squeeze(freqresp(Ws, freqs, 'Hz'))), 'k--', 'DisplayName', '$|W_s|^{-1}$'); + plot(freqs, abs(squeeze(freqresp(1/(1 + K*G), freqs, 'Hz'))), 'k-', 'DisplayName', '$|S|$'); + set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log'); + xlabel('Frequency [Hz]'); ylabel('Magnitude'); + legend('location', 'southeast', 'FontSize', 8); +#+end_src + +#+begin_src matlab :tangle no :exports results :results file replace + exportFig('figs/results_sensitivity_hinf.pdf', 'width', 'wide', 'height', 'normal'); +#+end_src + +#+name: fig:results_sensitivity_hinf +#+caption: Weighting function and obtained closed-loop sensitivity +#+RESULTS: +[[file:figs/results_sensitivity_hinf.png]] + +* $\mathcal{H}_\infty$ Mixed-Sensitivity Synthesis +<> + +** Problem + +** Typical Procedure + +** Step 1 - Shaping of the Sensitivity Function + +** Step 2 - Shaping of + +* Conclusion * Resources diff --git a/matlab/generateWeight.m b/matlab/generateWeight.m new file mode 100644 index 0000000..f28ec1a --- /dev/null +++ b/matlab/generateWeight.m @@ -0,0 +1,20 @@ +function [W] = generateWeight(args) + arguments + args.G0 (1,1) double {mustBeNumeric, mustBePositive} = 0.1 + args.G1 (1,1) double {mustBeNumeric, mustBePositive} = 10 + args.Gc (1,1) double {mustBeNumeric, mustBePositive} = 1 + args.wc (1,1) double {mustBeNumeric, mustBePositive} = 2*pi + args.n (1,1) double {mustBeInteger, mustBePositive} = 1 + end + + if (args.Gc <= args.G0 && args.Gc <= args.G1) || (args.Gc >= args.G0 && args.Gc >= args.G1) + eid = 'value:range'; + msg = 'Gc must be between G0 and G1'; + throwAsCaller(MException(eid,msg)) + end + + s = zpk('s'); + + W = (((1/args.wc)*sqrt((1-(args.G0/args.Gc)^(2/args.n))/(1-(args.Gc/args.G1)^(2/args.n)))*s + (args.G0/args.Gc)^(1/args.n))/((1/args.G1)^(1/args.n)*(1/args.wc)*sqrt((1-(args.G0/args.Gc)^(2/args.n))/(1-(args.Gc/args.G1)^(2/args.n)))*s + (1/args.Gc)^(1/args.n)))^args.n; + +end