%% LyX 2.3.6 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[12pt,fleqn,english, treatise,allpages]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{color}
\usepackage{babel}
\usepackage{float}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[unicode=true]
 {hyperref}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\newcommand{\noun}[1]{\textsc{#1}}
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\theoremstyle{plain}
\newtheorem{thm}{\protect\theoremname}
\theoremstyle{remark}
\newtheorem{rem}[thm]{\protect\remarkname}
\theoremstyle{definition}
\newtheorem{defn}[thm]{\protect\definitionname}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{lastpage}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{Luc Jaulin}
\fancyhead[C]{Automooc}
\fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}
\usepackage{indentfirst}
\usepackage{amsfonts}
\usepackage{eurosym}
\usepackage{verbatim}
\usepackage{amsthm}
\usepackage{float}
%\usepackage[english,francais]{babel}
\usepackage{epstopdf}
\usepackage{comment}\setcounter{MaxMatrixCols}{30}
\sloppy
\newtheoremstyle{mytheoremstyle}
{11pt}
{11pt}
{\itshape}
{}
{\scshape}
{.--}
{.5em}
{}
\theoremstyle{mytheoremstyle}
\textwidth 18cm
\topmargin -1cm
\oddsidemargin -0.5cm
\evensidemargin -0.5cm
\headsep 1cm
\textheight 23cm
\renewcommand{\baselinestretch}{1.1}
\voffset 0cm
\newtheorem{theoreme}{Theorem}[chapter]
\newtheorem{lemme}{Lemma}[chapter]
\newtheorem{corollaire}{Corallary}[chapter]
\newtheorem{exemple}{Example}[chapter]
\newtheorem{Def}{Definition}[chapter]
\newtheorem{remarque}{Remark}[chapter]
\newtheorem{Exercice}{Exercise}[chapter]
\newtheorem{proposition}{Proposition}[chapter]

\makeatother

\providecommand{\definitionname}{Definition}
\providecommand{\remarkname}{Remark}
\providecommand{\theoremname}{Theorem}

\begin{document}
\title{AutoMOOC\\
\href{https://www.ensta-bretagne.fr/automooc/}{https://www.ensta-bretagne.fr/automooc/}}
\author{Luc Jaulin}

\maketitle
\makeatletter \lefthyphenmin=1000 \righthyphenmin=1000

\setlength{\marginparsep}{9\p@} \setlength{\marginparpush}{8\p@}
\setlength{\marginparwidth}{5.7pc} \makeatother


\chapter{Introduction}

Biological, economic, and other mechanical systems surrounding us
can often be described by a differential equation such as: 
\[
\left\{ \begin{split}\mathbf{\dot{x}}(t) & =\mathbf{f}(\mathbf{x}(t),\mathbf{u}(t))\\
\mathbf{y}(t) & =\mathbf{g}(\mathbf{x}(t),\mathbf{u}(t))
\end{split}
\right.
\]
under the hypothesis that the time $t$ in which the system evolves
is continuous \cite{JaulinLivre05}. The vector $\mathbf{u}(t)$ is
the \emph{input} (or \emph{control}) of the system. Its value may
be chosen arbitrarily for all $t$. The vector $\mathbf{y}(t)$ is
the \emph{output} of the system and can be measured with a certain
degree of accuracy. The vector $\mathbf{x}(t)$ is called the \emph{state}
of the system. It represents the memory of the system, in other words
the information needed by the system in order to predict its own future,
for a known input $\mathbf{u}(t)$. The first of the two equations
is called the \emph{evolution equation}. It is a differential equation
which enables us to know where the state $\mathbf{x}(t)$ is headed
knowing its value at the present moment $t$ and the control $\mathbf{u}(t)$
which we are currently exerting. The second equation is called the
\emph{observation equation}. It allows us to calculate the output
vector $\mathbf{y}(t)$, knowing the state and the control at time
$t$. Note however that, unlike the evolution equation, this equation
is not a differential equation since it does not involve the derivatives
of the signals. The two equations above form the \emph{state representation}
of the system.

\noindent It is sometimes useful to consider a discrete time $k$,
with $k\in\mathbb{Z}$, where $\mathbb{Z}$ is the set of integers.
If, for instance, the universe being considered is a computer, it
is possible to consider that the time $k$ is discrete and synchronized
to the clock of the microprocessor. Discrete-time systems often obey
a recurrence equation such as: 
\[
\left\{ \begin{split}\mathbf{x}(k+1) & =\mathbf{f}(\mathbf{x}(k),\mathbf{u}(k))\\
\mathbf{y}(k) & =\mathbf{g}(\mathbf{x}(k),\mathbf{u}(k))
\end{split}
\right.
\]
The first objective of this book is to understand the concept of state
representation through numerous exercises. For this, we will consider,
in Chapter \ref{ch:modelisation}, a large number of varied exercises
and show how to reach a state representation. We will then show, in
Chapter \ref{ch:simul}, how to simulate a given system on a computer
using its state representation.

\noindent The second objective of this book is to propose methods
to \emph{control} the systems described by state equations. In other
words, we will attempt to build \emph{automatic} machines (in which
humans are practically not involved, except to give orders, or \emph{setpoints}),
called \emph{controllers} capable of \emph{domesticating} (changing
the behavior in a desired direction) the systems being considered.
For this, the controller will have to compute the inputs $\mathbf{u}(t)$
to be applied to the system from the (more or less noisy) knowledge
of the outputs $\mathbf{y(}t\mathbf{)}$ and from the setpoints $\mathbf{w}(t)$
(see Figure \ref{fig:regulateur}).

\begin{figure}[!h]
\begin{centering}
\includegraphics[width=10cm]{regulateur} \caption{Closed loop concept illustrating the control of a system}
\par\end{centering}
\label{fig:regulateur}
\end{figure}

From the point of view of the user, the system, referred to as a \emph{closed-loop
system}, with input $\mathbf{w}(t)$ and output $\mathbf{y}(t)$ will
have a suitable behavior. We will say that we have \emph{controlled}
the system. With this objective of control, we will, in a first phase,
only look at linear systems, in other words when the functions $\mathbf{f}$
and $\mathbf{g}$ are assumed linear. Thus, in the continuous-time
case, the state equations of the system are written as: 
\[
\left\{ \begin{split}\mathbf{\dot{x}}(t) & =\mathbf{Ax}(t)+\mathbf{Bu}(t)\\
\mathbf{y}(t) & =\mathbf{Cx}(t)+\mathbf{Du}(t)
\end{split}
\right.
\]
and in the discrete-time case, they become: 
\[
\left\{ \begin{split}\mathbf{x}(k+1) & =\mathbf{Ax}(k)+\mathbf{Bu}(k)\\
\mathbf{y}(k) & =\mathbf{Cx}(k)+\mathbf{Du}(k)
\end{split}
\right.
\]
The matrices $\mathbf{A\textnormal{,}B\textnormal{,}C\textnormal{,}D}$
are called \emph{evolution}, \emph{control}, \emph{observation} and
\emph{direct matrices}. A detailed analysis of these systems will
be performed in Chapter \ref{ch:syslin}. We will then explain, in
Chapter \ref{ch:com:lin}, how to stabilize these systems. Finally,
we will show in Chapter \ref{ch:com:nl1} that around certain points,
called \emph{operating points}, non-linear systems behave like linear
systems. It will then be possible to stabilize them using the same
methods as those developed for the linear case.

\chapter*{Exercises}

\begin{Exercice} \label{ex:saucisse}Underwater robot \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/9GCxgVcWB3k}{https://youtu.be/9GCxgVcWB3k}}

The underwater robot \emph{Saucisse} of the ENSTA Bretagne \cite{Jaulin09_Automatica_Robust},
whose photo is given in Figure \ref{fig:saucisse_photo}, is a control
system. It includes a computer, three propellers, a camera, a compass
and a sonar. What does the input vector $\mathbf{u}$, the output
vector $\mathbf{y}$, the state vector $\mathbf{x}$ and the setpoint
$\mathbf{w}$ correspond to in this context?

\begin{figure}[!h]
\centering \includegraphics[width=10cm]{saucisse_photo} \caption{Controlled underwater robot}

\label{fig:saucisse_photo} 
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:vaimos} Sailing robot \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/JWUSDrIE7JY}{https://youtu.be/JWUSDrIE7JY}}

The sailing robot \emph{\noun{Vaimos}} (\noun{Ifremer} and \noun{Ensta}
Bretagne) in Figure \ref{fig:vaimos_spiral} is also a control system
\cite{Jaulin:IEEE:TRO:12,JaulinCifa2012}. It is capable of following
paths by itself, such as the one drawn on Figure \ref{fig:vaimos_spiral}.
It has a rudder and a sail adjustable using a sheet. It also has an
anemometer on top of the mast, a compass and a GPS. Describe what
the input vector $\mathbf{u}$, the output vector $\mathbf{y}$, the
state vector $\mathbf{x}$ and the setpoint $\mathbf{w}$ may correspond
to.

\begin{figure}[H]
\centering \includegraphics[width=12cm]{vaimos_spiral} {\hspace*{-18mm}
a)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
b)} \caption{Sailing robot \noun{Vaimos} a) and a path followed by \noun{Vaimos}
b). The zig-zags in the path are due to \noun{Vaimos} having to tack
in order to sail against the wind}

\label{fig:vaimos_spiral}
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:chaos}Chaos \end{Exercice} 

\textcolor{blue}{See the correction video at \href{https://youtu.be/JBIOOykHK9E}{https://youtu.be/JBIOOykHK9E}}

We consider the discrete-time state space model described by
\[
x(k+1)=4x(k)\cdot(1-x(k)).
\]

This system is an archetypal example of how complex, chaotic behavior
can arise from an apparently simple non-linear dynamical equations.
In this system, $x(k)\in[0,1]$ is the population size (in million,
for instance) and $k$ is the year. The model captures two effects:
\begin{itemize}
\item the\emph{ growth} where the population increases exponentially when
the population size is small. 
\item the \emph{starvation} where the growth rate will decrease when the
theoretical carrying capacity of the environment is less than the
current population.
\end{itemize}
1) Give the equilibrium points of the system and specify which of
them is stable.

2) How many cycles with a length 3 (i.e., $x(k+3)=x(k)$). A graphic
resolution could be used for this purpose.

3) Provide a simulation of the system and illustrate the chaotic behavior
of the system.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:henon}Henon map \end{Exercice}

\textcolor{blue}{See the correction video at \href{http://Tf_IHzvBnyk}{Tf\_IHzvBnyk}}

Given a discrete-time state space system of the form $\mathbf{x}(k+1)=\mathbf{f}(\mathbf{x}(k))$.
A set \noun{$\mathbb{I}$} is said to be invariant $\mathbf{f}(\mathbb{I})=\mathbb{I}$.

1) Prove that if $\mathbb{I}_{1}$ and $\mathbb{I}_{2}$ are both
invariant then their union is invariant.

2) Given a set $\mathbb{A}$, show that there exists a largest invariant
set which is included in $\mathbb{A}$, denoted by $\text{Inv}(\mathbb{A})$.

3) Show that the sequence of sets defined by 
\[
\left\{ \begin{array}{c}
\mathbb{X}(k+1)=\mathbf{f}(\mathbb{X}(k))\cap\mathbb{A}\\
\mathbb{X}(0)=\mathbb{A}
\end{array}\right.
\]
converges toward $\text{Inv}(\mathbb{A})$. 

4) Assume that
\[
\mathbf{f}(\mathbf{x})=\left(\begin{array}{c}
x_{1}+1-ax_{1}^{2}\\
bx_{1}
\end{array}\right)
\]
where $a=1.4$ and $b=0.3$. Make a program which draws an approximation
the largest invariant set of the system which is included in the box
$[-2,2]\times[-2,2]$. 

\chapter{Modeling \label{ch:modelisation}}

We will call \emph{modeling} the step which consists of finding a
more or less accurate state representation of the system we are looking
at. In general, constant parameters appear in the state equations
(such as the mass or the inertial moment of a body, the coefficient
of viscous friction, the capacitance of a capacitor, etc.). In these
cases, an identification step may prove to be necessary. In this book,
we will assume that all the parameters are known, otherwise we invite
the reader to consult Eric Walter's book \cite{Walter14} for a broad
range of identification methods. Of course, no systematic methodology
exists that can be used to model a system. The goal of this chapter
and of the following exercises is to present, using several varied
examples, how to obtain a state representation.

\section{Modeling method}

To model a system here means to represent the evolution of the system
under the form 
\begin{equation}
\mathbf{\dot{x}}(t)=\mathbf{f}(\mathbf{x}(t),\mathbf{u}(t))\label{eq:state:eq:xt}
\end{equation}
if the time $t$ is continuous, or 
\begin{equation}
\mathbf{x}(k+1)=\mathbf{f}(\mathbf{x}(k),\mathbf{u}(k))\label{eq:state:eq:xk}
\end{equation}
if the time $k$ is discrete. The first step of the modeling is to
find what is the memory of the system. When the system is a physical
mechanism, this amounts to finding where the energy is stored. The
state can also be understood as all quantities we need to know at
the current time on the system to be able to predict the future, from
the single knowledge of the input vector $\mathbf{u}(t)$ or $\mathbf{u}(k)$.
For some applications, it is also needed to find the observation equation
which is often easier.

The state variables can be 
\begin{itemize}
\item the degrees of freedom (position, angles) of a mechanical system,
\item the speeds, or equivalently, the derivative of the degrees of freedom;
\item the quantity of water inside tank;
\item the electric current when it goes through an inductance;
\item the charge of a capacitor;
\item the temperature of a body.
\end{itemize}
Then, we apply basic physic rules which tell us how these state variables
will change with time. These rules are often given into a simple first
order differential equation. Examples are
\begin{itemize}
\item The kinematic relations $\dot{x}=v$ or $\dot{v}=a$, which tells
us that the speed is the derivative of the position with respect to
$t$ or that the acceleration is the derivative of the speed. 
\item The Newton laws, such as $\dot{v}=\frac{f}{m}$, where $f$ is the
force, $m$ is the mass and $v$ is the speed;
\item Electric rules such as the Faraday's law of induction $\frac{d}{dt}i=\frac{u}{L}$
which states that any change in flux through a circuit induces an
electromotive force or the relation $\frac{dv}{dt}=\frac{i}{C}$ which
states that the current $i(t)$ through a capacitor is proportional
to the derivative of the voltage $v(t)$. 
\item The Fick's laws which postulates a time variation of a quantity (such
as the temperature) is related to the spacial variations.
\end{itemize}
Combining all these equations, we have to build a single state equation
of the form (\ref{eq:state:eq:xt}) or (\ref{eq:state:eq:xk}).

\section{Linear systems}

In the continuous-time case, linear systems can be described by the
following state equations: 
\[
\left\{ \begin{split}\mathbf{\dot{x}}(t) & =\mathbf{Ax}(t)+\mathbf{Bu}(t)\\
\mathbf{y}(t) & =\mathbf{Cx}(t)+\mathbf{Du}(t)
\end{split}
\right.
\]
Linear systems are rather rare in nature. However, they are relatively
easy to manipulate using linear algebra techniques and often approximate
in an acceptable way the non-linear systems around their operating
point. Moreover, when we combine linear systems (for instance in line,
in parallel, or a loop), we still obtain a linear system. They will
we studied in details in Chapter \ref{ch:syslin}.

\section{Mechanical systems \label{st:model:meca}}

In this section, we will focus our attention on mechanical systems
which are necessary when modeling robots. The fundamental principle
of dynamics allows us to easily find the state equations of mechanical
systems (such as robots). The resulting calculations are relatively
complicated for complex systems and the use of computer algebra systems
may prove to be useful. In order to obtain the state equations of
a mechanical system composed of several subsystems $\mathcal{S}_{1},\mathcal{S}_{2},\dots,\mathcal{S}_{m},$
assumed to be rigid, we follow three steps.
\begin{enumerate}
\item \emph{Obtaining the differential equations}. For each subsystem $\mathcal{S}_{k}$,
with mass $m$ and inertial matrix $\mathbf{J}$, the following relations
must be applied: 
\[
\begin{array}{cc}
\sum_{i}\mathbf{f}_{i} & =m\mathbf{a}\\
\sum_{i}\mathcal{M}_{\mathbf{f}_{i}} & =\mathbf{J\dot{\omega}}
\end{array}
\]
where the $\mathbf{f}_{i}$ are the forces acting on the subsystem
$\mathcal{S}_{k}$, $\mathcal{M}_{\mathbf{f}_{i}}$ represents the
torque created by the force $\mathbf{f}_{i}$ on $\mathcal{S}_{k}$,
with respect to its center. The vector $\mathbf{a}$ represents the
tangential acceleration of $\mathcal{S}_{k}$ and the vector $\mathbf{\dot{\omega}}$
represents the angular acceleration of $\mathcal{S}_{k}$. After decomposing
these $2m$ vectorial equations according to their components, we
obtain $6m$ scalar differential equations such that some of them
might be degenerate.
\item \emph{Removing the components of the internal forces}. In differential
equations there are so-called \emph{bonding} forces, which are internal
to the global mechanical system, even though they are external to
each subsystem composing it. They represent the action of a subsystem
$\mathcal{S}_{k}$ on another subsystem $\mathcal{S}_{\ell}$. Following
the action-reaction principle, the existence of such a force, denoted
by $\mathbf{f}^{k,\ell}$, implies the existence of another force
$\mathbf{f}^{\ell,k}$, representing the action of $\mathcal{S}_{\ell}$
on $\mathcal{S}_{k},$ such that $\mathbf{f}^{\ell,k}=-\mathbf{f}^{k,\ell}$.
Through a formal manipulation of the differential equations and by
taking into account the equations due to the action-reaction principle,
it is possible to remove the internal forces. The resulting number
of differential equations has to be reduced to the number $n$ of
degrees of freedom $q_{1},\dots,q_{n}$ of the system.
\item \emph{Obtaining the state equations}. We then have to isolate the
second derivative $\ddot{q}_{1},\dots,\ddot{q}_{n}$ from the set
of $n$ differential equations in such a way to obtain a vectorial
relation such as: 
\[
\mathbf{\ddot{q}}=\mathbf{f}\left(\mathbf{q,\dot{q},u}\right)
\]
where $\mathbf{u}$ is the vector of external forces which are not
derived from a potential (in other words, those which we apply to
the system). The state equations are then written as: 
\[
\frac{d}{dt}\left(\begin{array}{c}
\mathbf{q}\\
\mathbf{\dot{q}}
\end{array}\right)=\left(\begin{array}{c}
\mathbf{\dot{q}}\\
\mathbf{f}\left(\mathbf{q,\dot{q},u}\right)
\end{array}\right).
\]
\end{enumerate}

\section{Servomotors}

A mechanical system is controlled by forces or torques and obeys a
dynamic model which depends on many poorly known coefficients. This
same mechanical system represented by a kinematic model is controlled
by positions, speeds or accelerations. The kinematic model depends
on well-known geometric coefficients and is a lot easier to put into
equations. In practice, we move from a dynamic model to its kinematic
equivalent by adding servomotors. In summary, a servomotor is a direct
current motor with an electrical control circuit and a sensor (of
the position, speed or acceleration). The control circuit computes
the voltage $u$ to give to the motor in order for the value measured
by the sensor corresponds to the setpoint $w$. In practice, the signal
$w$ is generally given in the form of a square wave called PWM (\emph{Pulse-Width
Modulation}). There are three types of servomotors:
\begin{itemize}
\item the \emph{position servo}. The sensor measures the position (or the
angle) $x$ of the motor and the control rule is expressed as $u=k\left(x-w\right)$.
If $k$ is large, we may conclude that $x\simeq w$ ;
\item the \emph{speed servo}. The sensor measures the speed (or the angular
speed) $\dot{x}$ of the motor and the control rule is expressed as
$u=k\left(\dot{x}-w\right)$. If $k$ is large, we have $\dot{x}\simeq w$
;
\item the \emph{acceleration servo}. The sensor measures the acceleration
(tangential or angular) $\ddot{x}$ of the motor and the control rule
is expressed as $u=k\left(\ddot{x}-w\right)$. If $k$ is large, we
have $\ddot{x}\simeq w$.
\end{itemize}

\section{Non holonomic systems}

A mechanical system whose dynamics can be described by the relation
$\mathbf{\ddot{q}}=\mathbf{f}\left(\mathbf{q,\dot{q},u}\right)$ will
be referred to as \emph{holonomic}. For a holonomic system, $\mathbf{q}$
and $\mathbf{\dot{q}}$ are thus independent. If there is a so-called
\emph{non-holonomic} constraint which links the two of them (of the
form $h\left(\mathbf{q},\mathbf{\dot{q}}\right)=0$), the system will
be referred to as \emph{non-holonomic}. Such systems may be found
for instance in mobile robots with wheels \cite{Laumond01}. Readers
interested in more details on the modeling of mechanical systems may
consult \cite{KhalilDombre:07}. 

Non holonomic system are ubiquitous as soon as we consider vehicles
in robotics. To understand how such system occur, consider the robot
tank in Figure \ref{fig:robot2roues}. It is composed of two parallel
motorized crawlers (or wheels) whose accelerations (which form the
inputs $u_{1}$ and $u_{2}$ of the system) are controlled by two
independent motors. In the case where wheels are considered, the stability
of the system is ensured by one or two idlers, not represented on
the figure. The degrees of freedom of the robot are the $x,y$ coordinates
of its center and its heading $\theta$.

\begin{figure}[!h]
\centering \includegraphics[width=0.5\columnwidth]{robot2roues}
\caption{Robot tank viewed from above}

\label{fig:robot2roues} \vspace*{-3mm}
\end{figure}

The state vector cannot be chosen to be equal to $(x,y,\theta,\dot{x},\dot{y},\dot{\theta})^{\text{T}}$,
which would seem natural with respect to Lagrangian theory. Indeed,
some states such as 
\[
\left(x=0,y=0,\theta=0,\dot{x}=1,\dot{y}=1,\dot{\theta}=0\right)
\]
has no meaning since the tank is not allowed to skid. This phenomenon
is due to the existence of wheels which creates constraints between
the natural state variables. Here, we necessarily have the so-called
\emph{non-holonomic} constraint: 
\[
\dot{y}=\dot{x}\tan\theta
\]
Mechanical systems for which there are such constraints on the equality
of natural state variables (by natural state variables we mean the
vector $(\mathbf{q,\dot{q}})$ where $\mathbf{q}$ is the vector of
the degrees of liberty of our system) are said to be \emph{non-holonomic}.
When such a situation arises, it is useful to employ these constraints
in order to reduce the number of state variables and this, until no
more constraints are left between the state variables.

Denote by $v_{1}$ and $v_{2}$ the center speeds of each of the motorized
wheels. Let us choose as state vector the vector $\mathbf{x}=\left(x,y,\theta,v_{1},v_{2}\right)^{\text{T}}$.
This choice of state variables is easily understood in the sense that
these variables allow us to draw the tank ($x,y,\theta$) and the
knowledge of $v_{1}$,$v_{2}$ allows us to calculate the variables
$\dot{x},\dot{y},\dot{\theta}.$ Moreover, every arbitrary choice
of vector $\left(x,y,\theta,v_{1},v_{2}\right)$ corresponds to a
physically possible situation. The state equations of the system are:
\[
\left(\begin{array}{l}
\dot{x}\\
\dot{y}\\
\dot{\theta}\\
\dot{v}_{1}\\
\dot{v}_{2}
\end{array}\right)=\left(\begin{array}{c}
\frac{v_{1}+v_{2}}{2}\cos\theta\\
\frac{v_{1}+v_{2}}{2}\sin\theta\\
\frac{v_{2}-v_{1}}{\ell}\\
Ru_{1}\\
Ru_{2}
\end{array}\right)
\]
where $\ell$ is the distance between the two wheels. The third relation
on $\dot{\theta}$ is obtained by the speed composition rule (Varignon's
formula). Indeed, we have: 
\[
\mathbf{v}_{2}=\mathbf{v}_{1}+\overrightarrow{C_{2}C_{1}}\wedge\overrightarrow{\mathbf{\omega}}
\]
where $\overrightarrow{\mathbf{\omega}}$ is the instantaneous rotation
vector of the tank and $\mathbf{v}_{1}$ and $\mathbf{v}_{2}$ are
the speed vectors of the centers of the wheels. Let us note that this
relation is a vector relation which depends on the observer but which
is independent of the frame. Let us express this in the frame of the
tank, represented on the figure. We must be careful not to confuse
the observer fixed on the ground with the frame in which the relation
is expressed. This equation is written as:
\[
\underset{\mathbf{v}_{2}}{\underbrace{\left(\begin{array}{c}
v_{2}\\
0\\
0
\end{array}\right)}}=\underset{\mathbf{v}_{1}}{\underbrace{\left(\begin{array}{c}
v_{1}\\
0\\
0
\end{array}\right)}}+\underset{\overrightarrow{C_{2}C_{1}}}{\underbrace{\left(\begin{array}{c}
0\\
\ell\\
0
\end{array}\right)}}\wedge\underset{\overrightarrow{\mathbf{\omega}}}{\underbrace{\left(\begin{array}{c}
0\\
0\\
\dot{\theta}
\end{array}\right)}}
\]
We thus obtain $v_{2}=v_{1}+\ell\dot{\theta}$ or $\dot{\theta}=\frac{v_{2}-v_{1}}{\ell}$.

\chapter*{Exercises}

\begin{Exercice} \label{ex:integrateur} First and second order system
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/LPnkZJFskjY}{https://youtu.be/LPnkZJFskjY}}

We consider an integrator and a second-order system described by
\[
\begin{array}{ccl}
(i) &  & \dot{y}=u\\
(ii) &  & \ddot{y}+a_{1}\dot{y}+a_{0}y=bu
\end{array}
\]

where, $u$ is the input $y$ the output 

Find a state representation in matrix form and give the characteristic
polynomial for the two systems. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:masses_ressorts} Mass-spring system \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/dVdKwrcFpOY}{https://youtu.be/dVdKwrcFpOY}}

Let us consider a system with input $u$ and output $q_{1}$ as shown
in Figure \ref{fig:deuxchariots} ($u$ is the force applied to the
second carriage, $q_{i}$ is the deviation of the $i^{\text{th}}$
carriage with respect to its equilibrium point, $k_{i}$ is the stiffness
of the $i^{th}$ spring, $\alpha$ is the coefficient of viscous friction).

\begin{figure}[!h]
\centering \includegraphics[width=7.8cm]{deuxchariots} \caption{a) Mass-spring system at rest, b) system in any state}

\label{fig:deuxchariots} 
\end{figure}

Let us take the state vector: 
\[
\mathbf{x}=\left(q_{1},q_{2},\dot{q}_{1},\dot{q}_{2}\right)^{\text{T}}
\]

1) Find the state equations of the system.

2) Is this system linear? 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:pendule_simple} Model a pendulum \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/0rkma1Jin90}{https://youtu.be/0rkma1Jin90}} 

Let us consider the pendulum in Figure \ref{fig:pendulesimple}. The
input of this system is the momentum $u$ exerted on the pendulum
around its axis. The output is $y(t),$ the algebraic distance between
the mass $m$ and the vertical axis:

1) Determine the state equations of this system using the Newton law.

2) Express the mechanical energy $E_{m}$ in function of the state
of the system. Show that the latter remains constant when the momentum
$u$ is nil.

\begin{figure}[!h]
\centering \includegraphics[width=4cm]{pendulesimple} \caption{Simple pendulum with state vector $\mathbf{x}=\left(q,\dot{q}\right)$}

\label{fig:pendulesimple} 
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:hamilton} Hamilton's method \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/0LAGI-63-Nw}{https://youtu.be/0LAGI-63-Nw}} 

Hamilton's method allows us to obtain the state equations of a conservative
mechanical system (in other words whose energy is conserved) only
from the expression of a single function: its energy. For this, we
define the \emph{Hamiltonian} as the mechanical energy of the system,
in other words the sum of the potential energy and the kinetic energy.
The Hamiltonian can be expressed as a function $H\left(\mathbf{q},\mathbf{p}\right)$
of the degrees of freedom $\mathbf{q}$ and of the associated momentum
$\mathbf{p}$. The Hamilton equations are written as:
\[
\left\{ \begin{split}\mathbf{\dot{q}} & =\frac{\partial H\left(\mathbf{q},\mathbf{p}\right)}{\partial\mathbf{p}}\\
\mathbf{\dot{p}} & =-\frac{\partial H\left(\mathbf{q},\mathbf{p}\right)}{\partial\mathbf{q}}
\end{split}
\right.
\]

1) Let us consider the simple pendulum shown in Figure \ref{fig:pendulesimple0}.
This pendulum has a length of $\ell$ and is composed of a single
point mass $m$. Calculate the Hamiltonian of the system. Deduce the
state equations from this.

2) Show that if a system is described by Hamilton equations, then
the Hamiltonian is constant.

\begin{figure}[H]
\centering \includegraphics[width=4cm]{pendulesimple0} \caption{Simple pendulum as a conservative system}

\label{fig:pendulesimple0}
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:pendule_inverse} Dynamic modeling of
an inverted rod pendulum \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/ZI8EaNBDDp0}{https://youtu.be/ZI8EaNBDDp0}}

Let us consider the so-called \emph{inverted rod pendulum} system,
composed of a pendulum of length $\ell$ placed in an unstable equilibrium
on a carriage, as represented in Figure \ref{fig:pendule_inverse_model}.
The value $u$ is the force exerted on the carriage of mass $m_{c}$,
$s$ indicates the position of the carriage, $\theta$ is the angle
between the pendulum and the vertical axis and $\mathbf{r}$ is the
force exerted by the carriage on the pendulum. At the extremity $\mathbf{b}$
of the rod a point mass $m_{r}$ is fixated. We may ignore the mass
of the rod. Finally, \textbf{a} is the point of articulation between
the rod and the carriage and $\boldsymbol{\omega}=\dot{\theta}\mathbf{k}$
is the rotation vector associated with the rod.

\begin{figure}[H]
\centering \includegraphics[width=11cm]{pendule_inverse_model} \caption{Inverted rod pendulum}

\label{fig:pendule_inverse_model} 
\end{figure}

1) Write the fundamental principle of dynamics as applied on the carriage
and the pendulum.

2) Show that the speed vector at point $\mathbf{b}$ is expressed
by the relation $\dot{\mathbf{b}}=(\dot{s}-\dot{\theta}\cos\theta)\cdot\mathbf{i}-\dot{\theta}\sin\theta\cdot\mathbf{j}$.
Calculate the acceleration $\ddot{\mathbf{b}}$ of $\mathbf{b}$.

3) In order to model the inverted pendulum, we will take the state
vector $\mathbf{x}=\left(s,\theta,\dot{s},\dot{\theta}\right)$. Justify
this choice.

4) Find the state equations for the inverted rod pendulum.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:segway} Segway \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/u4cnGvygFPI}{https://youtu.be/u4cnGvygFPI}}

The segway represented on the left side of Figure \ref{fig:segway}
is a vehicle with two wheels and a single axle. It is stable since
it is controlled. In the modeling step, we will of course assume that
the engine is not controlled.

Its open loop behavior is very close to that of the planar unicycle
represented in Figure \ref{fig:segway} on the right hand side. In
this figure, $u$ represents the exerted momentum between the body
and the wheel.

The link between these two elements is a pivoting pin. We will denote
by $\mathbf{b}$ the center of gravity of the body and by $\mathbf{a}$
that of the wheel. $\mathbf{c}$ is a fix point on the disk. Let us
denote by $s$ the angle between the vector $\overrightarrow{\mathbf{ac}}$
and the horizontal axis and by $\theta$ the angle between the body
of the unicycle and the vertical axis. This system has two degrees
of freedom $s$ and $\theta$. The state of our system is given by
the vector $\mathbf{x}=(s,\theta,\dot{s},\dot{\theta})^{\text{T}}$.
The parameters are:
\begin{itemize}
\item for the disk: its mass $M$, its radius $\rho$, its moment of inertia
$J_{M}$ ;
\item for the pendulum: its mass $m$, its moment of inertia $J_{p}$, the
distance $\ell$ between its center of gravity and the center of the
disk. 
\end{itemize}
Find the state equations of the system.

\begin{figure}[H]
\centering \includegraphics[width=10cm]{segway} \caption{The segway has two wheels and an axle}

\label{fig:segway} 
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Modeling a car \label{ex:modele:voiture} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/b9iBhp56OF8}{https://youtu.be/b9iBhp56OF8}}

Let us consider the car as shown in Figure \ref{fig:robot4roues}.
The driver of the car (on the left hand side on the figure) has two
controls: the acceleration of the front wheels (assumed to be motorized)
and the rotation speed of the steering wheel. The brakes here represent
a negative acceleration. We will denote by $\delta$ the angle between
the front wheels and the axis of the car, by $\theta$ the angle made
by the car with respect to the horizontal axis and by $(x,y)$ the
coordinates of the middle of the rear axle. The state variables of
our system are composed of:
\begin{itemize}
\item the position coordinates, in other words all the knowledge necessary
to draw the car, more specifically the $x,y$ coordinates of the center
of the rear axle, the orientation $\theta$ of the car, and the angle
$\delta$ of the front wheels;
\item the kinetic coordinate $v$ representing the speed of the center of
the front axle (indeed, the sole knowledge of this value and the position
coordinates allows to calculate all the speeds of all the other elements
of the car). 
\end{itemize}
Calculate the state equations of the system. We will assume that the
two wheels have the same speed $v$ (even though in reality, the inner
wheel during a turn is slower than the outer one). Thus, as illustrated
on the right hand side figure, everything happens as if there were
only two virtual wheels situated at the middle of the axles.

\begin{figure}[!h]
\centering \includegraphics[width=10.3659cm,height=4.0681cm]{robot4roues}
\caption{Car moving on a plane (view from above)}

\label{fig:robot4roues} 
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:RLC} RLC circuit \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/yD6cwoUQBwI}{https://youtu.be/yD6cwoUQBwI}}

The electrical circuit of Figure \ref{fig:circuitrlc} has $u(t)$
as input the voltage and $y(t)$ as output the voltage. Find the state
equations of the system. Is this a linear system?

\begin{figure}[H]
\centering \includegraphics[width=11cm]{circuitRLC} \caption{Electrical circuit to be modeled}

\label{fig:circuitrlc}
\end{figure}
\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:moteur:cc} DC motor \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/GknV51O80z8}{https://youtu.be/GknV51O80z8}}

A direct current motor can be described by Figure \ref{fig:moteurdc},
in which $u$ is the supply voltage of the motor, $i$ is the current
absorbed by the motor, $R$ is the resistance, $L$ is the inductance,
$e$ is the electromotive force, $\rho$ is the coefficient of friction
in the motor, $\omega$ is the angular speed of the motor and $T_{r}$
is the torque exerted by the motor on the load.

\begin{figure}[H]
\centering \includegraphics[width=11cm]{moteurDC} \vspace*{2mm}
 \caption{Direct current motor}

\label{fig:moteurdc} 
\end{figure}

Recall the equations of an ideal direct current motor: $e=K\Phi\omega$
and $T=K\Phi i$. In the case of an induction-independent motor, or
a motor with permanent magnets, the flow $\Phi$ is constant. We are
going to put ourselves in this situation.

1) We take as inputs of the system $T_{r}$ and $u$. Find the state
equations ;

2) We connect a fan to the output of the system with a characteristic
of $T_{r}=\alpha\omega^{2}$. Give the new state equations of the
motor. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:trois:bacs} Water tanks \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/Nwacp2T2MLo}{https://youtu.be/Nwacp2T2MLo}}

Let us consider two containers placed as shown in Figure \ref{fig:deuxbacs}.
In the left container, the water flows without friction in the direction
of the right container. In the left container, the water flows in
a fluid way, as opposed to the right container, where there are turbulences.
These are turbulences which absorb the kinetic energy of the water
and transform it into heat. Without these turbulences, we would have
a perpetual back-and-forth movement of the water between the two containers. 

1) If $a$ is the cross-section of the canal, show the so-called \emph{Torricelli}'s
law which states that the water flow from the right container to the
left one is equal to:
\[
Q_{D}=a.sign\left(z_{A}-z_{B}\right)\sqrt{2g|z_{A}-z_{B}|}
\]

\begin{figure}[H]
\centering \includegraphics[width=8cm]{deuxbacs} \caption{Hydraulic system composed of two containers filled with water and
connected with a canal}

\label{fig:deuxbacs} 
\end{figure}

2) Let us now consider the system composed of three containers as
represented on Figure \ref{fig:troisbacs}.

\begin{figure}[H]
\centering \includegraphics[width=9.7cm]{troisbacs} \caption{System composed of three containers filled with water and connected
with two canals}

\label{fig:troisbacs} 
\end{figure}

The water from containers 1 and 3 can flow towards container 2, but
also towards the outside with atmospheric pressure. The state variables
of this system which may be considered are the heights of the containers.
In order to simplify, we will assume that the surfaces of the containers
are all equal to $1m^{2}$, thus the volume of water in a container
is interlinked with its height. Find the state equations describing
the dynamics of the system.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:fibonacci} Fibonacci sequence \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/T3lL1Pjy2xk}{https://youtu.be/T3lL1Pjy2xk}}

We will now study the evolution of the number $y(k)$ of rabbit couples
on a farm in function of the year $k$. At year $0$, there is only
a single couple of newly-born rabbits on the farm (and thus $y(0)=1$).
The rabbits only become fertile a year after their birth. It follows
that at year $1$, there is still a single couple of rabbits, but
this couple is fertile (and thus $y(1)=1$). A fertile couple gives
birth, each year, to another couple of rabbits. Thus, at year $2$,
there is a fertile couple of rabbits and a newly-born couple. This
evolution can be described by Table \ref{tab:rabbits}, where $N$
means \emph{newly-born} and $A$ means \emph{adult}.

\begin{table}[!h]
\centering{}{\small{}}%
\begin{tabular}{|l|l|l|l|l|}
\hline 
{\small{}$k=0$ } & {\small{}$k=1$ } & {\small{}$k=2$ } & {\small{}$k=3$ } & {\small{}$k=4$ }\tabularnewline
\hline 
{\small{}N } & {\small{}A } & {\small{}A } & {\small{}A } & {\small{}A }\tabularnewline
\hline 
 &  & {\small{}N } & {\small{}A } & {\small{}A }\tabularnewline
\hline 
 &  &  & {\small{}N } & {\small{}A }\tabularnewline
\hline 
 &  &  &  & {\small{}N }\tabularnewline
\hline 
 &  &  &  & {\small{}N }\tabularnewline
\hline 
\end{tabular}{\small{}\caption{{\small{}Evolution of the number of rabbits}}
\label{tab:rabbits}}
\end{table}

Let us denote by $x_{1}(k)$ the number of newly-born couples, by
$x_{2}(k)$ the number of fertile couples and by $y(k)$ the total
number of couples.

1) Give the state equations which govern the system ; 

2) Give the recurrence relation satisfied by $y(k)$. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:maxplus} Bus network \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/o4eEAhgxTa4}{https://youtu.be/o4eEAhgxTa4}}

We consider a public transport system of buses with $4$ lines and
$4$ buses. There are only two stations where travelers can change
lines. This system can be represented by a Petri net (see Figure \ref{fig:petri_bus1}).
Each token corresponds to a bus. The places $p_{1},p_{2},p_{3},p_{4}$
represent the lines. These places are composed of a number which corresponds
to the minimum amount of time that the token must remain in its place
(this corresponds to the transit time). The transitions $t_{1},t_{2}$
ensure synchronization. They are only crossed when each upstream place
of the transition has at least one token which has waited sufficiently
long. In this case, the upstream places lose a token and the downstream
places gain one. This structure ensures that the correspondence will
be performed systematically and that the buses will leave in pairs.

1) Let us assume that at time $t=0$, the transitions $t_{1}$ and
$t_{2}$ are crossed for the first time and that we are in the configuration
of Figure \ref{fig:petri_bus1} (this corresponds to the initialization).
Give the crossing times for each of the transitions.

\begin{figure}[H]
\centering \includegraphics[width=7.6311cm,height=2.5415cm]{petri_bus1}
\caption{Petri net of the bus system}

\label{fig:petri_bus1} 
\end{figure}

2) Let us denote by $x_{i}\left(k\right)$ the time when the transition
$t_{i}$ is crossed for the $k^{\text{th}}$ time. Show that the dynamics
of the model can be written using states:
\[
\mathbf{x}\left(k+1\right)=\mathbf{f}\left(\mathbf{x}\left(k\right)\right)
\]
where $\mathbf{x}=(x_{1},x_{2})^{\text{T}}$ is the state vector.
Remember that here $k$ is not the time, but an event number.

3) Let us now attempt to reformulate elementary algebra by redefining
the addition and multiplication operators (see \cite{Baccelli92})
as follows:
\[
\left\{ \begin{split}a\oplus b & =\max\left(a,b\right)\\
a\otimes b & =a+b
\end{split}
\right.
\]
Thus $2\oplus3=3$ whereas $2\otimes3=5$. Show that in this new algebra
(called max-plus), the previous system is linear. Discuss.

\chapter{Simulation\label{ch:simul}}

In this chapter, we will show how to perform a computer simulation
of a non-linear system described by its state equations: 
\[
\left\{ \begin{array}{ccc}
\mathbf{\dot{x}}(t) & = & \mathbf{f}(\mathbf{x}(t),\mathbf{u}(t))\\
\mathbf{y}(t) & = & \mathbf{g}(\mathbf{x}(t),\mathbf{u}(t))
\end{array}\right.
\]
This step is important in order to test the behavior of a system (controlled
or not). Before presenting the simulation method, we will introduce
the concept of vector fields. This concept will allow us to better
understand the simulation method as well as certain behaviors which
could appear in non-linear systems. We will also give several concepts
of graphics necessary for the graphical representation of our systems.

\section{Concept of vector field}

We will now present the concept of vector fields and show the manner
in which they are useful in order to better understand the various
behaviors of systems. We invite the reader to consult the book of
Khalil \cite{KhalilHassa2002} for further details on this subject.
A \emph{vector field} is a continuous function $\mathbf{f}$ of $\mathbb{R}^{n}$
to $\mathbb{R}^{n}.$ When $n=2$, a graphical representation of the
function $\mathbf{f}$ can be imagined. For instance, the vector field
associated with the linear function: 
\[
\mathbf{f}:\begin{array}{ccc}
\mathbb{R}^{2} & \rightarrow & \mathbb{R}^{2}\\
\left(\begin{array}{c}
x_{1}\\
x_{2}
\end{array}\right) & \rightarrow & \left(\begin{array}{c}
x_{1}+x_{2}\\
x_{1}-x_{2}
\end{array}\right)
\end{array}
\]
is illustrated in Figure \ref{fig:chpsvect}. In order to obtain this
figure, we have taken a set of vectors from the initial set, following
a grid. Then, for each grid vector $\mathbf{x}$, we have drawn its
image vector $\mathbf{f}($\textbf{$\mathbf{x}$}$)$ by giving it
the vector $\mathbf{x}$ as origin. 

\begin{figure}[!h]
\centering \includegraphics[width=8cm]{chpsvect} \caption{Vector field associated with a linear application}

\label{fig:chpsvect} 
\end{figure}

We may recognize on this figure the characteristic spaces (dotted
lines) of the linear application. We can also see that one eigenvalue
is positive and another one is negative. This can be verified by analyzing
the matrix of our linear application given by:
\[
\mathbf{A}=\left(\begin{array}{ccc}
1 &  & 1\\
1 &  & -1
\end{array}\right)
\]
Its eigenvalues are $\sqrt{2}$ and $-\sqrt{2}$ and the associated
eigenvectors are: 
\[
\mathbf{v}_{1}=\left(\begin{array}{c}
0.9239\\
0.3827
\end{array}\right)\text{ et }\mathbf{v}_{2}=\left(\begin{array}{c}
-0.3827\\
0.9239
\end{array}\right)
\]
Let us note that the vector $\mathbf{x}$ represented on the figure
is not an eigenvector since $\mathbf{x}$ and $\mathbf{f}$\textbf{$(\mathbf{x})$}
are not collinear. On the other hand, all the vectors that belong
to the characteristic subspaces (represented as dotted lines on the
figure) are eigenvectors. Along the characteristic subspace associated
with the negative eigenvalue, the field vectors tend to point towards
$\mathbf{0}$ whereas these vectors point to infinity along the characteristic
subspace associated with the positive eigenvalue.

For an autonomous system (i.e., without input), the evolution is given
by the equation $\mathbf{\dot{x}}(t)=\mathbf{f}(\mathbf{x}(t))$.
When $\mathbf{f}$ is a function of $\mathbb{R}^{2}$ to $\mathbb{R}^{2}$,
we can obtain a graphical representation of $\mathbf{f}$ by drawing
the vector field associated with $\mathbf{f}$. The graph will then
allow us to better understand the behavior of our system.

\section{Graphical representation}

\label{st:graphisme}

In this paragraph, we will give several concepts necessary for the
graphical representation of systems during simulations.

\subsection{Sketchs}

A \emph{sketch} is a matrix with two or three rows (following whether
the object is in the plane or in space) and $n$ columns which represent
the $n$ vertices of a shape-retaining polygon, meant to represent
the object. It is important that the unions of all the segments formed
by the two consecutive points of the sketch form the edges of the
polygon that we wish to represent. For instance, the sketch $\mathbf{M}$
of the chassis (see Figure \ref{fig:voituremotif}) of the car (with
the rear wheels) is given by: 
\[
\left(\begin{array}{rrrrrrrrrr}
-1 & 4 & 5 & 5 & 4 & -1 & -1 & 0 & 0 & -1\\
-2 & -2 & -1 & 1 & 2 & 2 & -2 & -2 & -3 & -3
\end{array}\begin{array}{rrrrrrrrrr}
1 & 0 & 0 & -1 & 1 & 0 & 0 & 3 & 3 & 3\\
-3 & -3 & 3 & 3 & 3 & 3 & 2 & 2 & 3 & -3
\end{array}\right)
\]
It is clear on the graph of the car in movement that the front wheels
can move with respect to the chassis, but also with respect to one
another. They therefore cannot be incorporated into the sketch of
the chassis. For the graph of the car, we will therefore have to use
$3$ sketches: that of the chassis, that of the left front wheel and
that of the right front wheel. 

\begin{figure}[!h]
\centering \includegraphics[width=4.5cm]{voituremotif} \caption{Car to be represented graphically}

\label{fig:voituremotif} 
\end{figure}


\subsection{Rotation matrix}

Let us recall that the $j^{\text{th}}$ column of the matrix of a
linear application of $\mathbb{R}^{n}\rightarrow\mathbb{R}^{n}\ $represents
the image of the $j^{\text{th}}$ vector $\mathbf{e}_{j}$ of the
standard basis. Thus, the expression of a rotation matrix of angle
$\theta$ in the plane $\mathbb{R}^{2}$ is given by (see Figure \ref{fig:rotation}):
\[
\mathbf{R}=\left(\begin{array}{ccc}
\cos\theta &  & -\sin\theta\\
\sin\theta &  & \cos\theta
\end{array}\right).
\]
\begin{figure}[!h]
\centering \includegraphics[width=11cm]{rotation} \caption{Rotation of angle $\theta$}

\label{fig:rotation} 
\end{figure}

Concerning rotations in the space $\mathbb{R}^{3}$, it is important
to specify the rotation axis. We can distinguish between $3$ main
rotations: the rotation of angle $\theta$ around the $Ox$ axis,
the one around the $Oy$ axis and the one around the $Oz$ axis. The
associated matrices are, respectively, given by: 
\[
\mathbf{R}_{x}=\left(\begin{array}{ccc}
1 & 0 & 0\\
0 & \cos\theta & -\sin\theta\\
0 & \sin\theta & \cos\theta
\end{array}\right),\ \mathbf{R}_{y}=\left(\begin{array}{ccc}
\cos\theta & 0 & \sin\theta\\
0 & 1 & 0\\
-\sin\theta & 0 & \cos\theta
\end{array}\right)\text{ et }\mathbf{R}_{z}=\left(\begin{array}{ccc}
\cos\theta & -\sin\theta & 0\\
\sin\theta & \cos\theta & 0\\
0 & 0 & 1
\end{array}\right)
\]


\subsection{Homogeneous coordinates \label{sst:coordonnees:homogenes}}

Drawing two-dimensional or three-dimensional objects on a screen requires
a series of affine transformations (rotations, translations, homotheties)
of the form: 
\[
\mathbf{f}_{i}:\begin{array}{lll}
\mathbb{R}^{n} & \rightarrow & \mathbb{R}^{n}\\
\mathbf{x} & \mapsto & \mathbf{A}_{i}\mathbf{x}+\mathbf{b}_{i}
\end{array}
\]
with $n=2$ or $3$. However, the manipulation of compositions of
affine functions is not as simple as that of linear applications.
The idea of the transformation into \emph{homogeneous coordinates}
is to transform a system of affine equations into a system of linear
equations. Let us note first of all that an affine equation of type
$\mathbf{y}=\mathbf{Ax}+\mathbf{b}$ can be re-written in the form:
\[
\left(\begin{array}{c}
\mathbf{y}\\
1
\end{array}\right)=\left(\begin{array}{ll}
\mathbf{A} & \mathbf{b}\\
0 & 1
\end{array}\right)\left(\begin{array}{c}
\mathbf{x}\\
1
\end{array}\right)
\]
We will therefore define the \emph{homogeneous transformation} of
a vector as follows: 
\[
\mathbf{x}\mapsto\mathbf{x}_{\text{h}}=\left(\begin{array}{c}
\mathbf{x}\\
1
\end{array}\right)
\]
Thus, an equation such as: 
\[
\mathbf{y}=\mathbf{A}_{3}\left(\mathbf{A}_{2}\left(\mathbf{A}_{1}\mathbf{x}+\mathbf{b}_{1}\right)+\mathbf{b}_{2}\right)+\mathbf{b}_{3}
\]
where there is a composition of $3$ affine transformations can be
re-written as: 
\[
\mathbf{y}_{\text{h}}=\left(\begin{array}{cc}
\mathbf{A}_{3} & \mathbf{b}_{3}\\
\mathbf{0} & 1
\end{array}\right)\left(\begin{array}{cc}
\mathbf{A}_{2} & \mathbf{b}_{2}\\
\mathbf{0} & 1
\end{array}\right)\left(\begin{array}{cc}
\mathbf{A}_{1} & \mathbf{b}_{1}\\
\mathbf{0} & 1
\end{array}\right)\mathbf{x}_{\text{h}}.
\]
Two transformation matrices are useful when dealing with 3D graphics
in homogeneous coordinates:
\begin{itemize}
\item The rotation around a vector $\boldsymbol{\omega}$ of an angle $\varphi=||\boldsymbol{\omega}||$
is given by
\begin{equation}
\text{Rot}(\boldsymbol{\omega})=\left(\begin{array}{ccc}
\exp\left(\begin{array}{ccc}
0 & -\omega_{z} & \omega_{y}\\
\omega_{z} & 0 & -\omega_{x}\\
-\omega_{y} & \omega_{x} & 0
\end{array}\right) &  & \left(\begin{array}{c}
0\\
0\\
0
\end{array}\right)\\
\left(\begin{array}{ccccc}
0 & \, & 0 & \, & 0\end{array}\right) &  & 1
\end{array}\right)\label{eq:rot3H}
\end{equation}
which corresponds to the \emph{Rodrigues' formula.} 
\item The translation matrix by a vector $\mathbf{v}$ of $\mathbb{R}^{3}$
is: 
\begin{equation}
\text{Tran}(\textbf{v})=\left(\begin{array}{ccccccc}
1 & \, & 0 & \, & 0 & \, & v_{1}\\
0 &  & 1 &  & 0 &  & v_{2}\\
0 &  & 0 &  & 1 &  & v_{3}\\
0 &  & 0 &  & 0 &  & 1
\end{array}\right)\label{eq:tran3H}
\end{equation}
\end{itemize}

\section{Simulation}

In this paragraph, we will present the integration method to perform
a computer simulation of a non-linear system described by its state
equations: 
\[
\left\{ \begin{array}{ccc}
\mathbf{\dot{x}}(t) & = & \mathbf{f}(\mathbf{x}(t),\mathbf{u}(t))\\
\mathbf{y}(t) & = & \mathbf{g}(\mathbf{x}(t),\mathbf{u}(t))
\end{array}\right.
\]
This method is rather approximative, but remains simple to understand
and is enough in order to describe the behaviors of most of robotized
systems.

\subsection{Euler's method}

Let $dt$ be a very small number compared to the time constants of
the system and which corresponds to the sampling period of the method
(for example $dt=0.01$). The evolution equation is approximated by:
\[
\begin{array}{ccc}
\frac{\mathbf{x}(t+dt)-\mathbf{x}(t)}{dt} & \simeq & \mathbf{f}(\mathbf{x}(t),\mathbf{u}(t))\end{array}
\]
in other words: 
\[
\mathbf{x}\left(t+dt\right)\simeq\mathbf{x}\left(t\right)+\mathbf{f}(\mathbf{x}(t),\mathbf{u}(t)).dt
\]
This equation can be interpreted as an order $1$ Taylor formula.
From this we can deduce the simulation algorithm (called \emph{Euler's
method}):

\begin{center}
\begin{tabular}{|cl|}
\hline 
 & $\textbf{\textbf{Algorithm}\ensuremath{\hspace{1cm}}\textsc{Euler}}(\mbox{in:}\textbf{ \ensuremath{\mathbf{x}_{0}}})$\tabularnewline
\hline 
1 & $\ensuremath{\mathbf{x}:=\mathbf{x}_{0};}\ensuremath{t:=0;\;dt=0.01;}$\tabularnewline
2 & repeat \tabularnewline
3 & $\hspace{1cm}$read the input $\mathbf{u}$ ;\tabularnewline
4 & $\hspace{1cm}\mathbf{y}:=\mathbf{g}(\mathbf{x,u})$;\tabularnewline
5 & $\hspace{1cm}$ return $\mathbf{y}$;\tabularnewline
6 & $\ensuremath{\hspace{1cm}\mathbf{x}:=\mathbf{x}+\mathbf{f}(\mathbf{x,u})\mathbf{.}dt\mathbf{;}}$\tabularnewline
7 & $\hspace{1cm}$wait for interrupt from timer;\tabularnewline
8 & $\hspace{1cm}$$t=t+dt$;\tabularnewline
9 & while true \tabularnewline
\hline 
\end{tabular}
\par\end{center}

The timer creates a periodic interrupt every $dt$ seconds. Thus,
if the computer is sufficiently fast, the simulation is performed
at the same speed as our physical system. We then refer to \emph{real-time}
simulation. In some circumstances, what we are interested in is obtaining
the result of the simulation in the fastest possible time (for instance
in order to predict how a system will behave in the future). In this
case, it is not necessary to slow the computer down in order to synchronize
it with our physical time.

We call \emph{local error} the quantity:
\[
e_{t}=||\mathbf{x}(t+dt)-\mathbf{\hat{x}}(t+dt)||\text{ with }\mathbf{x}(t)=\mathbf{\hat{x}}(t)
\]
where $\mathbf{x}(t+dt)$ is the exact solution of the differential
equation $\mathbf{\dot{x}}=\mathbf{f}(\mathbf{x},\mathbf{u})$ and
$\mathbf{\hat{x}}(t+dt)$ is the estimated value of the state vector,
for the integration scheme being used. For Euler's method, we can
show that $e_{t}$ is of order $1$, i.e. $e_{t}=O(dt)$.

\subsection{Runge-Kutta method}

There are more efficient integration methods in which the local error
is of order $2$ or more. This is the case of the Runge-Kutta method
of order $2$, which consists of replacing the recurrence $\mathbf{\hat{x}}(t+dt):=\mathbf{\hat{x}}(t)+\mathbf{f}\left(\mathbf{\hat{x}}(t),\mathbf{u}(t)\right).dt$
with:
\[
\mathbf{\hat{x}}(t+dt)=\mathbf{\hat{x}}(t)+dt.\left[\tfrac{1}{4}.\mathbf{f}\left(\mathbf{\hat{x}}(t),\mathbf{u}(t)\right)+\tfrac{3}{4}.\mathbf{f}(\underset{\mathbf{\hat{x}}_{E}(t+\frac{2}{3}dt)}{\underbrace{\mathbf{\hat{x}}(t)+\tfrac{2}{3}dt.\mathbf{f}(\mathbf{\hat{x}}(t),\mathbf{u}(t))}},\mathbf{u}(t+\tfrac{2}{3}dt))\right]
\]
Let us note in this expression the value $\mathbf{\hat{x}}_{E}(t+\frac{2}{3}dt)$
which can be interpreted as the integration obtained by Euler's method
at time $t+\frac{2}{3}dt$. The quantity between the square brackets
is an average between an estimation of $\mathbf{f}\left(\mathbf{x}(t),\mathbf{u}(t)\right)$
and an estimation of $\mathbf{f}\left(\mathbf{\hat{x}}(t+\tfrac{2}{3}dt),\mathbf{u}(t+\tfrac{2}{3}dt)\right)$.
The local error $e_{t}$ here is of order $2$ and the integration
method is therefore a lot more precise. There are Runge-Kutta methods
of order higher than $2$ which we will not discuss here.

\subsection{Taylor's method}

Euler's method (which is an order $1$ Taylor method) can be extended
to higher orders. Let us show, without loss of generality, how to
extend to second order. We have: 
\[
\mathbf{x}\left(t+dt\right)=\mathbf{x}\left(t\right)+\mathbf{\dot{x}}(t).dt+\frac{1}{2}\mathbf{\ddot{x}}(t).dt^{2}+o\left(dt^{2}\right)
\]
But:
\begin{align*}
\mathbf{\dot{x}}(t) & =\mathbf{f}(\mathbf{x}(t),\mathbf{u}(t))\\
\mathbf{\ddot{x}}(t) & =\frac{\partial\mathbf{f}}{\partial\mathbf{x}}(\mathbf{x}(t),\mathbf{u}(t)).\mathbf{\dot{x}}(t)+\frac{\partial\mathbf{f}}{\partial\mathbf{u}}(\mathbf{x}(t),\mathbf{u}(t)).\mathbf{\dot{u}}(t)
\end{align*}
Therefore, the integration scheme becomes:
\begin{multline*}
\mathbf{\hat{x}}(t+dt)=\mathbf{\hat{x}}(t)+dt.\mathbf{f}(\mathbf{\hat{x}}(t),\mathbf{u}(t))+\frac{1}{2}dt^{2}.\left(\frac{\partial\mathbf{f}}{\partial\mathbf{x}}(\mathbf{\hat{x}}(t),\mathbf{u}(t)).\mathbf{f}(\mathbf{\hat{x}}(t),\mathbf{u}(t))\right.\\
+\left.\frac{\partial\mathbf{f}}{\partial\mathbf{u}}(\mathbf{\hat{x}}(t),\mathbf{u}(t)).\mathbf{\dot{u}}(t)\right)
\end{multline*}


\chapter*{Exercises}

\begin{Exercice} \label{ex:champ_lotka} Prey-predator model \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/22OD0hPsz7w}{https://youtu.be/22OD0hPsz7w}}

The \emph{predator-prey} system, also called a Lotka-Volterra system,
is given by:
\[
\left\{ \begin{array}{ccc}
\dot{x}_{1}(t) & = & \left(1-x_{2}(t)\right)x_{1}(t)\\
\dot{x}_{2}(t) & = & \left(x_{1}(t)-1\right)x_{2}(t)
\end{array}\right.
\]
The state variables $x_{1}(t)$ and $x_{2}(t)$ represent the size
of the prey and predator populations. For example, $x_{1}$ could
represent the number of preys in millions whereas $x_{2}$ could be
the number of predators, in thousands. Even though the number of preys
and predators are integers, we will assume that $x_{1}$\ and $x_{2}$
are real values. The quadratic terms of this state equation represent
the interactions between the two species. Let us note that the preys
grow in an exponential manner when there are no predators. Similarly,
the population of predators declines when there is no prey.

1) Figure \ref{fig:volterra} corresponds to the vector field associated
with the evolution function: 
\[
\mathbf{f}(\mathbf{x})=\left(\begin{array}{c}
\left(1-x_{2}\right)x_{1}\\
\left(x_{1}-1\right)x_{2}
\end{array}\right)
\]
on the grid $[0,2]\times[0,2]$. Discuss the dynamic behavior of the
system using this figure.

2) Also using this figure, give the equilibrium point. Verify it through
calculation.

\begin{figure}[H]
\centering \includegraphics[width=8cm]{volterra} \caption{Vector field associated with the Lotka-Volterra system, in the plane
$(x_{1},x_{2})$}

\label{fig:volterra} 
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:champ_pendule}Simple pendulum \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/pzNEuLJmR6A}{https://youtu.be/pzNEuLJmR6A}}

Let us consider the simple pendulum of Figure \ref{fig:pendulesimple_x1x2}
described by the following state equations:
\[
\left\{ \begin{array}{lll}
\dot{x}_{1} & = & x_{2}\\
\dot{x}_{2} & = & -\sin x_{1}
\end{array}\right.
\]

\begin{figure}[H]
\centering \includegraphics[width=6cm]{pendulesimple_x1x2} \caption{Simple pendulum with state vector $\mathbf{x}=(x_{1},x_{2})=(\theta,\dot{\theta})$}
\label{fig:pendulesimple_x1x2}
\end{figure}

The vector field associated with the evolution function $\mathbf{f}(\mathbf{x})$
is drawn on Figure \ref{fig:pendulechp}.

\begin{figure}[!h]
\centering \includegraphics[width=10cm]{pendulechp} \caption{Vector field associated with the simple pendulum in the phase plane
$(x_{1},x_{2})=(\theta,\dot{\theta})$ }

\label{fig:pendulechp} 
\end{figure}

1) From the vector field, give the stable and unstable points of equilibrium. 

2) Program an Euler integration and draw the trajectory on the state
space.

3) Compare the Euler integration with a Runge-Kutta method.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:VanderPol} Van der Pol system \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/SlQrNliwHIc}{https://youtu.be/SlQrNliwHIc}}

Let us consider the system described by the following differential
equation:
\[
\ddot{y}+\left(y^{2}-1\right)\dot{y}+y=0
\]

1) Let us choose as state vector $\mathbf{x}=\left(y,\dot{y}\right)$.
Give the state equations of the system.

2) Linearize this system around the equilibrium point. What are the
poles of the system? Is the system stable around the equilibrium point?

3) The vector field associated with this system is represented on
Figure \ref{fig:vanderpol_champ} in the state space $\left(x_{1},x_{2}\right)$.
We initialize the system in $\mathbf{x}_{0}=\left(0.1,0\right)$.
Draw on the figure the path $\mathbf{x}\left(t\right)$ of the system
on the state space. Give the form of $y(t).$

4) Can a trajectory have a loop?

5) Simulate this system, with an Euler method and also with a Runge-Kutta
method. Compare both integration schemes. 

\begin{figure}[H]
\centering \includegraphics[width=8cm]{vanderpol_champ} \caption{Vector field associated with the Van der Pol system}

\label{fig:vanderpol_champ} 
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:simu:voiture}Simulation of a car \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/LV9QVSt8ll0}{https://youtu.be/LV9QVSt8ll0}}

Let us consider the car with the following state equations: 
\[
\left(\begin{array}{l}
\dot{x}\\
\dot{y}\\
\dot{\theta}\\
\dot{v}\\
\dot{\delta}
\end{array}\right)=\left(\begin{array}{c}
v\cos\delta\cos\theta\\
v\cos\delta\sin\theta\\
\frac{v\sin\delta}{L}\\
u_{1}\\
u_{2}
\end{array}\right)
\]
The state vector is given by $\mathbf{x}=\left(x,y,\theta,v,\delta\right)$,
where $x,y,\theta$ corresponds to the pose of the car (in other words
its position and orientation), $v$ is the speed and $\delta$ is
the angle of the front wheels. The parameter $L=3\text{m}$ is the
distance between the two axles of the car.

1) Using homogeneous coordinates, design a function which draws a
car in a state $\mathbf{x}=(x,y,\theta,v,\delta)^{\text{T}}$ 

2) Propose a program which simulates the dynamic evolution of this
car during $5~$seconds with Euler's method and a sampling step of
$0.01~\sec$. Take the initial state for the car as $\mathbf{x}\left(0\right)=\left(0,0,0,50,0\right),$
which means that at time $t=0$, the car is centered around the origin,
with a nil heading angle, a speed of $50ms^{-1}$ and the front wheels
parallel to the axis of the car. We assume that the vectorial control
$\mathbf{u}(t)$ remains constant and equal to $\left(0,\,0.05\right)$.
Which means that the car does not accelerate (since $u_{1}=0$) and
that the steering wheel is turning at a constant speed of $0.05\,\text{rad}\cdot\text{s}^{-1}$. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:integration:Taylor2} Integration by Taylor's
method \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/wtXp0RF8tfQ}{https://youtu.be/wtXp0RF8tfQ}}

Let us consider a robot described by the following state equations:
\[
\left(\begin{array}{l}
\dot{x}_{1}\\
\dot{x}_{2}\\
\dot{x}_{3}\\
\dot{x}_{4}\\
\dot{x}_{5}
\end{array}\right)=\left(\begin{array}{c}
x_{4}\cos x_{3}\\
x_{4}\sin x_{3}\\
x_{5}\\
u_{1}\\
u_{2}
\end{array}\right)
\]
1) Propose a second order integration scheme using Taylor's method.
The input is: 
\[
\mathbf{u}=\left(\begin{array}{c}
u_{1}\\
u_{2}
\end{array}\right)=\left(\begin{array}{c}
\cos t\\
\sin t
\end{array}\right).
\]

2) Simulate the car for $t\in[0,12],\,$with the three following integration
schemes: \emph{(i)} Euler, \emph{(ii)} Runge Kutta of order 2 and
\emph{(iii)} the Taylor of order 2. For the initial vector, we take
$\mathbf{x}(0)=(0,0,0,5,-\frac{1}{2})$ and the sampling time is taken
as $dt=0.05$s. Compare and discuss.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:motif:cube} Rotating cube \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/a1AwVPjyvkk}{https://youtu.be/a1AwVPjyvkk}}

Let us consider the three-dimensional cube $\left[0,1\right]\times\left[0,1\right]\times\left[0,1\right]$.

1) Give its sketch in matrix form.

2) What matrix operation must be performed in order to rotate it with
an angle $\theta$ around the $Ox$ axis?

3) Illustrate the rotation with a program where the cube turns with
time around the $Ox$ axis.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:simu:tricycle:matlab}Three-dimensional
simulation of a tricycle \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/BapNhAtJYe0}{https://youtu.be/BapNhAtJYe0}}

The driver of the tricycle of Figure \ref{fig:voiture3d} has two
controls: the acceleration of the front wheel $u_{1}$ and the rotation
rate $u_{2}$ of the steering angle $\delta$. The state variables
of our system are composed of 
\begin{itemize}
\item the degrees of freedom, \emph{i.e.}, the $x,y$ coordinates of the
center of the rear axle, the heading $\theta$ and the steering angle
$\delta$;
\item the speed $v$ of the center of the front wheel; 
\item the longitudinal angles of the wheels are $s_{1},s_{2},s_{3}$ 
\end{itemize}
The parameters are 
\begin{itemize}
\item the distance between the rear axle and the center of the front wheel:
$L=3$$\text{m}$; 
\item the distance between each rear wheel and the axis of the tricycle:
$e=2$m; 
\item the radius of the wheels is $r=0.5$m. 
\end{itemize}
1) Give the state equations of the three dimensional tricycle. 

2) Provide a program which draws the tricycle, at a given state. For
this, rotate and translate the sketch in 3D using the homogeneous
coordinates and Rodrigues' formula. 

3) Provide a simulation of the three-dimensional tricycle. 

\begin{figure}[H]
\centering \includegraphics[width=7.5cm]{voiture3d} \caption{Tricycle to be simulated}

\label{fig:voiture3d} 
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:bras:manipulateur}Manipulator robot \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/ig3E1Lyd-Fw}{https://youtu.be/ig3E1Lyd-Fw}}

The manipulator robot represented on Figure \ref{fig:bras} is composed
of three arms in series. The first one, of length $3$, can rotate
around the $Oz$ axis. The second, of length $2$, placed at the end
of the first one can also rotate around the $Oz$ axis. The third
one, of length $1$, placed at the end of the second, can rotate around
the axis formed by the second arm. This robot has $3$ degrees of
freedom $\mathbf{x}=\left(\alpha_{1},\alpha_{2},\alpha_{3}\right)$,
where the $\alpha_{i}$ represent the angles formed by each of the
arms. The basic sketch chosen to represent each of the arms if the
unit cube. Each arm is assumed to be a parallelepiped of thickness
0.3. In order to take the form of the arm, the sketch must be subjected
to transformation, represented by a diagonal matrix. Then, it has
to be rotated and translated in order to be correctly places. Design
a program that simulates this system, with a 3D vision inspired from
the figure.

\begin{figure}[H]
\centering \includegraphics[width=12cm]{bras} \caption{Manipulator robot composed of three arms}

\label{fig:bras} 
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Omni wheel robot \label{ex:robot:omni} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/sXmcNt5B5zQ}{https://youtu.be/sXmcNt5B5zQ}}

Let us consider the robot with three omni wheels shown on Figure \ref{fig:robot_suedois}.
An omni wheel is equipped with a multitude of small rollers over its
entire periphery which allow it to slide sideways (in other words
perpendicularly to its nominal movement direction). Let us denote
by $\mathbf{v}_{i}$ the speed vector of the contact point of the
$i^{th}$ wheel. If $\mathbf{i}_{i}$ is the normed direction vector
indicating the nominal movement direction of the wheel, then the component
of $\mathbf{v}_{i}$ according to $\mathbf{i}_{i}$ corresponds to
the rotation $\omega_{i}$ of the wheel whereas its complementary
component (perpendicular to $\mathbf{i}_{i}$) is linked to the rotation
of the peripheral rollers. If $r$ is the radius of the wheel, then
we have the relation $r\omega_{i}=-\left\langle \mathbf{v}_{i},\mathbf{i}_{i}\right\rangle $.
If $\mathbf{v}_{i}$ and $\mathbf{u}_{i}$ are collinear then the
wheel behaves like a classical wheel. If $\left\langle \mathbf{v}_{i},\mathbf{i}_{i}\right\rangle =0$,
the wheel no longer turns and it is in a state of skid.

\begin{figure}[H]
\centering \includegraphics[width=10.5cm]{robot_suedois} \caption{Holonomic robot with omni wheels}

\label{fig:robot_suedois}
\end{figure}

1) Show that 
\[
\begin{array}{cll}
\left(\begin{array}{c}
\omega_{1}\\
\omega_{2}\\
\omega_{3}
\end{array}\right) & = & \frac{1}{r}\left(\begin{array}{ccccc}
\sin\theta & \, & -\cos\theta & \, & -a\\
\sin(\theta+\frac{2\pi}{3}) &  & -\cos(\theta+\frac{2\pi}{3}) &  & -a\\
\sin(\theta-\frac{2\pi}{3}) &  & -\cos(\theta-\frac{2\pi}{3}) &  & -a
\end{array}\right)\left(\begin{array}{c}
\dot{x}\\
\dot{y}\\
\dot{\theta}
\end{array}\right)\end{array}
\]

2) Give the state equations of the system. We will use the state vector
$\mathbf{x}=\left(x,y,\theta,s_{1},s_{2},s_{3}\right)$ and the input
vector $\boldsymbol{\omega}=\left(\omega_{1},\omega_{2},\omega_{3}\right)$
where the $s_{i}$ are the proper angle of the wheels. Check the behavior
of the system using a 3D simulation.

3) Propose a loop which allows to obtain a model tank described by
the following state equations:
\[
\left\{ \begin{split}\dot{x} & =v\cos\theta\\
\dot{y} & =v\sin\theta\\
\dot{\theta} & =u_{1}\\
\dot{v} & =u_{2}
\end{split}
\right.
\]

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:simu:patineur}Snake \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/CwZRSnBfo8U}{https://youtu.be/CwZRSnBfo8U}}

\begin{figure}[H]
\centering \includegraphics[width=6.48cm,height=4.3471cm]{robot_snake}
\caption{Snake or Skating robot}

\label{fig:robot_snake} 
\end{figure}

The \emph{snake} is the skating vehicle represented in Figure \ref{fig:robot_snake}.
It is designed to move on a frozen lake and stands on 5 ice-skates
\cite{JaulinCifa2010}. This system has two inputs: the tangent $u_{1}$
of angle $\beta$ of the front skate we have chosen the tangent as
input in order to avoid singularities) and $u_{2}$ the torque exerted
on the articulation between the two sledges and which corresponds
to the angle $\delta$. The propulsion therefore only comes from the
torque $u_{2}$ and is similar to the mode of propulsion of a snake
or an eel \cite{Boyer:06}. Any control over $u_{1}$ therefore doesn't
give any energy to the system.

1) Show that the system can be described by the following state equations:
\[
\left\{ \begin{array}{ccc}
\dot{x} & = & v\cos\theta\\
\dot{y} & = & v\sin\theta\\
\dot{\theta} & = & vu_{1}\\
\dot{v} & = & -\left(u_{1}+\sin\delta\right)u_{2}-v\\
\dot{\delta} & = & -v\left(u_{1}+\sin\delta\right)
\end{array}\right.
\]
where $v$ is the speed of the center of the front axle. This is of
course a simplified and normalized model where, for reasons of simplicity,
the coefficients (masses, viscous friction, inter-axle distances,
etc.) have been chosen unitary.

2) Simulate this system by using Euler's method. Discuss.

3) We will now attempt to control this system using \emph{biomimicry},
i.e. by attempting to reproduce the propulsion of the snake. We choose
$u_{1}$ to be of the form:
\[
u_{1}=p_{1}\cos\left(p_{2}t\right)+p_{3}
\]
where $p_{1}$ is the amplitude, $p_{2}$ the pulse and $p_{3}$ the
bias. We choose $u_{2}$ so that the propulsion torque is always a
driving force, in other words $\dot{\delta}.u_{2}\geq0$. Indeed,
the term $\dot{\delta}.u_{2}$ corresponds to the power brought by
the robot which is transformed into kinetic energy. Program this control
and make the right choice for the parameters which allow to ensure
an efficient propulsion. Reproduce the two behaviors illustrated on
Figure \ref{fig:robot_snake_simu_reg} on your computer.

\begin{figure}[H]
\centering \includegraphics[width=10cm]{robot_snake_simu} \caption{Simulations of the controlled skating robot}

\label{fig:robot_snake_simu_reg} 
\end{figure}

4) Add a second control loop which controls the parameters $p_{i}$
of your controller in order for your robot to be able to follow a
desired heading $\bar{\theta}$.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:subcar}Swimbox \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/k37a_fM8pCs}{https://youtu.be/k37a\_fM8pCs}}

A \emph{swimbox} is an imaginary vehicle which swims horizontally
at the bottom of the ocean. The sea floor is assumed to be flat. The
swimbox has no propeller, but contains as a unique actuator a weight
that can move left and right. This is illustrated by Figure \ref{fig:subcar}
where 
\begin{itemize}
\item $u$ the reaction force on the weight made by the hull;
\item $x_{1}$ is the position of the hull;
\item $x_{2}\in[-1,1]$ is the position of the weight in the hull;
\item $v_{1}$ is the speed of the hull with respect the the sea floor;
\item $v_{2}$ is the speed of the weight with respect to the hull.
\end{itemize}
1) Assuming that all coefficients (mass, frictions, etc) taken as
1, show that a possible model for the system is given by
\[
\left(\begin{array}{l}
\dot{x}_{1}\\
\dot{x}_{2}\\
\dot{v}_{1}\\
\dot{v}_{2}
\end{array}\right)=\left(\begin{array}{c}
v_{1}\\
v_{2}\\
-u-v_{1}\cdot|v_{1}|\\
2u+v_{1}\cdot|v_{1}|
\end{array}\right)
\]

\begin{figure}[H]
\centering \includegraphics[width=10cm]{swimbox} \caption{The swimbox is composed of a hull and a weight. The weight (red) can
move horizontally}

\label{fig:subcar}
\end{figure}

2) Find a controller such that the swimbox swims forward for a long
distance always satisfying the constraint $x_{2}\in[-1,1]$. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:virus}Virus \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/Gghwa53kQNc}{https://youtu.be/Gghwa53kQNc}}

We consider a population of $N$ individuals. We want to study the
evolution of the virus in this population. We denote by 
\begin{itemize}
\item $x_{1}(t)$, the number of individuals not yet infected with the virus. 
\item $x_{2}(t)$, the number of infected individuals. All of them are capable
of spreading the disease.
\item $x_{3}(t),$ the individuals that have been cured from the virus.
Those in this category will not be infected again or transmit the
virus to others.
\end{itemize}
For simplicity, we consider that a the time unit for $t$ is in days.
We assume that
\begin{itemize}
\item \textbf{(A1)} an individual in the population not yet infected has
a probability to become infected at each unit of time which is proportional
to the density of infected individuals. 
\item \textbf{(A2)} an individual which is infected at time $t$ has a constant
probability to become cured at time $t+dt$.
\end{itemize}
1) Find state equations for a model describing the evolution of the
system. This model has two parameters related to the assumptions. 

2) We assume that 
\begin{itemize}
\item \textbf{(A3)}. If a not-yet-infected individual lives among a population
which is completely infected, then the probability to be infected
at time $t+dt$ is $0.3\cdot dt$. 
\item \textbf{(A4)}. If one individual is infected at time $t$, then, it
has a probability of $0.1\cdot dt$ to be cured at time $t+dt$.
\end{itemize}
Identify the parameters of the state-space model.

3) When $t\rightarrow\infty$, can we know what is the percentage
of the population that will never been infected ? 

4) Assume that at time $t=0$, we have one infected individual for
a population of $10^{8}$ persons. Using a simulation, predict at
which time the peak (the maximum for $x_{2}$) occurs. 

5) Draw the trajectory in the $(x_{1},x_{2})$ with the corresponding
vector field. Discuss.

\chapter{Linear systems \label{ch:syslin}}

The study of linear systems \cite{Bourles06} is fundamental for the
proper understanding of the concepts of stability\index{stability}
and the design of linear controllers. Let us recall that linear systems
are of the form: 
\[
\left\{ \begin{array}{ccc}
\mathbf{\dot{x}}(t) & = & \mathbf{Ax}(t)+\mathbf{Bu}(t)\\
\mathbf{y}(t) & = & \mathbf{Cx}(t)+\mathbf{Du}(t)
\end{array}\right.
\]
for continuous-time systems and: 
\[
\left\{ \begin{array}{ccc}
\mathbf{x}(k+1) & = & \mathbf{Ax}(k)+\mathbf{Bu}(k)\\
\mathbf{y}(k) & = & \mathbf{Cx}(k)+\mathbf{Du}(k)
\end{array}\right.
\]
for discrete-time systems. This chapter introduces the notion of stability
and makes the link between a state space representation and the more
classical transfer approach.

\section{Stability}

\label{st:stabilite}

A system of the form $\mathbf{\dot{x}}=\mathbf{f}(\mathbf{x})$ is
\emph{stable} if, after a sufficiently long amount of time, the state
no longer depends on the initial conditions, no matter what they are.
The definition by Lyapunov formalizes the stability as follows. The
system is \emph{stable} if for every $\varepsilon>0$, there exists
$\delta>0$ such that 
\begin{equation}
\|\mathbf{x}(0)\|<\delta\Rightarrow\forall t\geq0,\|\mathbf{x}(t)\|<\varepsilon.
\end{equation}
The system is \emph{asymptotically stable} if it is \emph{Lyapunov
stable} and there exists $\delta>0$ such that 
\begin{equation}
\|\mathbf{x}(0)\|<\delta\Rightarrow\lim_{t\rightarrow\infty}\|\mathbf{x}(t)\|=0.
\end{equation}
The same definitions are also valid when the time is discrete. In
the case of linear systems, the asymptotic stability translates into:
\[
\begin{array}{ll}
\lim_{t\rightarrow\infty}e^{\mathbf{A}t}=\mathbf{0}_{n} & \text{if the system is continuous-time}\\
\lim_{k\rightarrow\infty}\mathbf{A}^{k}=\mathbf{0}_{n} & \text{if the system is discrete-time}
\end{array}
\]
In this expression we can see the concept of \emph{matrix exponential}.
The exponential of a square matrix $\mathbf{M}$ of dimension $n$
can be defined through its power series development: 
\[
e^{\mathbf{M}}=\mathbf{I}_{n}+\mathbf{M}+\frac{1}{2!}\mathbf{M}^{2}+\frac{1}{3!}\mathbf{M}^{3}+\dots=\sum_{i=0}^{\infty}\frac{1}{i!}\mathbf{M}^{i}
\]
where $\mathbf{I}_{n}$ is the identity matrix of dimension $n$.
It is clear that $e^{\mathbf{M}}$ is of the same dimension as $\mathbf{M}$.
Here are some of the important properties concerning the exponentials
of matrices. If $\mathbf{0}_{n}$ is the zero matrix of $n\times n$
and if $\mathbf{M}$ and $\mathbf{N}$ are two matrices $n\times n$,
then: 
\[
\begin{array}{l}
e^{\mathbf{0}_{n}}=\mathbf{I}_{n}\\
e^{\mathbf{M}}.e^{\mathbf{N}}=e^{\mathbf{M}+\mathbf{N}}\text{ (if the matrices commute)}\\
\frac{d}{dt}\left(e^{\mathbf{M}t}\right)=\mathbf{M}e^{\mathbf{M}t}
\end{array}
\]
\textsc{Criterion of stability}.\textendash{} There is a criterion
of stability which only depends on the matrix $\mathbf{A}.$ A continuous-time
linear system is stable if and only if all the eigenvalues of its
evolution matrix $\mathbf{A}$ have strictly negative real parts.
A discrete-time linear system is stable if and only if all the eigenvalues
of $\mathbf{A}$ are strictly inside the unit circle. This corresponds
to the criterion of stability as proven in Exercise \ref{ex:critere:stab}.

\noindent Whether it is for continuous-time or discrete-time linear
systems, the position of the eigenvalues of $\mathbf{A}$ is of paramount
importance in the study of stability of a linear system. The \emph{characteristic
polynomial} of a linear system is defined as the characteristic polynomial
of the matrix $\mathbf{A}$ which is given by the formula: 
\[
P(s)=\det\left(s\mathbf{I}_{n}-\mathbf{A}\right)
\]
Its roots are the eigenvalues of $\mathbf{A}$. Indeed, if $s$ is
a root of $P(s)$, then $\det\left(s\mathbf{I}_{n}-\mathbf{A}\right)=0,$
in other words there is a vector $\mathbf{v}$ non-nil such that $\left(s\mathbf{I}_{n}-\mathbf{A}\right)\mathbf{v}=\mathbf{0}$.
This means that $s\mathbf{v}-\mathbf{Av}=\mathbf{0}$ or $\mathbf{Av}=s\mathbf{v}$.
Therefore $s$ is an eigenvalue of $\mathbf{A}$. A corollary of the
stability criterion is thus the following.

\noindent \textsc{Corollary}.\textendash{} A continuous-time linear
system is stable if and only if all the roots of its characteristic
polynomial have negative real parts. A discrete-time linear system
is stable if and only if all the roots of its characteristic polynomial
are inside the unit circle.

\section{Laplace transform}

The \emph{Laplace transform} is a very useful tool for the control
engineer in the manipulation of systems described by differential
equations. This approach is particularly utilized in the context of
monovariate systems (i.e. systems with a single input and output)
and may be regarded as a competitor to the state-representation approach
considered in this book.

\subsection{Laplace variable}

The space of differential operators in $\frac{d}{dt}$ is a ring and
has favorable properties such as associativity. For example:
\[
\frac{d^{4}}{dt^{4}}\left(\frac{d^{3}}{dt^{3}}+\frac{d}{dt}\right)=\frac{d^{4}}{dt^{4}}\frac{d^{3}}{dt^{3}}+\frac{d^{4}}{dt^{4}}\frac{d}{dt}=\frac{d^{7}}{dt^{7}}+\frac{d^{5}}{dt^{5}}
\]
This ring is commutative. For example: 
\[
\frac{d^{4}}{dt^{4}}\left(\frac{d^{3}}{dt^{3}}+\frac{d}{dt}\right)=\left(\frac{d^{3}}{dt^{3}}+\frac{d}{dt}\right)\frac{d^{4}}{dt^{4}}
\]
We may associate with the operator $\frac{d}{dt}$ the symbol $s$
called \emph{Laplace variable}. Thus the operator $\frac{d^{4}}{dt^{4}}\left(\frac{d^{3}}{dt^{3}}+\frac{d}{dt}\right)$
will be represented by the polynomial $s^{4}\left(s^{3}+s\right)$.

\subsection{Transfer function}

Let us consider a linear system with input $u$ and output $y$ described
by a differential relation such as:
\[
y(t)=H\left(\frac{d}{dt}\right)\cdot u(t)
\]
The function $H(s)$ is called the transfer function of the system.
Let us take for instance the system described by the differential
equation:
\[
\ddot{y}+2\dot{y}+3y=4\dot{u}-5u
\]
We have:
\[
y(t)=\left(\frac{4\frac{d}{dt}-5}{\frac{d^{2}}{dt^{2}}+2\frac{d}{dt}+3}\right)\cdot u(t)
\]
Its transfer function is therefore:
\[
H(s)=\frac{4s-5}{s^{2}+2s+3}
\]
If the transfer function $H(s)$ of a system is a rational function,
its denominator $P(s)$ is called the \emph{characteristic polynomial}.

\subsection{Laplace transform}

We call \emph{Laplace transform} $\hat{y}(s)$ of the signal $y(t)$
the transfer function of the system which generates $y(t)$ from the
Dirac delta function $\delta(t)$. We will denote it by $\hat{y}(s)=\mathcal{L}\left(y(t)\right)$.
We also say that $y\left(t\right)$ is the \emph{impulse response}
of the system. The table below shows several systems together with
their transfer function and impulse response.

\begin{table}[!h]
{\small{}\centering }%
\begin{tabular}{|c|c|c|c|}
\hline 
\textbf{\small{}System}{\small{} } & \textbf{\small{}Equation}{\small{} } & \textbf{\small{}Transfer function}{\small{} } & \textbf{\small{}Impulse response}{\small{} }\tabularnewline
\hline 
{\small{}Identity } & {\small{}$y\left(t\right)=u\left(t\right)$ } & {\small{}$1$ } & {\small{}$\delta\left(t\right)$ }\tabularnewline
\hline 
{\small{}Integrator } & {\small{}$\dot{y}\left(t\right)=u\left(t\right)$ } & {\small{}$\frac{1}{s}$ } & {\small{}$E\left(t\right)$\ (step) }\tabularnewline
\hline 
{\small{}Differentiator } & {\small{}$y\left(t\right)=\dot{u}\left(t\right)$ } & {\small{}$s$ } & {\small{}$\dot{\delta}\left(t\right)$ }\tabularnewline
\hline 
{\small{}Delay } & {\small{}$y\left(t\right)=u\left(t-\tau\right)$ } & {\small{}$e^{-\tau s}$ } & {\small{}$\delta\left(t-\tau\right)$ }\tabularnewline
\hline 
\end{tabular}{\small{}\caption{{\small{}Transfer function and impulse response of some elementary
systems}}
}
\end{table}

In this table, $E\left(t\right)$ is the unit step which is equal
to $1$ if $t\geq0$ and $0$ otherwise. Thus, the Laplace transforms
of $\delta\left(t\right),E\left(t\right),\dot{\delta}\left(t\right),\delta(t-\tau)$
are respectively $1,\frac{1}{s},s,e^{-\tau s}$. 
\begin{rem}
The transfer function of the delay comes from the relation
\[
y(t)=\sum_{i=0}^{\infty}\frac{y^{(i)}(t_{0})}{i!}\left(t-t_{0}\right)^{i}
\]
If we take $\tau=t_{0}-t$, the relation translates into
\[
y(t)=\sum_{i=0}^{\infty}\frac{y^{(i)}(\tau+t)}{i!}(-\tau)^{i}
\]
Since $y\left(t\right)=u\left(t-\tau\right)$, or equivalently $y(t+\tau)=u(t)$,
we get 
\[
\begin{array}{cclll}
y(t) & = & \sum_{i=0}^{\infty}\frac{u^{(i)}(t)}{i!}(-\tau)^{i} & = & \sum_{i=0}^{\infty}\frac{(-\tau)^{i}}{i!}\frac{d^{i}}{dt^{i}}u(t)\\
 & = & \left(\sum_{i=0}^{\infty}\frac{1}{i!}\left(-\tau\cdot\frac{d}{dt}\right)^{i}\right)\cdot u(t) & = & e^{-\tau\cdot\frac{d}{dt}}\cdot u(t)\\
 & = & e^{-\tau s}\cdot u(t)
\end{array}
\]
 
\end{rem}
But we can go further, as is shown on the following table.

\begin{table}[!h]
\centering{}{\small{}}%
\begin{tabular}{|c|c|c|}
\hline 
\textbf{\small{}Equation}{\small{} } & \textbf{\small{}Transfer function}{\small{} } & \textbf{\small{}Impulse response}{\small{} }\tabularnewline
\hline 
{\small{}$y\left(t\right)=\alpha_{1}u\left(t-\tau_{1}\right)+\alpha_{2}u\left(t-\tau_{2}\right)$ } & {\small{}$\alpha_{1}e^{-\tau_{1}s}+\alpha_{2}e^{-\tau_{2}s}$ } & {\small{}$\alpha_{1}\delta\left(t-\tau_{1}\right)+\alpha_{2}\delta\left(t-\tau_{2}\right)$ }\tabularnewline
\hline 
{\small{}$y\left(t\right)=\sum_{i=0}^{\infty}\alpha_{i}u\left(t-\tau_{i}\right)$ } & {\small{}$\sum_{i=0}^{\infty}\alpha_{i}e^{-\tau_{i}s}$ } & {\small{}$\sum_{i=0}^{\infty}\alpha_{i}\delta(t-\tau_{i})$ }\tabularnewline
\hline 
{\small{}$y\left(t\right)=\int_{-\infty}^{\infty}f(\tau)u\left(t-\tau\right)d\tau$ } & {\small{}$\int_{-\infty}^{\infty}f(\tau)e^{-\tau s}d\tau$ } & {\small{}$\int_{-\infty}^{\infty}f(\tau)\delta(t-\tau)d\tau$ }\tabularnewline
\hline 
\end{tabular}{\small{}\caption{{\small{}Transfer function and impulse response of composed systems}}
}
\end{table}

The operation $y\left(t\right)=\int_{-\infty}^{\infty}f(\tau)u\left(t-\tau\right)$
is called \emph{convolution}.\emph{\ }We may notice that the impulse
response of the system described by the last row of the table is:
\[
y\left(t\right)=\left.\int_{-\infty}^{\infty}f(\tau)u\left(t-\tau\right)d\tau\right\vert _{u\left(t\right)=\delta\left(t\right)}=\int_{-\infty}^{\infty}f(\tau)\delta\left(t-\tau\right)d\tau=f(t)
\]
Therefore, the Laplace transform of a function $f\left(t\right)$
is:
\[
\hat{f}\left(s\right)=\int_{-\infty}^{\infty}f(\tau)e^{-\tau s}d\tau
\]
Let us note that the relation: 
\[
f(t)=\int_{-\infty}^{\infty}f(\tau)\delta(t-\tau)d\tau
\]
illustrates the fact that $f\left(t\right)$ can be estimated by the
sum of an infinity of infinitely approached Dirac distributions.

\subsection{Input-output relation}

Let us consider a system with input $u$, output $y$ and transfer
function $H(s)$, as in Figure \ref{fig:systsimple}.

\begin{figure}[!h]
\centering \includegraphics[width=4.5cm]{systsimple} \caption{Laplace transform and transfer function}

\label{fig:systsimple} 
\end{figure}

We have: 
\[
y(t)=H(\frac{d}{dt}).u(t)=~\underset{\hat{y}\left(\frac{d}{dt}\right)}{\underbrace{H(\frac{d}{dt}).\hat{u}\left(\frac{d}{dt}\right)}}\cdot\delta(t)
\]
Therefore, the Laplace transform of $y(t)$ is:
\[
\hat{y}(s)=H(s)\cdot\hat{u}(s)
\]


\section{Relationship between state and transfer representations}

Let us consider the system described by its state equations:
\[
\left\{ \begin{array}{lll}
\mathbf{\dot{x}} & = & \mathbf{Ax}+\mathbf{Bu}\\
\mathbf{y} & = & \mathbf{Cx}+\mathbf{Du}
\end{array}\right.
\]
The Laplace transform of the state representation is given by: 
\[
\left\{ \begin{array}{ccc}
s\mathbf{\hat{x}} & = & \mathbf{A\hat{x}}+\mathbf{B\hat{u}}\\
\mathbf{\hat{y}} & = & \mathbf{C\hat{x}}+\mathbf{D\hat{u}}
\end{array}\right.
\]
The first equation can be re-written as $s\mathbf{\hat{x}}-\mathbf{A\hat{x}}=\mathbf{B\hat{u}}$,
i.e. $s\mathbf{I\hat{x}}-\mathbf{A\hat{x}}=\mathbf{B\hat{u}},$ where
$\mathbf{I}$ is the identity matrix. From this, by factoring, we
get $\left(s\mathbf{I}-\mathbf{A}\right)\mathbf{\hat{x}}=\mathbf{B\hat{u}}$
(we must be careful, a notation such as $s\mathbf{\hat{x}}-\mathbf{A\hat{x}}$
$=$ $\left(s-\mathbf{A}\right)\mathbf{\hat{x}}$ is not permitted
since $s$ is a scalar whereas $\mathbf{A}$ is a matrix). Therefore:
\[
\left\{ \begin{array}{ccc}
\mathbf{\hat{x}} & = & (s\mathbf{I}-\mathbf{A})^{-1}\mathbf{B\hat{u}}\\
\mathbf{\hat{y}} & = & \mathbf{C\hat{x}}+\mathbf{D\hat{u}}
\end{array}\right.
\]
And thus: 
\[
\mathbf{\hat{y}}=\left(\mathbf{C}(s\mathbf{I}-\mathbf{A})^{-1}\mathbf{B}+\mathbf{D}\right)\mathbf{\hat{u}}
\]
The matrix: 
\[
\mathbf{G}(s)=\mathbf{C}(s\mathbf{I}-\mathbf{A})^{-1}\mathbf{B}+\mathbf{D}
\]
is called \emph{transfer matrix}. It is a matrix of \emph{transfer
functions} (in other words of rational functions in $s$) in which
every denominator is a divisor of the characteristic polynomial $P_{\mathbf{A}}\left(s\right)$
of $\mathbf{A}$. By multiplying each side by $P_{\mathbf{A}}(s)$
and replacing $s$ by $\frac{d}{dt}$ we obtain a system of input-output
differential equations. The state $\mathbf{x}$ will no longer appear
there.

Reciprocally, in the case of \emph{monovariate} linear systems (in
other words with a single input and a single output), we can obtain
a state representation from an expression of the transfer function,
as it will be illustrated in Exercises \ref{ex:forme:canonique:commande},
\ref{ex:forme:canonique:obs} and \ref{ex:forme:modale}.

\chapter*{Exercises}

\begin{Exercice} \label{ex:sol:eq:etat}Solution of a state equation
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/l0accPUnKZw}{https://youtu.be/l0accPUnKZw}}

1) Show that the continuous-time linear system
\[
\begin{array}{ccc}
\mathbf{\dot{x}}(t) & = & \mathbf{Ax}(t)+\mathbf{Bu}(t)\end{array}
\]
has the solution 
\[
\mathbf{x}(t)=e^{\mathbf{A}t}\mathbf{x}(0)+\int_{0}^{t}e^{\mathbf{A}(t-\tau)}\mathbf{Bu}(\tau)d\tau.
\]
The function $e^{\mathbf{A}t}\mathbf{x}(0)$ is called \emph{homogeneous},
\emph{free} or \emph{transient solution}. The function $\int_{0}^{t}e^{\mathbf{A}(t-\tau)}\mathbf{Bu}(\tau)d\tau$
is called \emph{forced solution}.

2) Show that the discrete-time linear system
\[
\mathbf{x}(k+1)=\mathbf{Ax}(k)+\mathbf{Bu}(k)
\]
has the solution 
\[
\mathbf{x}(k)=\mathbf{A}^{k}\mathbf{x}(0)+\sum_{\ell=0}^{k-1}\mathbf{A}^{k-\ell-1}\mathbf{Bu}(\ell).
\]
Again, $\mathbf{A}^{k}\mathbf{x}(0)$ is \emph{homogeneous solution}
and $\sum_{\ell=0}^{k}\mathbf{A}^{k-\ell}\mathbf{Bu}(\ell)$ is the
\emph{forced solution}.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:critere:stab} Stability criterion \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/PXO2ojcMpt0}{https://youtu.be/PXO2ojcMpt0}}

The proof of the stability criterion for linear systems is based on
the theorem of correspondence of the eigenvalues which is articulated
as follows. If $f$ is a polynomial (or more generally an integer
series) and if $\mathbf{A}$ is an $\mathbb{R}^{n\times n}$ matrix
then the eigenvectors of $\mathbf{A}$ are also eigenvectors of $f(\mathbf{A})$.
Moreover if the eigenvalues of $\mathbf{A}$ are $\left\{ \lambda_{1},\dots,\lambda_{n}\right\} $
then those of $f(\mathbf{A})$ are $\left\{ f\left(\lambda_{1}\right),\dots,f(\lambda_{n})\right\} .$

1) Prove the theorem of correspondence of the eigenvalues in the case
where $f$ is a polynomial.

2) Let spec$\left(\mathbf{A}\right)=\left\{ \lambda_{1},\dots,\lambda_{n}\right\} $
be the spectrum of $\mathbf{A}$, i.e. its eigenvalues. By using the
theorem of correspondence of the eigenvalues, calculate spec$\left(\mathbf{I}+\mathbf{A}\right),$
spec$\left(\mathbf{A}^{k}\right)$, spec$\left(e^{\mathbf{A}t}\right)$
and spec$\left(f\left(\mathbf{A}\right)\right)$. In these expressions,
$\mathbf{I}$ denotes the identity matrix, $k$ an integer and $f$
the characteristic polynomial of $\mathbf{A}$.

3) Show that if a continuous-time linear system is stable then all
the eigenvalues of its evolution matrix $\mathbf{A}$ have strictly
negative real parts (in fact, the condition is necessary and sufficient,
but we will limit the proof to the implication).

4) Show that if a discrete-time linear system is stable then all the
eigenvalues of $\mathbf{A}$ are strictly within the unit circle.
Again, even though we have the equivalence here, we will limit ourselves
to the proof of the implication. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:variable:laplace}Laplace variable \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/SRoMKIjl90g}{https://youtu.be/SRoMKIjl90g}}

Let us consider two systems in parallel as illustrated in Figure \ref{fig:laplace_motiv}.

\begin{figure}[!h]
\centering \includegraphics[width=6.9611cm,height=2.6733cm]{laplace_motiv}
\caption{Two linear systems interconnected in parallel}

\label{fig:laplace_motiv} 
\end{figure}

1) Without employing the Laplace transform, and by only using elementary
differential calculus, give a differential equation which links $u$
with $y$.

2) Using algebraic manipulations involving the $\frac{d}{dt}$ operator,
obtain the same differential equation again.

3) Obtain the same result by using the Laplace variable $s$. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:fct:transfert:simple}Transfer functions
of elementary systems\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/ibOfo-PixlY}{https://youtu.be/ibOfo-PixlY}}

Give the transfer function of the following systems with input $u$
and output $y$: 

1) a differentiator expressed by the differential equation $y=\dot{u}$; 

2) an integrator which obeys the differential equation $\dot{y}=u$; 

3) a delay of $\tau$ which is expressed by the input-output relation
$y(t)=u(t-\tau)$. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:laplace:composition}Transfer function
of composite systems \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/_L4wGYU1xhg}{https://youtu.be/\_L4wGYU1xhg}} 

1) Let us consider two systems of transfer functions $H_{1}(s)$ and
$H_{2}(s)$ placed in series as shown on Figure \ref{fig:systserie}.

\begin{figure}[!h]
\centering \includegraphics[width=7cm]{systserie} \caption{Two systems in series}

\label{fig:systserie} 
\end{figure}

Calculate, in function of $H_{1}(s)$ and $H_{2}(s)$, the transfer
function of the composite system.

2) Let us place the two systems of transfer functions $H_{1}(s)$
and $H_{2}(s)$ in parallel as shown on Figure \ref{fig:systparal}.

\begin{figure}[!h]
\centering \includegraphics[width=7cm]{systparal} \caption{Two systems in parallel}

\label{fig:systparal} 
\end{figure}

Give, in function of $H_{1}(s)$ and $H_{2}(s)$, the transfer function
of the composite system.

3) Let us loop the system $H(s)$ as shown on Figure \ref{fig:systboucle}. 

\begin{figure}[!h]
\centering \includegraphics[width=6.5cm]{systboucle} \caption{Looped system}

\label{fig:systboucle} 
\end{figure}

Give, in function of $H(s)$, the transfer function of the looped
system.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:mat:transfert} Transfer matrix \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/O7U57PztbGk}{https://youtu.be/O7U57PztbGk}} 

Let us consider the continuous-time linear system described by its
state representation: 
\[
\left\{ \begin{array}{lllllll}
\mathbf{\dot{x}}(t) & = & \left(\begin{array}{ccc}
1 &  & 3\\
2 &  & 0
\end{array}\right) & \mathbf{x}(t) & + & \left(\begin{array}{c}
1\\
1
\end{array}\right) & u(t)\\
\mathbf{y}(t) & = & \left(\begin{array}{lcl}
1 &  & 2\\
1 &  & 0
\end{array}\right) & \mathbf{x}(t) & + & \left(\begin{array}{c}
2\\
0
\end{array}\right) & u(t)
\end{array}\right.
\]

1) Calculate its transfer matrix.

2) Give a differential relation which links the input to the outputs. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:change:base} Change of basis \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/c6j2TFPoiVw}{https://youtu.be/c6j2TFPoiVw}}

Let us consider the continuous-time linear system described by its
state equations: 
\[
\left\{ \begin{array}{lll}
\mathbf{\dot{x}} & = & \mathbf{Ax}+\mathbf{Bu}\\
\mathbf{y} & = & \mathbf{Cx}+\mathbf{Du}
\end{array}\right.
\]
Let us take the change of basis $\mathbf{v}=\mathbf{P}^{-1}\mathbf{x}$,
where $\mathbf{P}$ is a transfer matrix (i.e., square and invertible). 

1) What do the system equations become if $\mathbf{v}$ is the new
state vector ?

2) Let us consider the system described by the following state equations:
\[
\left\{ \begin{array}{lll}
\mathbf{\dot{x}} & = & \left(\begin{array}{ccccc}
4 &  & -\frac{1}{2} &  & -\frac{1}{2}\\
4 &  & 1 &  & -1\\
4 &  & -2 &  & 2
\end{array}\right)\mathbf{x}+\left(\begin{array}{c}
1\\
2\\
4
\end{array}\right)u\\
y & = & \left(\begin{array}{lclcl}
2 &  & 1 &  & 1\ \end{array}\right)\mathbf{x}
\end{array}\right.
\]
We are trying to find a simpler representation, i.e. with more zeros
and ones (in order for instance to limit the number of components
necessary in the design of the circuitry). We propose to take the
following change of basis: 
\[
\mathbf{v}=\left(\begin{array}{lll}
1 & 1 & 1\\
2 & 1 & 2\\
2 & 1 & 0
\end{array}\right)^{-1}\mathbf{x}
\]
which brings us to a Jordan normal form. What does the new state representation
become ?

3) Calculate the transfer function of this system. What is the characteristic
polynomial of the system ? 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:vers:compagnon}Controllable canonical
form \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/pZm7yAA4Npk}{https://youtu.be/pZm7yAA4Npk}}

Let us consider a system with the input described by the evolution
equation: 
\[
\mathbf{\dot{x}}=\mathbf{Ax}+\mathbf{b}u
\]
Let us note that the control matrix traditionally denoted by $\mathbf{B}$
becomes, in our case of a single input, a vector $\mathbf{b}$. Let
us take as transfer matrix (assumed invertible):
\[
\mathbf{P}=\left(\mathbf{b\ |\ Ab\ |\ A}^{2}\mathbf{b\ |\ \dots\ |\ A}^{n-1}\mathbf{b}\right)
\]
The new state vector is therefore $\mathbf{v}=\mathbf{P}^{-1}\mathbf{x}$.
Show that, in this new basis, the state equations are written as:
\[
\begin{array}{ccc}
\mathbf{\dot{v}} & = & \left(\begin{array}{ccccccc}
0 &  & 0 &  & 0 &  & -a_{0}\\
1 &  & 0 &  & 0 &  & -a_{1}\\
0 &  & \vdots &  & 0 &  & \dots\\
0 &  & 0 &  & 1 &  & -a_{n-1}
\end{array}\right)\mathbf{v}+\left(\begin{array}{l}
1\\
0\\
\vdots\\
0
\end{array}\right)\mathbf{u}\end{array}
\]
where the $a_{i}$ are the coefficients of the characteristic polynomial
of the matrix $\mathbf{A}$.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} State equations of a second order system \label{ex:cablage:etat}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/ZV-4gpKGaVY}{https://youtu.be/ZV-4gpKGaVY}}

Let us consider the system $\mathcal{S}$ described by the block diagram
of Figure \ref{fig:schema_complexe}.

\begin{figure}[!h]
\centering \includegraphics[width=6.8732cm,height=4.536cm]{schema_complexe}
\caption{Second-order system}

\label{fig:schema_complexe} 
\end{figure}

1) Give its state equations in matrix form.

2) Calculate the characteristic polynomial of the system. Is the system
stable ?

3) Calculate the transfer function of the system. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Combination of systems \label{ex:combinaison:systemes}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/bzmd0Ue2DK8}{https://youtu.be/bzmd0Ue2DK8}}

Let us consider the systems $\mathcal{S}_{1}$ and $\mathcal{S}_{2}$
given on top of Figure \ref{fig:schema_composition}.

1) Give the state equations in matrix form of the system $\mathcal{S}_{a}$
obtained by placing systems $\mathcal{S}_{1}$ and $\mathcal{S}_{2}$
in series. Give the transfer function and characteristic polynomial
of $\mathcal{S}_{a}.$

2) Do the same with the system $\mathcal{S}_{b}$ obtained by placing
systems $\mathcal{S}_{1}$ and $\mathcal{S}_{2}$ in parallel.

3) Do the same with the system $\mathcal{S}_{c}$ obtained by looping
$\mathcal{S}_{1}$ by $\mathcal{S}_{2}$ as represented on Figure
\ref{fig:schema_composition}. 

\begin{figure}[H]
\centering \includegraphics[width=12cm]{schema_composition} \caption{Composition of systems\label{fig:schema_composition}}
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Transfer function \label{ex:calcul_FT0} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/4sA1C9vXzJQ}{https://youtu.be/4sA1C9vXzJQ}}

Let us consider the system represented by Figure \ref{fig:transfert}.
Calculate its transfer function.

\begin{figure}[!h]
\centering \includegraphics[width=12cm]{transfert} \caption{Linear system for which the transfer function must be calculated}

\label{fig:transfert} 
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Canonical control form \label{ex:forme:canonique:commande}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/3vI-NVxx58w}{https://youtu.be/3vI-NVxx58w}}

Let us consider the order $3$ linear system with a single input and
a single output, described by the following differential equation:
\[
\dddot{y}+a_{2}\ddot{y}+a_{1}\dot{y}+a_{0}y=b_{2}\ddot{u}+b_{1}\dot{u}+b_{0}u
\]

1) Calculate its transfer function $G(s).$

2) By noticing that this system can be obtained by placing the two
transfer function systems in series:
\[
G_{1}(s)=\frac{1}{s^{3}+a_{2}s^{2}+a_{1}s+a_{0}}\text{ \ \ and \ \ }G_{2}(s)=b_{2}s^{2}+b_{1}s+b_{0}
\]
deduce a block diagram with only three integrators, some adders and
amplifiers.

3) Give the state equations associated with this block diagram. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Canonical observation form\label{ex:forme:canonique:obs}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/ZNyAHIN9PrQ}{https://youtu.be/ZNyAHIN9PrQ}}

Let us consider once more the system described by the differential
equation: 
\[
\dddot{y}+a_{2}\ddot{y}+a_{1}\dot{y}+a_{0}y=b_{2}\ddot{u}+b_{1}\dot{u}+b_{0}u
\]

1) Show that this differential equation can be written in integral
form as:
\[
y=\int\int\int\left(b_{2}\ddot{u}-a_{2}\ddot{y}\ +\ b_{1}\dot{u}-a_{1}\dot{y}\ +\ b_{0}u-a_{0}y\right)
\]

2) Deduce from this a block diagram with only three integrators, some
adders and amplifiers.

3) Give the associated state equations.

4) Compare this with the results obtained in Exercise \ref{ex:forme:canonique:commande}. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Modal form \label{ex:forme:modale} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/Y9tlXWQrAcQ}{https://youtu.be/Y9tlXWQrAcQ}}

A monovariate linear system is in \emph{modal} form if it can be written
as: 
\[
\left\{ \begin{array}{lll}
\mathbf{\dot{x}} & = & \left(\begin{array}{llll}
\lambda_{1} & 0 & \cdots & 0\\
0 & \lambda_{2} & 0 & \cdots\\
\cdots & \cdots & \cdots & \cdots\\
0 & \cdots & 0 & \lambda_{n}
\end{array}\right)\mathbf{x}+\left(\begin{array}{c}
1\\
1\\
\vdots\\
1
\end{array}\right)u\\
y & = & \left(\begin{array}{llll}
c_{1} & c_{2} & \cdots\  & \ c_{n}\end{array}\right)\mathbf{x\ \ }+\ \ \ \ d\ \ u
\end{array}\right.
\]

1) Draw a block diagram for this system using integrators, adders
and amplifiers.

2) Calculate the transfer function associated with this system.

3) Calculate its characteristic polynomial. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Jordan normal form \label{ex:jordan} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/79UbImbjs9Q}{https://youtu.be/79UbImbjs9Q}}

The system described by the state equations:
\begin{align*}
\mathbf{\dot{x}} & =\left(\begin{array}{ccccc}
-2 & 1 & 0 & 0 & 0\\
0 & -2 & 1 & 0 & 0\\
0 & 0 & -2 & 0 & 0\\
0 & 0 & 0 & -3 & 1\\
0 & 0 & 0 & 0 & -3
\end{array}\right)\mathbf{x}+\left(\begin{array}{l}
0\\
0\\
1\\
0\\
1
\end{array}\right)u\\
y & =\left(\begin{array}{lllll}
-2 & -1 & 3 & -4 & 7\end{array}\right)\mathbf{x}+2u
\end{align*}
is in Jordan normal form since its evolution matrix $\mathbf{A}$
is a Jordan matrix. In other words, it is block diagonal and each
block (here there are two) has zeros everywhere, except on the diagonal
which contains equal elements and on the opposite diagonal which only
contains ones. Moreover, the control matrix only contains ones and
zeros which are positioned at the last row of each block.

1) Draw a block diagram for this system using integrators, adders
and amplifiers.

2) Calculate its transfer function.

3) Calculate its characteristic polynomial as well as the associated
eigenvalues. 

\chapter{Linear control \label{ch:com:lin}}

In this chapter, we will study the design of controllers for systems
given by linear state equations of the form:
\[
\left\{ \begin{array}{lll}
\mathbf{\dot{x}} & = & \mathbf{Ax}+\mathbf{Bu}\\
\mathbf{y} & = & \mathbf{Cx}
\end{array}\right.
\]
We will show in the following chapter that around very particular
points of the state space, called \emph{operating points}, many non-linear
systems genuinely behave like linear systems. The techniques developed
in this chapter will then be used for the control of non-linear systems.
Let us denote by $m,n,p$ the respective dimensions of the vectors
$\mathbf{u}$, $\mathbf{x}$ and $\mathbf{y}$. Recall that $\mathbf{A}$
is called \emph{evolution matrix}, $\mathbf{B}$ is the \emph{control
matrix} and $\mathbf{C}$ is the \emph{observation matrix}. 
\begin{rem}
We have assumed here, in the interest of simplification, that the
direct matrix $\mathbf{D}$ involved in the observation equation was
nil. In the case where such a direct matrix exists, we can remove
it with a simple feed-forward loop $\mathbf{z}=\mathbf{y}-\mathbf{Du}$,
as represented on Figure \ref{fig:nodirect}. 
\end{rem}
\begin{figure}[!b]
\centering \includegraphics[width=0.4\columnwidth]{removeD} \caption{Loop allowing the removal of the direct matrix $\mathbf{D}$}

\label{fig:nodirect}
\end{figure}

After having defined the fundamental concepts of controllability and
observability, we will propose two approaches for the design of controllers.
First of all, we will assume that the state $\mathbf{x}$ is accessible
on demand. Even though this hypothesis is generally not verified,
it will allow us to establish the principles of the \emph{pole placement
method}. In the second phase, we will no longer assume that the state
is accessible. We will then have to develop \emph{state estimators}
capable of approximating the state vector in order to be able to employ
the tools developed in the first phase. The reader should consult
the book of T. Kailath \cite{kailath80}in order to have a wider view
of the methods used for the control of linear systems. 

\section{Controllability and observability}

There are multiple equivalent definitions for the controllability
and observability of linear systems. A simple definition is the following.
\begin{defn}
\noindent The linear system 
\[
\left\{ \begin{array}{lll}
\mathbf{\dot{x}} & = & \mathbf{Ax}+\mathbf{Bu}\\
\mathbf{y} & = & \mathbf{Cx}
\end{array}\right.
\]
is said to be \emph{controllable} if, for every pair of state vectors
$\left(\mathbf{x}_{0},\mathbf{x}_{1}\right)$, we can find a time
$t_{1}$ and a control $\mathbf{u}(t)$, $t\in[0,t_{1}]$, such that
the system, initialized in $\mathbf{x}_{0},$ reaches the state $\mathbf{x}_{1},$
at time $t_{1}$. It is \emph{observable} is the knowledge of $\mathbf{y}(t)$
and of $\mathbf{u}(t)$ for $t\in\mathbb{R}$ allows us to determine,
in a unique manner, the state $\mathbf{x}(t)$, for all $t$.
\end{defn}
\noindent \textsc{Controllability criterion} \textendash{} The system
is controllable if and only if: 
\[
\text{rank}\underset{\mathbf{\Gamma}_{\text{con}}}{\underbrace{\left(\mathbf{B\;|\;AB\;|\;A}^{2}\mathbf{B\;|}\;\dots\;|\;\mathbf{A}^{n-1}\mathbf{B}\right)}}\ =\ n
\]
where $n$ is the dimension of $\mathbf{x}$. In other words, the
matrix $\mathbf{\Gamma}_{\text{con}}$, called the \emph{controllability
matrix}, obtained by juxtaposing the $n$ matrices $\mathbf{B}$,
$\mathbf{AB}$, $\dots,$ $\mathbf{A}^{n-1}\mathbf{B}$ next to one
another, has to be of full rank in order for the system to be controllable.
This criterion is proved in Exercise \ref{ex:critere:com:continu}.$~$

\noindent \textsc{Observability criterion} \textendash{} The linear
system is \emph{observable} if: 
\[
\text{rank}\underset{\mathbf{\Gamma}_{\text{obs}}}{\underbrace{\left(\begin{array}{c}
\mathbf{C}\\
\mathbf{CA}\\
\vdots\\
\mathbf{CA}^{n-1}
\end{array}\right)}}=n
\]
in other words the matrix, called the \emph{observability matrix}
$\mathbf{\Gamma}_{\text{obs}}$, obtained by placing the $n$ matrices
$\mathbf{C}$, $\mathbf{CA}$, $\dots$, $\mathbf{CA}^{n-1}$ below
one another, is of full rank. The proof of this criterion is discussed
in Exercise \ref{ex:preuve:obs}.

The above definitions as well as the criteria are also valid for discrete-time
linear systems (see Exercise \ref{ex:critere:com:discret}).

\section{State feedback control \label{st:retour:etat}}

Let us consider the system $\mathbf{\dot{x}}=\mathbf{Ax}+\mathbf{Bu}$
which is assumed to be controllable and we are looking to find a controller
for this system of the form $\mathbf{u}=\mathbf{w}-\mathbf{Kx}$,
where $\mathbf{w}$ is the new input. This leads to the assumption
that $\mathbf{x}$ is accessible on demand, which is normally not
the case. We will see further on how to get rid of this awkward hypothesis.
The state equations of the looped system are written as: 
\[
\mathbf{\dot{x}}=\mathbf{Ax}+\mathbf{B}\left(\mathbf{w}-\mathbf{Kx}\right)=\left(\mathbf{A}-\mathbf{BK}\right)\mathbf{x}+\mathbf{Bw}.
\]
It is reasonable to choose the control matrix $\mathbf{K}$ so as
to impose the poles of the looped system. This problem is equivalent
to imposing the characteristic polynomial of the system. Let $P_{\text{con}}(s)$
be the desired polynomial of degree $n$. We need to solve the polynomial
equation: 
\[
\det(s\mathbf{I}-\mathbf{A}+\mathbf{BK})=P_{\text{con}}(s)
\]
referred to as \emph{pole placement}. This equation can be translated
into $n$ scalar equations. Let us indeed recall that two monic polynomials
of degree $n$ $s^{n}+a_{n-1}s+\dots+a_{0}$ and $s^{n}+b_{n-1}s+\dots+b_{0}$
are equal if and only if their coefficients are all equal, i.e. if
$a_{n-1}=b_{n-1},\dots,a_{0}=b_{0}.$ Our system of $n$ equations
has $m.n$ unknowns which are the coefficients $k_{ij}$, $i\in\{1,\dots,m\},j\in\{1,\dots,n\}$.
In fact, a single solution matrix $\mathbf{K}$ is sufficient. We
may therefore fix ($m-1)$ elements of $\mathbf{K}$ so that we are
left with only $n$ unknowns. However, the obtained system is not
always linear. The \texttt{ppol} instruction in \textsc{Scilab} or
\texttt{place} in \textsc{Matlab} or \textsc{Python} allow to solve
the pole placement equation.

\section{Output feedback control\label{st:retour:sortie}}

In this paragraph, we are once again looking to stabilize the system:
\[
\left\{ \begin{array}{ccc}
\mathbf{\dot{x}} & = & \mathbf{Ax}+\mathbf{Bu}\\
\mathbf{y} & = & \mathbf{Cx}
\end{array}\right.
\]
but this time, the state $\mathbf{x}$ of the system is is no longer
assumed to be accessible on demand. The controller which will be used
is represented on Figure \ref{fig:precompensateur}.

\begin{figure}[!h]
\centering \includegraphics[width=0.6\columnwidth]{precompensateur}
\caption{Principle of an output feedback controller}

\label{fig:precompensateur}
\end{figure}

Only the setpoint $\mathbf{w}$ and the output of the system $\mathbf{y}$
can be used by the controller. The unknowns of the controller are
the matrices $\mathbf{K}$, $\mathbf{L}$ and $\mathbf{H}$. Let us
attempt to explain the structure of this controller. First of all,
in order to estimate the state $\mathbf{x}$ necessary for computing
the control $\mathbf{u}$, we integrate a \emph{simulator} of our
system into the controller. The simulator is a copy of the system
and its state vector is denoted by $\mathbf{\hat{x}}$. The error
$\mathbf{\varepsilon}_{y}$ between the output of the simulator $\mathbf{\hat{y}}$
and the output of the system $\mathbf{y}$ allows us to correct, by
using a correction matrix $\mathbf{L}$, the evolution of the estimated
state $\mathbf{\hat{x}}$. The corrected simulator is referred to
as the \emph{Luenberger observer}. We can then apply a state feedback
technique which will be carried out using the matrix $\mathbf{K}$.
For the calculation of $\mathbf{K}$ we may use the pole placement
method described earlier, which consists of solving $\det(s\mathbf{I}-\mathbf{A}+\mathbf{BK})=P_{\text{con}}(s)$,
where $P_{\text{con}}(s)$ is the characteristic polynomial of degree
$n$ chosen for the control dynamics. For the calculation of the correction
matrix $\mathbf{L}$, we will try to guarantee a convergence of the
error $\mathbf{\hat{x}}-\mathbf{x}$ to $\mathbf{0}$. The role of
the matrix $\mathbf{H}$ (square matrix placed right after the setpoint
vector $\mathbf{w}$), called a \emph{precompensator} is to match
the components of the setpoint $\mathbf{w}$ with certain state variables
chosen beforehand. We will also discuss how to choose this matrix
$\mathbf{H}$ in order to be able to perform this association.

In order to calculate $\mathbf{L}$, let us extract, from the controlled
system of the figure, the sub-system with input $\mathbf{u}$ formed
from the system to be controlled and its observer (see Figure \ref{fig:sortie_erreur_etat}).

The state equations which describe the system are: 
\[
\left\{ \begin{array}{lll}
\mathbf{\dot{x}} & = & \mathbf{Ax}+\mathbf{Bu}\\
\frac{d}{dt}\mathbf{\hat{x}} & = & \mathbf{A\hat{x}}+\mathbf{Bu}-\mathbf{L}\left(\mathbf{C\hat{x}}-\mathbf{Cx}\right)
\end{array}\right.
\]
where the state vector is $\left(\mathbf{x,\hat{x}}\right)$. Let
us create, only by thought, the quantity $\mathbf{\varepsilon}_{x}=\mathbf{\hat{x}}-\mathbf{x}$,
as represented on Figure \ref{fig:sortie_erreur_etat}. By subtracting
the two evolution equations, we obtain: 
\[
\frac{d}{dt}\left(\mathbf{\hat{x}}-\mathbf{x}\right)=\mathbf{A\hat{x}}+\mathbf{Bu}-\mathbf{L}\left(\mathbf{C\hat{x}}-\mathbf{Cx}\right)-\mathbf{Ax}-\mathbf{Bu}=\mathbf{A}\left(\mathbf{\hat{x}}-\mathbf{x}\right)-\mathbf{LC}\left(\mathbf{\hat{x}}-\mathbf{x}\right)
\]
Thus, $\boldsymbol{\varepsilon}_{x}$ obeys the differential equation:
\[
\boldsymbol{\dot{\varepsilon}}_{x}=\left(\mathbf{A}-\mathbf{LC}\right)\boldsymbol{\varepsilon}_{x}
\]
in which the control $\mathbf{u}$ is not involved. The estimation
error $\boldsymbol{\varepsilon}_{x}$ on the state tends towards zero
if all the eigenvalues of $\mathbf{A}-\mathbf{LC}$ have negative
real parts. To impose the dynamics of the error (in other words, its
convergence speed) means solving: 
\[
\det\left(s\mathbf{I}-\mathbf{A}+\mathbf{LC}\right)=P_{\text{obs}}(s)
\]
where $P_{\text{obs}}(s)$ is chosen as desired, so as to have the
required poles. Since the determinant of a matrix is equal to that
of its transpose, this equation is equivalent to: 
\[
\det\left(s\mathbf{I}-\mathbf{A}^{\text{T}}+\mathbf{C}^{\text{T}}\mathbf{L}^{\text{T}}\right)=P_{\text{obs}}(s)
\]
We obtain a pole placement-type equation.

\begin{figure}[!h]
\centering \includegraphics[width=0.5\columnwidth]{sortie_erreur_etat}
\caption{Diagram of the output error between the observer and the system}

\label{fig:sortie_erreur_etat} 
\end{figure}

\noindent \textsc{Precompensator}.\textendash{} The precompensator
$\mathbf{H}$ allows to associate the setpoints (components of $\mathbf{w}$)
with certain values of the state variables that we are looking at.
The choice of these state variables is done by using a setpoint matrix
$\mathbf{E}$. Assuming that $\mathbf{w}(t)=\bar{\mathbf{w}}$ is
constant, at equilibrium we have, $\hat{\mathbf{x}}=\mathbf{x}=\mathbf{\bar{x}}$
and $\dot{\mathbf{x}}=\mathbf{0}$. Thus 
\[
\begin{array}{c}
\left(\mathbf{A}-\mathbf{BK}\right)\mathbf{\bar{x}}+\mathbf{B}\mathbf{H}\bar{\mathbf{w}}=\mathbf{0}\end{array}
\]
or equivalently $\mathbf{\bar{x}}=-\left(\mathbf{A}-\mathbf{BK}\right)^{-1}\mathbf{B}\mathbf{H}\bar{\mathbf{w}}$.
If we want $\mathbf{\bar{w}}=\mathbf{E}\bar{\mathbf{x}}$, we should
solve\emph{ }
\[
-\mathbf{E}\left(\mathbf{A}-\mathbf{BK}\right)^{-1}\mathbf{B}\mathbf{H}=\mathbf{I}.
\]
Therefore
\[
\mathbf{H}=-\left(\mathbf{E}\left(\mathbf{A}-\mathbf{BK}\right)^{-1}\mathbf{B}\right)^{-1}.
\]


\section{Summary}

\label{sst:regulKLH}The algorithm of the table below summarizes the
method which allows to calculate an output feedback controller with
precompensator.

\begin{center}
\begin{tabular}{|cl|}
\hline 
 & $\textbf{\textbf{Algorithm}\ensuremath{\;}\textsc{RegulKLH}\ensuremath{\left(\text{in: }\mathbf{A,B,C,E,p}_{\text{con}},\mathbf{p}_{\text{obs}}\text{ ; out : }\mathcal{R}\right)}}$\tabularnewline
\hline 
1 & $\ensuremath{\mathbf{K}:=\mathbf{\;}}\textsc{place}\ensuremath{\left(\mathbf{A,B,p}_{\text{con}}\right);}$\tabularnewline
2 & $\ensuremath{\mathbf{L}:=\mathbf{\;}}\textsc{place}\ensuremath{\left(\mathbf{A}^{\text{T}}\mathbf{,C}^{\text{T}}\mathbf{,p}_{\text{obs}}\right)^{\text{T}};}$ \tabularnewline
3 & $\mathbf{H}:=-\left(\mathbf{E}\left(\mathbf{A}-\mathbf{BK}\right)^{-1}\mathbf{B}\right)^{-1};$\tabularnewline
4 & $\ensuremath{\mathcal{R}:=\left\{ \begin{array}{cccccc}
\frac{d}{dt}\mathbf{\hat{x}} & = & \left(\mathbf{A}-\mathbf{BK}-\mathbf{LC}\right) & \mathbf{\hat{x}} & + & \left(\begin{array}{cc}
\mathbf{BH} & \mathbf{L}\end{array}\right)\left(\begin{array}{l}
\mathbf{w}\\
\mathbf{\mathbf{y}}
\end{array}\right)\\
\mathbf{u} & = & -\mathbf{K} & \mathbf{\hat{x}} & + & \mathbf{\left(\begin{array}{cc}
\mathbf{H} & \mathbf{0}\end{array}\right)}\left(\begin{array}{l}
\mathbf{w}\\
\mathbf{\mathbf{y}}
\end{array}\right)
\end{array}\right.}$\tabularnewline
\hline 
\end{tabular}
\par\end{center}

\chapter*{Exercises}

\begin{Exercice} Non-observable states, non-controllable states \label{ex:etats:nonobs:noncom}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/Vdy3PmyV9kk}{https://youtu.be/Vdy3PmyV9kk}}

Let us consider the system: 
\[
\left\{ \begin{array}{ccccccc}
\mathbf{\dot{x}}(t) & = & \left(\begin{array}{ccccccc}
-1 & \, & 1 & \, & 0 & \, & 0\\
0 &  & 1 &  & 0 &  & 0\\
1 &  & 1 &  & 1 &  & 1\\
0 &  & 1 &  & 0 &  & 1
\end{array}\right) & \mathbf{x}(t) & + & \left(\begin{array}{c}
1\\
0\\
1\\
0
\end{array}\right) & u(t)\\
y(t) & = & \left(\begin{array}{lclclcl}
1 & \, & 1 & \, & 0 & \, & 0\end{array}\right) & \mathbf{x}(t) & + & 1 & u(t)
\end{array}\right.
\]

1) Calculate its transfer function.

2) Is this system stable ?

3) Draw the associated block diagram and deduce from this the non-observable
and non-controllable states.

4) The poles of the system (the eigenvalues of the evolution matrix)
are composed of transmission poles (poles of the transfer function)
and hidden poles. Give the hidden poles. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Using the controllability and observability criteria
\label{ex:utilisation:critere:obs:com} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/n-5sA7HGH1s}{https://youtu.be/n-5sA7HGH1s}}

Let us consider the system 
\[
\left\{ \begin{array}{lll}
\mathbf{\dot{x}} & = & \left(\begin{array}{ccccc}
1 &  & 1 &  & 0\\
0 &  & 1 &  & 0\\
0 &  & 0 &  & 1
\end{array}\right)\mathbf{x}+\left(\begin{array}{lcl}
0 &  & 0\\
1 &  & 0\\
1 &  & a
\end{array}\right)\mathbf{u}\\
\mathbf{y} & = & \left(\begin{array}{ccccc}
1 &  & 1 &  & b\\
0 &  & 1 &  & 0
\end{array}\right)\mathbf{x}
\end{array}\right.
\]

1) For which values of $a$ is the system controllable ?

2) For which values of $b$ is the system observable ? 

3) Draw the block diagram of the system.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Proof of the controllability criterion in discrete
time \label{ex:critere:com:discret} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/-B3nfyBQ1U8}{https://youtu.be/-B3nfyBQ1U8}}

Prove the criterion of controllability is discrete time. This theorem
states that the system $\mathbf{x}(k+1)=\mathbf{Ax}(k)+\mathbf{Bu}(k)$
is controllable if and only if: 
\[
\text{rank}\underset{\mathbf{\Gamma}_{\text{con}}}{\underbrace{\left(\mathbf{B}\;|\;\mathbf{A}\mathbf{B}\;|\;\mathbf{A}^{2}\mathbf{B}|\dots|\;\mathbf{A}^{n-1}\mathbf{B}\right)}}\ =\ n
\]
where $n$ is the dimension of $\mathbf{x}$.

1) Show that: 
\[
\mathbf{x}(n)=\mathbf{A}^{n}\mathbf{x}(0)+\left(\mathbf{B}\;|\;\mathbf{A}\mathbf{B}\;|\dots|\;\mathbf{A}^{n-1}\mathbf{B}\right)\left(\begin{array}{c}
\mathbf{u}(n-1)\\
\vdots\\
\mathbf{u}(1)\\
\mathbf{u}(0)
\end{array}\right)
\]
2) Show that if the matrix $\left(\mathbf{B\;|\;AB\;|}\;\dots\;|\;\mathbf{A}^{n-1}\mathbf{B}\right)$
is of full rank then, for every initial vector $\mathbf{x}_{0}$,
for every target vector $\mathbf{x}_{n}$, we can find a control $\mathbf{u}(0),\mathbf{u}(1),\dots,\mathbf{u}(n-1)$
such that the system initialized in $\mathbf{x}_{0}$ reaches $\mathbf{x}_{n}$,
at time $k=n$.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Proof of the controllability criterion in continuous
time \label{ex:critere:com:continu} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/4TWwM0HyHDw}{https://youtu.be/4TWwM0HyHDw}}

In this exercise, we prove the controllability criterion in continuous
time which states that the system $\mathbf{\dot{x}}=\mathbf{Ax}+\mathbf{Bu}$
is controllable if and only if: 
\[
\text{rank}\underset{\mathbf{\Gamma}_{\text{con}}}{\underbrace{\left(\mathbf{B\;\textnormal{|}\;AB\;|\;A}^{2}\mathbf{B\;\textnormal{|}}\;\dots\;|\;\mathbf{A}^{n-1}\mathbf{B}\right)}}\ =\ n
\]
where $n$ is the dimension of $\mathbf{x}$ and \textbf{$\Gamma$}$_{\text{con}}$
is the controllability matrix. 

The proof is in two steps. First, we prove in Question 1 by contradiction
that if the system is controllable then the rank is equal to $n$.
Then, we show in Question 2 that if the rank is equal to $n$ then
the system is controllable.

1) Assume that: 
\[
\text{rank}\underset{\mathbf{\Gamma}_{\text{con}}}{\underbrace{\left(\mathbf{B\;|\;AB\;|\;A}^{2}\mathbf{B\;|}\;\dots\;|\;\mathbf{A}^{n-1}\mathbf{B}\right)}}<n
\]
Let $\mathbf{z}$ be a non-zero vector such that \textbf{$\mathbf{z}^{\text{T}}\cdot\mathbf{\Gamma}_{\text{con}}=\mathbf{0}$}.
By using the solution of the state equation: 
\[
\mathbf{x}(t)=e^{\mathbf{A}t}\mathbf{x}(0)+\int_{0}^{t}e^{\mathbf{A}(t-\tau)}\mathbf{Bu}(\tau)d\tau,
\]
show that the control $\mathbf{u}$ cannot influence the value $\mathbf{z}^{\text{T}}\mathbf{x}.$
Deduce from this that the system is not controllable.

2) Show that if rank$\left(\mathbf{\Gamma}_{\text{con}}\right)=n$,
for every pair $\left(\mathbf{x}(0),\mathbf{x}(t_{1})\right),$ $t_{1}>0$,
there is a polynomial control $\mathbf{u}(t),t\in[0,t_{1}]$ which
leads the system from state $\mathbf{x}(0)$ to state $\mathbf{x}(t_{1})$.
Here, we will limit ourselves to $t_{1}=1,$ knowing that the main
principle of the proof remains valid for any $t_{1}>0$.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Proof of the observability criterion \label{ex:preuve:obs}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/Y6TBDrMf8Eo}{https://youtu.be/Y6TBDrMf8Eo}}

Consider the continuous-time linear system: 
\begin{align*}
\mathbf{\dot{x}} & =\mathbf{Ax}+\mathbf{Bu}\\
\mathbf{y} & =\mathbf{Cx}
\end{align*}
1) Show that: 
\[
\left(\begin{array}{c}
\mathbf{y}\\
\mathbf{\dot{y}}\\
\mathbf{\ddot{y}}\\
\vdots\\
\mathbf{y}^{(n-1)}
\end{array}\right)=\left(\begin{array}{c}
\mathbf{C}\\
\mathbf{CA}\\
\mathbf{CA}^{2}\\
\vdots\\
\mathbf{CA}^{n-1}
\end{array}\right)\mathbf{x}+\left(\begin{array}{cccc}
\mathbf{0} & \mathbf{0} & \mathbf{0} & \mathbf{0}\\
\mathbf{CB} & \mathbf{0} & \mathbf{0} & \mathbf{0}\\
\mathbf{CAB} & \mathbf{CB} & \mathbf{0}\\
\vdots &  & \ddots & \ddots\\
\mathbf{CA}^{n-2}\mathbf{B} & \cdots & \mathbf{CAB} & \mathbf{CB}
\end{array}\right)\left(\begin{array}{c}
\mathbf{u}\\
\mathbf{\dot{u}}\\
\mathbf{\ddot{u}}\\
\vdots\\
\mathbf{u}^{(n-2)}
\end{array}\right)
\]
2) Deduce from this that if the observability matrix: 
\[
\mathbf{\Gamma}_{\text{obs}}=\left(\begin{array}{c}
\mathbf{C}\\
\mathbf{CA}\\
\vdots\\
\mathbf{CA}^{n-1}
\end{array}\right)
\]
is of full rank, then we can express the state $\mathbf{x}$ as a
linear function of the quantities $\mathbf{u}$, $\mathbf{y}$, $\mathbf{\dot{u},\dot{y}}$,
$\mathbf{\dots,u}^{(n-2)}$, $\mathbf{y}^{(n-2)}$, $\mathbf{y}^{(n-1)}.$

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Kalman decomposition \label{ex:decomposition:kalman}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/reOIIEOPz50}{https://youtu.be/reOIIEOPz50}}

A linear system can always be decomposed, after a suitable change
of basis, into four sub-systems $\mathcal{S}_{1},\mathcal{S}_{2},\mathcal{S}_{3},\mathcal{S}_{4}$
where $\mathcal{S}_{1}$ is controllable and observable, $\mathcal{S}_{2}$
is non-controllable and observable, $\mathcal{S}_{3}$\emph{\ }is
controllable and non-observable and $\mathcal{S}_{4}$\emph{\ }is
neither controllable nor observable. The dependencies between the
sub-systems can be summarized by Figure \ref{fig:decompositionkalm2}.

\begin{figure}[!h]
\centering \includegraphics[width=6cm]{decompositionKalm2} \caption{Principle of the Kalman decomposition ; C: controllable, O: observable,
\={C}: non-controllable, \={O}: non-observable}

\label{fig:decompositionkalm2} 
\end{figure}

Let us note that, on the figure, there is no path (respecting the
direction of the arrows) leading from the input $\mathbf{u}$ to a
non-controllable system. Similarly, there is no path leading from
a non-observable system to $\mathbf{y}$. We consider the system described
by the state equation: 
\[
\left\{ \begin{array}{ccccccc}
\mathbf{\dot{x}}(t) & = & \left(\begin{array}{cccc}
\mathbf{A}_{11} & \mathbf{A}_{12} & \mathbf{0} & \mathbf{0}\\
\mathbf{0} & \mathbf{A}_{22} & \mathbf{0} & \mathbf{0}\\
\mathbf{A}_{31} & \mathbf{A}_{32} & \mathbf{A}_{33} & \mathbf{A}_{34}\\
\mathbf{0} & \mathbf{A}_{42} & \mathbf{0} & \mathbf{A}_{44}
\end{array}\right) & \mathbf{x}(t) & + & \left(\begin{array}{c}
\mathbf{B}_{1}\\
\mathbf{0}\\
\mathbf{B}_{3}\\
\mathbf{0}
\end{array}\right) & \mathbf{u}(t)\\
\mathbf{y}(t) & = & \left(\begin{array}{lclclcl}
\mathbf{C}_{1} &  & \mathbf{C}_{2} &  & \mathbf{0} &  & \mathbf{0}\end{array}\right) & \mathbf{x}(t) & + & \left(\mathbf{D}\right) & \mathbf{u}(t)
\end{array}\right.
\]
Draw a block diagram of the system. Show a decomposition in $4$ sub-systems
$\mathcal{S}_{i}$ corresponding to the Kalman decomposition.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Resolution of the pole placement equation \label{ex:ppol}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/65nmtKCWzfw}{https://youtu.be/65nmtKCWzfw}}

We will illustrate here the resolution of the pole placement equation
when the system only has a single input. We consider the system: 
\[
\mathbf{\dot{x}}=\left(\begin{array}{ccc}
1 &  & 2\\
3 &  & 4
\end{array}\right)\mathbf{x}+\left(\begin{array}{c}
1\\
2
\end{array}\right)u
\]
that we are looking to stabilize by state feedback of the form: $u=w-\mathbf{Kx}$,
with: $\mathbf{K}=(k_{1}~~k_{2})$. Calculate $\mathbf{K}$ so that
this characteristic polynomial $P_{\text{con}}(s)$ of the closed-loop
system has the roots $-1$ and $-1$.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Output feedback of a scalar system \label{ex:retour:sortie:scal}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/6jbn4wP8IEU}{https://youtu.be/6jbn4wP8IEU}}

Let us consider the following state equation:
\[
\left\{ \begin{array}{lll}
\dot{x} & = & 3x+2u\\
y & = & 4x
\end{array}\right.
\]

1) Propose an output feedback controller which puts all the poles
in $-1$ and such that the setpoint variable corresponding to $x$
(in other words if we fix the setpoint at $\bar{w}$, we want the
state $x$ to converge towards $\bar{w}$).

2) Give the state equations of the looped system. What are the poles
of the looped system ? 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Separation principle \label{exer:principe:separation}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/C71Yfs-mnZ4}{https://youtu.be/C71Yfs-mnZ4}}

Let us consider a system looped by a pole placement method, as represented
on Figure \ref{fig:retoursortie:sep}.

\begin{figure}[H]
\centering \includegraphics[width=9.5355cm,height=7.9144cm]{retoursortie}
\caption{Output feedback controller}

\label{fig:retoursortie:sep} 
\end{figure}

1) Give the state equations of the controller.

2) Find the state equations of the looped system. We will take as
state vector the vector $(\mathbf{x}^{\text{T}}\;\mathbf{\hat{x}}^{\text{T}})^{\text{T}}$.

3) Let us take $\boldsymbol{\varepsilon}_{x}=\mathbf{\hat{x}}-\mathbf{x}$
and take as new state vector $(\mathbf{x}^{\text{T}}\;\boldsymbol{\varepsilon}_{x}^{\text{T}})^{\text{T}}$.
Give the associated state representation. Show that $\boldsymbol{\varepsilon}_{x}$
is not controllable.

4) Show that the characteristic polynomial of the looped system is
given by:
\[
P(s)=\det\left(s\mathbf{I}-\mathbf{A}+\mathbf{BK}\right).\det\left(s\mathbf{I}-\mathbf{A}+\mathbf{LC}\right)
\]

What can be deduced from this about the relationship between the poles
of this system and the ones we have placed ?

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Proportional and derivative control of a pump\label{ex:commande:PD:moteur:pompe}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/9lFBusPAzfA}{https://youtu.be/9lFBusPAzfA}}

We consider the direct current motor of Figure \ref{fig:moteur:conitinu}.

\begin{figure}[H]
\centering \includegraphics[width=10cm]{moteurDC} \caption{Direct current motor}

\label{fig:moteur:conitinu} 
\end{figure}

Its state equations are:
\[
\left\{ \begin{split}\frac{di}{dt} & =-\frac{R}{L}i-\frac{\kappa}{L}\omega+\frac{u}{L}\\
\dot{\omega} & =\frac{\kappa}{J}i-\frac{\rho}{J}\omega-\frac{T_{r}}{J}
\end{split}
\right.
\]
where $\kappa,R,L,\rho,J$ are constant parameters of the motor. The
inputs are the voltage $u$ and the torque $T_{r}$, the state variables
are $i$ and $\omega$. We use this motor to pump water from a well.
In this case, the torque used is $T_{r}=\alpha\omega$, where $\alpha$
is a constant parameter. We will ignore $\rho$ before $\alpha$.
There is consequently a single input for the motor+pump system: the
voltage $u$.

1) Give the state equations of the motor+pump system.

2) We choose as output $y=\omega$. Calculate the transfer function
of the motor+pump system.

3) Give the differential equation associated with this transfer function.

4) We take as state vector $\mathbf{x}=\left(y,\dot{y}\right)^{\text{T}}$.
Give a state representation of the system in matrix form.

5) A \emph{proportional-derivative} controller is a linear combination
of the output $y$, its derivative $\dot{y}$, and the setpoint $w$
(be careful not to confuse the setpoint $w$ with the speed of the
motor shaft $\omega$). This controller is written in the form: 
\[
u=hw-k_{1}y-k_{2}\dot{y}
\]
 Give the state equations of the motor+pump system looped by such
a controller.

6) Give the values of $k_{1}$ and $k_{2}$ that we need to choose
in order to have the poles of the looped system equal to $-1$.

7) Find $h$ in such a way that $y$ converges towards $w$ when the
setpoint $w$ is constant. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} PID control \label{ex:PID} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/uwcSOmcADHw}{https://youtu.be/uwcSOmcADHw}}

We consider a second-order system of the form described by the following
differential equation:
\[
\ddot{y}+a_{1}\dot{y}+a_{0}y=u
\]

1) Give the state equation of the system in matrix form. We will take
as state vector $\mathbf{x}=\left(y\ \ \dot{y}\right)^{\text{T}}$.

2) Let $w$ be a setpoint that we will assume constant. We would like
$y\left(t\right)$ to converge towards $w$. We define the error by:
$e\left(t\right)=w-y\left(t\right)$. We suggest controlling our system
by the following PID (proportional-derivative-integral) controller:
\[
u\left(t\right)=\alpha_{-1}\int_{0}^{t}e\left(\tau\right)d\tau\ \ +\ \alpha_{0}e\left(t\right)\ \ +\ \ \alpha_{1}\dot{e}\left(t\right)
\]
where the $\alpha_{i}$ are the coefficients of the controller. This
is a state feedback controller, where we assume that $\mathbf{x}\left(t\right)$
is measured. Give the state equations of this PID controller with
the inputs $\mathbf{x}$,$w$ and output $u$. A state variable $z\left(t\right)=\int_{0}^{t}e\left(\tau\right)d\tau$
will have to be created in order to take into account the integrator
of the control.

3) Draw the block diagram of the looped system. This diagram will
only be composed of integrators, adders and amplifiers. Encircle the
controller on the one hand and the system to be controlled on the
other.

4) Give the state equations of the looped system in matrix form.

5) Choose the coefficients $\alpha_{i}$ of the control (in function
of the $a_{i}$) so as to have a stable looped system in which all
the poles are equal to $-1$ ?

6) We slightly change the value of the parameters $a_{0}$ and $a_{1}$
while keeping the same controller. We assume that this modification
does not destabilize our system. The new values for $a_{0}$, $a_{1}$
are denoted by $a_{0}^{\prime}$, $a_{1}^{\prime}$. For a value $\bar{w}$
for given $w$, what value $\bar{y}$ does converge $y$ to ? Conclude.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Canonical control form \label{ex:retour:etat:3}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/G6UHzx8dleA}{https://youtu.be/G6UHzx8dleA}}

We consider the system described by its canonical control form as
in the Figure \ref{fig:compagne:retour:etat}.

\begin{figure}[H]
\centering \includegraphics[width=10.6053cm,height=5.3685cm]{compagne}
\caption{State feedback for a linear system in canonical control form}

\label{fig:compagne:retour:etat} 
\end{figure}

1) Give the state equations of this system. What is its characteristic
polynomial ?

2) We would like to control this system by a state feedback of the
form $u=-\mathbf{Kx}+hw$, where $w$ is the setpoint. Calculate $\mathbf{K}$
in order for all the poles to be equal to $-1.$

3) We would like, at equilibrium (\emph{i.e.}, when the setpoint and
the output no longer change), to have $y=w$. Deduce from this the
value to take for the precompensator $h$. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} State feedback with integral effect, monovariate
case \label{exer:retour:etat:integral:simple} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/mp4tF_D5lk4}{https://youtu.be/mp4tF\_D5lk4}}

We consider the system described by the state equations: 
\[
\left\{ \begin{array}{lll}
\mathbf{\dot{x}} & = & \left(\begin{array}{ccc}
1 &  & 1\\
0 &  & 2
\end{array}\right)\mathbf{x+}\left(\begin{array}{c}
0\\
1
\end{array}\right)u\\
y & = & x_{1}
\end{array}\right.
\]
where $u$ is the input, $y$ the output and $\mathbf{x}$ the state
vector.

1) Give the characteristic polynomial of the system. Is the system
stable ?

2) We loop the system by the following state feedback control:
\[
u=\alpha\int_{0}^{t}\left(w(\tau)-y(\tau)\right)d\tau\ \ -\ \ \mathbf{Kx},\text{\ \ avec }\mathbf{K}=\left(k_{1}\ \ k_{2}\right)
\]
where $w$ is the setpoint. Give the state equations of the controller
(we will denote by $z$ the state variable of the controller). What
are the poles of the controller ?

3) Give the state equations of the looped system.

4) Calculate $\mathbf{K}$ and $\alpha$ in order for all the poles
to be equal to $-1.$

5) We choose a setpoint $w=\bar{w}$ constant in time. What values
$\mathbf{\bar{x}}$ and $\bar{z}$, does the state of the system $\mathbf{x}$
and state of the controller $z$ tend to ? What value $\bar{y}$ does
the output $y$ tend to ?

6) We now replace the evolution matrix $\mathbf{A}$ by another matrix
$\mathbf{\bar{A}}$ close to $\mathbf{A}$, while keeping the same
controller. What value $y$ will it converge to ? 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} State feedback with integral effect, general case
\label{exer:retour:etat:integral} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/rCRQ3IjEE1w}{https://youtu.be/rCRQ3IjEE1w}}

We consider the system described by the state equation $\mathbf{\dot{x}}=\mathbf{Ax}+\mathbf{Bu}+\mathbf{p}$
where $\mathbf{p}$ is an unknown and constant disturbance vector
which represents an external disturbance. We will take $m=\dim\mathbf{u}$
and $n=\dim\mathbf{x}$. A state feedback controller with integral
effect is of the form: 
\[
\mathbf{u}=\mathbf{K}_{i}\int_{0}^{t}\left(\mathbf{w}-\mathbf{y}\right)dt-\mathbf{Kx}
\]
where $\mathbf{w}$ is the setpoint and $\mathbf{y}$ is a vector
with same dimension as $\mathbf{u}$ representing the setpoint state
variables (in other words those we wish to control directly by using
$\mathbf{w}$). The vector $\mathbf{y}$ is linked to the state $\mathbf{x}$
by the relation $\mathbf{y}=\mathbf{Cx}$.

1) Give the state equations of the looped system. Recall that the
state of the looped system will be composed of the state $\mathbf{x}$
of the system to control and of the vector $\mathbf{z}$ of the values
memorized in the integrators. Give the dimensions of $\mathbf{w},\mathbf{y},\mathbf{p},\mathbf{z},\mathbf{A},\mathbf{B},\mathbf{C},\mathbf{K}_{i},\mathbf{K}.$

2) Find the matrices $\mathbf{K}$ and $\mathbf{K}_{i}$ so that all
the poles of the looped system are equal to $-1$.

3) Show that, for a constant setpoint $\mathbf{w}$ and disturbance
$\mathbf{p}$, we necessarily have $\mathbf{y}=\mathbf{w}$, once
the steady state has been reached. What is then the value of $\mathbf{p}$
(in function of $\mathbf{x}$ and $\mathbf{z}$) ?

4) Give the state equations of the controller. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Luenberger observer \label{ex:observateur} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/HZmH9Rw9DVw}{https://youtu.be/HZmH9Rw9DVw}}

We consider the system with input $u$ and output $y$ of Figure \ref{fig:cablage_ordre2}.

\begin{figure}[H]
\centering \includegraphics[width=7.0028cm,height=3.3367cm]{cablage_ordre2}
\caption{Second order system for which we need to design an observer}

\label{fig:cablage_ordre2} 
\end{figure}

1) Give, in matrix form, a state representation for this system. Deduce
from this a simplification for the block diagram.

2) Study the stability of this system.

3) Give the transfer function of this system.

4) Is the system controllable ? Is it observable ?

5) Find an observer which allows to generate a state $\mathbf{\hat{x}}\left(t\right)$,
such that the error $\ ||\mathbf{\hat{x}}-\mathbf{x||}$ converges
towards zero at $e^{-t}$ (which means to place all the poles at $-1$).
Give this observer in state equation form. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Demodulator \label{exer:demodulateur:amplitude}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/Onqy3pbPeMw}{https://youtu.be/Onqy3pbPeMw}}

Consider the sinusoidal signal with pulsation $\omega$ 
\[
y\left(t\right)=a\cos\left(\omega t+b\right)
\]
where the parameters $a$ and $b$ are unknown. From the measure of
$y\left(t\right)$, we need to find the amplitude $a$ of the signal
$y\left(t\right)$.

1) Find an order $2$ state equation capable of generating the signal
$y\left(t\right)$. We will take as state variables $x_{1}=\omega y$
and $x_{2}=\dot{y}$.

2) Let us assume that at time $t$, we know the state vector $\mathbf{x}\left(t\right)$.
Deduce from this an expression of the amplitude $a$ of the signal
$y\left(t\right)$ in function of $\mathbf{x}\left(t\right)$.

3) We only measure $y\left(t\right)$. Propose a state observer (by
a pole placement method) which generates an estimation $\mathbf{\hat{x}}\left(t\right)$
of the state $\mathbf{x}\left(t\right)$. We will place all the poles
at $-1.$

4) Deduce from this the state equations of a state estimator with
input $y$ and output $\hat{a}$ which gives us an estimation $\hat{a}$
of the amplitude $a$ of a sinusoidal signal with pulsation $\omega$.
Build a program to check the behavior of the observer for the sampled
signal 
\[
y\left(t\right)=2\cos t+n\left(t\right)
\]
with $t\in\left\{ 0,dt,2dt,\dots,10\right\} $ where $dt=0.01$ is
the sampling period. The signal $n\left(t\right)$ is a white Gaussian
noise with standard deviation $0.1$. Draw also the filtered signal
$\hat{y}\left(t\right)$ as well as the estimation $\hat{a}\left(t\right)$
of the amplitude.

5) Draw the Bode diagram of the filter that generates $\hat{y}\left(t\right)$
from $y\left(t\right)$. Discuss. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Output feedback of a non-strictly proper system
\label{exer:commande:syst:impropre} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/X4WRTk4UBIg}{https://youtu.be/X4WRTk4UBIg}}

We consider the system $\mathcal{S}$ with input $u$ and output $y$
described by the differential equation: 
\[
\dot{y}-2y=\dot{u}+3u
\]
Since in this case the degree of differentiation of $u$ is not strictly
smaller than that of $y$, the system is not strictly proper.

1) Write this system in a state representation form.

2) In order to make this system strictly proper (in other words with
a direct matrix $\mathbf{D}$ equal to zero), we create a new output
$z=y-\alpha u.$ Give the appropriate value of $\alpha$. We will
denote by $\mathcal{S}_{z}$ this new system whose input is $u$ and
output is $z$.

3) Find an output feedback controller for $\mathcal{S}_{z}$ which
sets all the poles of the looped system to $-1$.

4) Deduce from this a controller $\mathcal{S}_{r}$ (in state equation
form) for $\mathcal{S}$ which sets all the poles of the looped system
to $-1$. We will denote by $\mathcal{S}_{b}$ the system $\mathcal{S}$
looped by the controller $\mathcal{S}_{r}$.

5) Give the state equations of the looped system $\mathcal{S}_{b}$.

6) Calculate the transfer function of the looped system $\mathcal{S}_{b}$.

7) Calculate the static gain of the looped system. This gain corresponds
to the ratio $\frac{\bar{y}}{\bar{w}}$ in a steady state. Deduce
from this the gain of the precompensator to be placed before the system
which would allow to have a static gain of $1$.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Output feedback with integral effect \label{exer:retour:sortie:integral}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/0bpDeghF2Qo}{https://youtu.be/0bpDeghF2Qo}}

We consider the system described by the state equation: 
\[
\left\{ \begin{array}{ccc}
\mathbf{\dot{x}} & = & \mathbf{Ax}+\mathbf{Bu}+\mathbf{p}\\
\mathbf{y} & = & \mathbf{Cx}
\end{array}\right.
\]
where $\mathbf{p}$ is a disturbance vector, representing an external
disturbance which could not be taken into account in the modeling
(wind, the slope of the terrain, the weight of the people in an elevator,
etc.). The vector $\mathbf{p}$ is assumed to be known and constant.
We will take $m=\dim\mathbf{u,}$ $n=\dim\mathbf{x}$ and $p=\dim\mathbf{y}$.
We need to control this system using the output feedback controller
with integral effect represented on Figure \ref{fig:retoursortie_integral}.

\begin{figure}[!h]
\centering \includegraphics[width=11cm]{retoursortie_integral} \caption{Output feedback controller with integral effect}

\label{fig:retoursortie_integral} 
\end{figure}

On this figure, $\mathbf{w}$ is the setpoint and $\mathbf{y}_{c}$
is a vector with the same dimension as $\mathbf{u}$ representing
the setpoint output variables (in other words those that we wish to
control directly using $\mathbf{w}$ and thus have $\mathbf{y}_{c}=\mathbf{w}$,
when the setpoint is constant). The vector $\mathbf{y}_{c}$ satisfies
the relation $\mathbf{y}_{c}=\mathbf{Ey}$, where $\mathbf{E}$ is
a known matrix.

1) Give the state equations of the looped system in matrix form.

2) Let us take $\boldsymbol{\varepsilon}=\mathbf{\hat{x}}-\mathbf{x}$.
Express these state equations in matrix form by taking, this time,
the state vectors $\left(\boldsymbol{x,z,\varepsilon}\right)$.

3) Show how we can arbitrarily set all the poles of the looped system.

4) Show that, for a constant setpoint $\mathbf{w}$ and disturbance
$\mathbf{p}$, in a steady state, we necessarily have $\mathbf{y}_{c}=\mathbf{w}$.

5) Give the state equations of the controller, in matrix form. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Poincare map \label{ex:poincare} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/HW9XjU9hJpU}{https://youtu.be/HW9XjU9hJpU}}

We consider the tank described by the state equation
\[
\left\{ \begin{array}{ccc}
\dot{x}_{1} & = & \cos x_{3}\\
\dot{x}_{2} & = & \sin x_{3}\\
\dot{x}_{3} & = & u
\end{array}\right.
\]

where $(x_{1},x_{2})$ corresponds to the position of the robot and
$x_{3}$ is its heading. The robot has an heading control of the form
$u=\sin(\bar{\psi}-x_{3})$. Moreover, the desired heading $\bar{\psi}$
obeys to the automaton (or Petri net) of Figure \ref{fig:poincare_petri}.
The variable $q\in\{0,1,2\}$ is a discrete and $c$ is a clock which
is initialized to 0 each time $q$ changes.

\begin{figure}[!h]
\centering \includegraphics[width=0.3\columnwidth]{poincare_petri}
\caption{Automaton deciding the desired heading}

\label{fig:poincare_petri}
\end{figure}

1) Using a simulation, show that the state $\mathbf{x}(t)$ converges
to a stable limit cycle. Take for the initial state $\mathbf{x}(0)=(-3,1,-1)$.

2) Given a surface of the state space $\mathcal{S}$ defined by $g(\mathbf{x})=0$
which is transverse to the field $\mathbf{f}$, \emph{i.e}., 
\[
\mathbf{x}\in\mathcal{S}\Rightarrow\left(\frac{\partial g}{\partial\mathbf{x}}\cdot\mathbf{f}\right)(\mathbf{x})\neq0
\]
almost everywhere. The surface $\mathcal{S}$ is called the \emph{Poincare
section}. Consider a point $\mathbf{a}\in\mathcal{S}$ such that $\left(\frac{\partial g}{\partial\mathbf{x}}\cdot\mathbf{f}\right)(\mathbf{a})>0$.
We define \emph{Poincare map} as the application which associates
the state $\mathbf{p}(\mathbf{a})$ of the surface $\mathcal{S}$
such that the trajectory initialized at $\text{\ensuremath{\mathbf{a}}}$
comes back for the first time in $\mathcal{S}$, with $\left(\frac{\partial g}{\partial\mathbf{x}}\cdot\mathbf{f}\right)(\mathbf{p}(\mathbf{a}))>0$.
See Figure \ref{fig:poincare1}. Show that for all $q=0.$ the surface
$\mathcal{S}:x_{1}+2=0$ is transverse to $\mathbf{f}$ where $\mathbf{f}(\mathbf{x},q)$
is the field associated to the controlled system.

\begin{figure}[H]
\centering \includegraphics[width=0.8\columnwidth]{poincare1} \caption{Left: the Poincare map; Right: a view of the Poincare map restricted
to the Poincare section $\mathcal{S}$ }

\label{fig:poincare1}
\end{figure}

3) Build a program which estimates the fixed point which satisfies
$\mathbf{p}(\bar{\mathbf{a}})=\bar{\mathbf{a}}$. Note that the trajectory
is in the surface $\mathcal{S}$ when $q$ switches from $q=2$ to
$q=0$.

4) Compute an estimate of the Jacobian matrix $\frac{d\mathbf{p}}{d\mathbf{a}}(\bar{\mathbf{a}}).$
Conclude about the stability of the limit cycle.

\chapter{Linearized control \label{ch:com:nl1}}

In Chapter \ref{ch:com:lin}, we have shown how to design controllers
for linear systems. However, in practice, the systems are rarely linear.
Nevertheless, if their state vector remains localized in a small zone
of the state space, the system may be considered linear and the techniques
developed in Chapter \ref{ch:com:lin} can then be used. We will first
show how to linearize a non-linear system around a given point of
the state space. We will then discuss how to stabilize these non-linear
systems.

\section{Linearization \label{st:linearisation}}

\subsection{Linearization of a function}

Let $\mathbf{f}:\mathbb{R}^{n}\rightarrow\mathbb{R}^{p}$ be a differentiable
function. In the neighborhood of a point $\mathbf{\bar{x}}\in\mathbb{R}^{n}$
the first-order Taylor development of $\mathbf{f}$ around $\mathbf{\bar{x}}$
gives us: 
\[
\mathbf{f}(\mathbf{x})\simeq\mathbf{f}(\mathbf{\bar{x}})+\frac{d\mathbf{f}}{d\mathbf{x}}\left(\mathbf{\bar{x}}\right)\left(\mathbf{x}-\mathbf{\bar{x}}\right)
\]
with 
\[
\frac{d\mathbf{f}}{d\mathbf{x}}\left(\mathbf{\bar{x}}\right)=\left(\begin{array}{ccccccc}
\frac{\partial f_{1}}{\partial x_{1}}\left(\mathbf{\bar{x}}\right) & \, & \frac{\partial f_{1}}{\partial x_{2}}\left(\mathbf{\bar{x}}\right) & \, & \dots & \, & \frac{\partial f_{1}}{\partial x_{n}}\left(\mathbf{\bar{x}}\right)\\
\frac{\partial f_{2}}{\partial x_{1}}\left(\mathbf{\bar{x}}\right) &  & \frac{\partial f_{2}}{\partial x_{2}}\left(\mathbf{\bar{x}}\right) &  & \dots &  & \frac{\partial f_{2}}{\partial x_{n}}\left(\mathbf{\bar{x}}\right)\\
\vdots &  & \vdots &  &  &  & \mathbf{\vdots}\\
\frac{\partial f_{p}}{\partial x_{1}}\left(\mathbf{\bar{x}}\right) &  & \frac{\partial f_{p}}{\partial x_{2}}\left(\mathbf{\bar{x}}\right) &  & \dots &  & \frac{\partial f_{p}}{\partial x_{n}}\left(\mathbf{\bar{x}}\right)
\end{array}\right).
\]
This matrix is called the \emph{Jacobian matrix}. Very often, in order
to linearize a function, we use formal calculus for calculating the
Jacobian matrix, then we instantiate this matrix around $\mathbf{\bar{x}}$.
When we differentiate by hand, we avoid such proceedings. We save
a lot of calculations if we perform the two operations (differentiation
and instantiation) simultaneously. Finally, there is a similar method
which is very easy to implement: the \emph{finite difference} method\emph{.
} In order to apply it\emph{\ }to the calculation of $\frac{d\mathbf{f}}{d\mathbf{x}}$
at point $\mathbf{\bar{x}}$, we approximate the $j^{\text{th}}$
column of the Jacobian matrix as follows: 
\[
\frac{\partial\mathbf{f}}{\partial x_{j}}\left(\mathbf{\bar{x}}\right)\simeq\frac{\mathbf{f}\left(\mathbf{\bar{x}+}h\mathbf{e}_{j}\right)-\mathbf{f}\left(\mathbf{\bar{x}}\right)}{h}
\]
where $\mathbf{e}_{j}$ is the $j^{\text{th}}$ vector of the canonical
basis of $\mathbb{R}^{n}$ and $h$ a small real number. Thus, the
Jacobian matrix is approximated by: 
\[
\frac{d\mathbf{f}}{d\mathbf{x}}\left(\mathbf{\bar{x}}\right)\simeq\left(\begin{array}{c}
\\
\frac{\mathbf{f}\left(\mathbf{\bar{x}+}h\mathbf{e}_{1}\right)-\mathbf{f}\left(\mathbf{\bar{x}}\right)}{h}\\
\ 
\end{array}\left\vert \begin{array}{c}
\\
\frac{\mathbf{f}\left(\mathbf{\bar{x}+}h\mathbf{e}_{2}\right)-\mathbf{f}\left(\mathbf{\bar{x}}\right)}{h}\\
\ 
\end{array}\right.\left\vert \begin{array}{c}
\\
\dots\\
\ 
\end{array}\right.\left\vert \begin{array}{c}
\\
\frac{\mathbf{f}\left(\mathbf{\bar{x}+}h\mathbf{e}_{n}\right)-\mathbf{f}\left(\mathbf{\bar{x}}\right)}{h}\\
\ 
\end{array}\right.\right)
\]
To have a correct approximation, we need to take a very small $h$.
However, if $h$ is too small, numerical problems appear. This method
therefore has to be considered weak.

\subsection{Linearization of a dynamic system}

Let us consider the system described by its state equations: 
\[
\mathcal{S}:\left\{ \begin{array}{ccc}
\mathbf{\dot{x}} & = & \mathbf{f}(\mathbf{x},\mathbf{u})\\
\mathbf{y} & = & \mathbf{g}(\mathbf{x,u})
\end{array}\right.
\]
where $\mathbf{x}$ is of dimension $n$, $\mathbf{u}$ is of dimension
$m$ and $\mathbf{y}$ is of dimension $p$. Around the point $(\mathbf{\bar{x},\bar{u}}),$
the behavior of $\mathcal{S}$ is therefore approximated by the following
state equations: 
\[
\left\{ \begin{array}{ccc}
\mathbf{\dot{x}} & = & \mathbf{f}(\mathbf{\bar{x},\bar{u}})+\mathbf{A}\left(\mathbf{x}-\mathbf{\bar{x}}\right)+\mathbf{B}\left(\mathbf{u}-\mathbf{\bar{u}}\right)\\
\mathbf{y} & = & \mathbf{g}(\mathbf{\bar{x},\bar{u}})+\mathbf{C}\left(\mathbf{x}-\mathbf{\bar{x}}\right)+\mathbf{D}\left(\mathbf{u}-\mathbf{\bar{u}}\right)
\end{array}\right.
\]
with:
\[
\begin{array}{cc}
\mathbf{A}=\frac{\partial\mathbf{f}}{\partial\mathbf{x}}\left(\mathbf{\bar{x},\bar{u}}\right), & \mathbf{B}=\frac{\partial\mathbf{f}}{\partial\mathbf{u}}\left(\mathbf{\bar{x},\bar{u}}\right)\\
\mathbf{C}=\frac{\partial\mathbf{g}}{\partial\mathbf{x}}\left(\mathbf{\bar{x},\bar{u}}\right), & \mathbf{D}=\frac{\partial\mathbf{g}}{\partial\mathbf{u}}\left(\mathbf{\bar{x},\bar{u}}\right)
\end{array}
\]
This is an affine system called \emph{tangent system} to $\mathcal{S}$
at point $(\mathbf{\bar{x},\bar{u}}).$

\subsection{Linearization around an operating point}

A point $(\mathbf{\bar{x},\bar{u}})$ is an \emph{operating point}
(also called \emph{polarization point}) if $\mathbf{f}(\mathbf{\bar{x},\bar{u}})=\mathbf{0}$.
If $\mathbf{\bar{u}}=\mathbf{0}$, we are in the case of an \emph{equilibrium
point}. Let us note first of all that if $\mathbf{x}=\mathbf{\bar{x}}$
and if $\mathbf{u}=\mathbf{\bar{u}}$, then $\mathbf{\dot{x}}=\mathbf{0}$,
in other words the system no longer evolves if we maintain the control
$\mathbf{u}=\mathbf{\bar{u}}$ when the system is in the state $\mathbf{\bar{x}}$.
In this case, the output $\mathbf{y}$ has the value $\mathbf{y}=\mathbf{\bar{y}}=\mathbf{g}(\mathbf{\bar{x},\bar{u}})$.
Around the operating point, $(\mathbf{\bar{x},\bar{u}})$, the system
$\mathcal{S}$ admits the tangent system: 
\[
\left\{ \begin{array}{rrr}
\mathbf{\dot{x}} & = & \mathbf{A}\left(\mathbf{x}-\mathbf{\bar{x}}\right)+\mathbf{B}\left(\mathbf{u}-\mathbf{\bar{u}}\right)\\
\mathbf{y} & = & \mathbf{\bar{y}}+\mathbf{C}\left(\mathbf{x}-\mathbf{\bar{x}}\right)+\mathbf{D}\left(\mathbf{u}-\mathbf{\bar{u}}\right)
\end{array}\right.
\]
Let us take $\widetilde{\mathbf{u}}=\mathbf{u}-\mathbf{\bar{u}}$,
$\widetilde{\mathbf{x}}=\mathbf{x}-\mathbf{\bar{x}}$ and $\widetilde{\mathbf{y}}=\mathbf{y}-\mathbf{\bar{y}}$.
These vectors are called the \emph{variations} of $\mathbf{u}$, $\mathbf{x}$
and $\mathbf{y}$. For small variations $\widetilde{\mathbf{u}}$,
$\widetilde{\mathbf{x}}$, $\widetilde{\mathbf{y}},$ we have: 
\[
\left\{ \begin{array}{ccc}
\frac{d}{dt}\widetilde{\mathbf{x}} & = & \mathbf{A}\widetilde{\mathbf{x}}+\mathbf{B}\widetilde{\mathbf{u}}\\
\widetilde{\mathbf{y}} & = & \mathbf{C}\widetilde{\mathbf{x}}+\mathbf{D}\widetilde{\mathbf{u}}
\end{array}\right.
\]
The system thus formed is called the \emph{linearized system} of $\mathcal{S}$
around the operating point\index{operating point} $(\mathbf{\bar{x},\bar{u}})$.

\section{Stabilization of a non-linear system\label{st:stabilisation:NL}}

Let us consider the system described by its state equations:
\[
\mathcal{S}:\left\{ \begin{array}{ccc}
\mathbf{\dot{x}} & = & \mathbf{f}(\mathbf{x},\mathbf{u})\\
\mathbf{y} & = & \mathbf{g}(\mathbf{x})
\end{array}\right.
\]
in which $(\mathbf{\bar{x},\bar{u}})$ constitutes an operating point.
In order for our system to behave like a linear system around $(\mathbf{\bar{x},\bar{u}})$,
let us create the variables $\widetilde{\mathbf{u}}=\mathbf{u}-\mathbf{\bar{u}}$
and $\widetilde{\mathbf{y}}=\mathbf{y}-\mathbf{\bar{y}}$, as represented
on Figure \ref{fig:ctrnlin1}.

\begin{figure}[!h]
\centering \includegraphics[width=2.1646in,height=1.1805in]{ctrnlin1}
\caption{Polarization of the system: the initial system, locally affine (in
the neighborhood of the operating point) is transformed into a locally
linear system}

\label{fig:ctrnlin1} 
\end{figure}

The system with input $\widetilde{\mathbf{u}}$ and output $\widetilde{\mathbf{y}}$
thus designed is called a \emph{polarized system}. The state equations
of the polarized system can be approximated by: 
\[
\left\{ \begin{array}{lll}
\mathbf{\dot{x}} & = & \mathbf{f}(\mathbf{x},\mathbf{u})\simeq\mathbf{A}\cdot\left(\mathbf{x}-\mathbf{\bar{x}}\right)+\mathbf{B}\cdot\left(\mathbf{u}-\mathbf{\bar{u}}\right)=\mathbf{A}\cdot\left(\mathbf{x}-\mathbf{\bar{x}}\right)+\mathbf{B}\cdot\widetilde{\mathbf{u}}\\
\widetilde{\mathbf{y}} & = & -\mathbf{\bar{y}}+\mathbf{y}=-\mathbf{\bar{y}}+\mathbf{g(\mathbf{x})}\simeq-\mathbf{\mathbf{\bar{y}}+\bar{y}}+\mathbf{C}\left(\mathbf{x}-\mathbf{\bar{x}}\right)=\mathbf{C}\cdot\left(\mathbf{x}-\mathbf{\bar{x}}\right)
\end{array}\right.
\]
where $\mathbf{A},$\textbf{ }$\mathbf{B},$\textbf{ }$\mathbf{C}$
are obtained by the calculation of the Jacobian matrix of the functions
$\mathbf{f}$ and $\mathbf{g}$ at point $\left(\mathbf{\bar{x},\bar{u}}\right).$
By taking now $\widetilde{\mathbf{x}}=\mathbf{x}-\mathbf{\bar{x}}$
as state vector instead of $\mathbf{x}$, we obtain: 
\[
\left\{ \begin{array}{lll}
\frac{d}{dt}\widetilde{\mathbf{x}} & = & \mathbf{A}\widetilde{\mathbf{x}}+\mathbf{B}\widetilde{\mathbf{u}}\\
\widetilde{\mathbf{y}} & = & \mathbf{C}\widetilde{\mathbf{x}}
\end{array}\right.
\]
which is the linearized system of the non-linear system. Let $\mathbf{x}_{c}=\mathbf{Ex}$
be the sub-vector of the setpoint variables. We can build a controller
$\mathcal{R}_{\text{L}}$ for this linear system using the \textsc{RegulKLH}
algorithm $\left(\mathbf{A,B,C,E},\mathbf{p}_{\text{con}},\mathbf{p}_{\text{obs}}\right)$
described on page \pageref{sst:regulKLH}. We know that when the setpoint
$\widetilde{\mathbf{w}}$ input into $\mathcal{R}_{\text{L}}$ is
constant, we have $\mathbf{E}\widetilde{\mathbf{x}}=\widetilde{\mathbf{w}}$.
However, we would like the input of the controller $\mathbf{w}$ that
we are building to satisfy $\mathbf{w}=\mathbf{Ex.}$ We therefore
have to build $\widetilde{\mathbf{w}}$ from $\mathbf{w}$ in such
a way that $\mathbf{w}=\mathbf{Ex}$, at equilibrium. We have: 
\[
\widetilde{\mathbf{w}}=\mathbf{E}\widetilde{\mathbf{x}}=\mathbf{E}\left(\mathbf{x}-\mathbf{\bar{x}}\right)=\mathbf{w}-\mathbf{\bar{w}}
\]
where $\mathbf{\bar{w}}=\mathbf{E\bar{x}}$. The controller thus obtained
is represented on Figure \ref{fig:ctrnlin2}, in the thick frame.

\begin{figure}[!h]
\centering \includegraphics[width=6cm]{ctrnlin2} \caption{Stabilization of a non-linear system around an operating point by
a linear controller}

\label{fig:ctrnlin2} 
\end{figure}

This controller stabilizes and decouples our non-linear system around
its operating point. A summary of the method to calculate a controller
for a non-linear system is given below.

\begin{center}
\begin{tabular}{|cl|}
\hline 
 & $\textbf{\textbf{Algorithm}\ensuremath{\;\text{\textsc{RegulNL}}\left(\text{in: }\mathbf{f,g,E,p}_{\text{con}},\mathbf{p}_{\text{obs}},\mathbf{\bar{x},\bar{u}}\text{ ; out : }\mathcal{R}\right)}}$\tabularnewline
\hline 
1 & Check that $\mathbf{f}\left(\mathbf{\bar{x},\bar{u}}\right)=\mathbf{0}$;\tabularnewline
2 & $\ensuremath{\mathbf{\bar{y}}:=\mathbf{g}\left(\mathbf{\bar{x}}\right);\;\mathbf{\bar{w}}:=\mathbf{E\bar{x}};}$\tabularnewline
3 & $\ensuremath{\mathbf{A}:=\frac{\partial\mathbf{f}}{\partial\mathbf{x}}\left(\mathbf{\bar{x},\bar{u}}\right);\;\mathbf{B}:=\frac{\partial\mathbf{f}}{\partial\mathbf{u}}\left(\mathbf{\bar{x},\bar{u}}\right);\,\mathbf{C}:=\frac{\partial\mathbf{g}}{\partial\mathbf{x}}\left(\mathbf{\bar{x},\bar{u}}\right);}$\tabularnewline
4 & $\ensuremath{\mathbf{K}:=\mathbf{\;}}\textsc{place}\ensuremath{\left(\mathbf{A,B,p}_{\text{con}}\right);}$\tabularnewline
5 & $\ensuremath{\mathbf{L}:=\mathbf{\;}\left(\text{\textsc{place}}\left(\mathbf{A}^{\text{T}}\mathbf{,C}^{\text{T}}\mathbf{,p}_{\text{obs}}\right)\right)^{\text{T}};}$\tabularnewline
6 & $\ensuremath{\mathbf{H}:=-\left(\mathbf{E}\left(\mathbf{A}-\mathbf{BK}\right)^{-1}\mathbf{B}\right)^{-1};}$\tabularnewline
7 & $\mathcal{R}:=\left\{ \begin{array}{lll}
\frac{d}{dt}\mathbf{\hat{x}} & = & \left(\mathbf{A}-\mathbf{BK}-\mathbf{LC}\right)\mathbf{\hat{x}}+\mathbf{BH}\left(\mathbf{w}-\mathbf{\bar{w}}\right)+\mathbf{L}\left(\mathbf{\mathbf{y}}-\mathbf{\mathbf{\bar{y}}}\right)\\
\mathbf{u} & = & \mathbf{\bar{u}}-\mathbf{K\hat{x}}+\mathbf{H}\left(\mathbf{w}-\mathbf{\bar{w}}\right)
\end{array}\right.$\tabularnewline
\hline 
\end{tabular}
\par\end{center}

This algorithm returns our controller with inputs $\mathbf{y,w}$
and output $\mathbf{u}$ in the form of its state equations.

\chapter*{Exercises}

\begin{Exercice} Linearization of the predator-prey system \label{exer:linearisation1}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/HqmT6kBilZQ}{https://youtu.be/HqmT6kBilZQ}}

Let us consider the Lotka-Volterra predator-prey system, given by:
\[
\left\{ \begin{array}{ccc}
\dot{x}_{1} & = & \left(1-x_{2}\right)x_{1}\\
\dot{x}_{2} & = & \left(-1+x_{1}\right)x_{2}
\end{array}\right.
\]

1) Linearize this system around a non-zero equilibrium point $\mathbf{\bar{x}}$.

2) Among the two vector fields of Figure \ref{fig:volterra_linearise},
which one represents the field associated with the Lotka-Volterra
system and which one corresponds to its tangent system ?

3) Calculate the poles of the linearized system. Discuss.

\begin{figure}[H]
\centering \includegraphics[width=10cm]{volterra_linearise} \caption{One of the two vector fields is associated with the Lotka-Volterra
system. The other corresponds to its tangent system}

\label{fig:volterra_linearise} 
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Water car \label{exer:masse:fluide} \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/o29wNy16XRk}{https://youtu.be/o29wNy16XRk}}

Consider a car moving horizontally in the water as illustrated by
Figure \ref{fig:watercar}. Its evolution obeys the following differential
equation:
\[
\ddot{y}+\dot{y}.\left\vert \dot{y}\right\vert =u
\]
where $y$ is the position of the car and $u$ is the force exerted
on this car.

1) Give the state equation for this system. We will take as state
vector $\mathbf{x}=\left(y\ \ \dot{y}\right)^{\text{T}}$.

2) Linearize around its equilibrium point. Study the stability of
the system.

3) In the case of a positive initial speed $\dot{y}\left(0\right)$,
give the solution of the non-linear differential equation when $u=0.$
To which value does $y$ converge to? 

\begin{figure}[H]
\centering \includegraphics[width=10cm]{watercar} \caption{The car moves on the sea-floor }

\label{fig:watercar}
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Control of a first-order non-linear system\label{exer:commande:place:poles}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/NrwbXbThk1M}{https://youtu.be/NrwbXbThk1M}}

Let us consider the non-linear system given by the state equations:
\[
\mathcal{S}:\left\{ \begin{array}{lll}
\dot{x} & = & 2x^{2}+u\\
y & = & 3x
\end{array}\right.
\]
which we wish to stabilize around the state $\bar{x}=2$. At equilibrium,
we would like $y$ to be equal to its setpoint $w$. Moreover, we
would like all the poles of the looped system to be equal to $-1.$

1) Give the state equations of the controller using pole placement
which satisfies these constraints.

2) What are the state equations of the looped system? 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} State feedback \label{exer:retour:etat:cablage}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/NifPfedkeek}{https://youtu.be/NifPfedkeek}}

Let us consider the system represented by Figure \ref{fig:schema_pendule}.

\begin{figure}[H]
\centering \includegraphics[width=6cm]{schema_pendule} \caption{block diagram for a non-linear system}

\label{fig:schema_pendule}
\end{figure}

1) Give the state equations of the system.

2) Calculate its equilibrium points.

3) Linearize this system around an equilibrium point $\mathbf{\bar{x}}$
corresponding to $x_{1}=\pi$. Is this a stable equilibrium point
?

4) Propose a state feedback controller of the form $u=-\mathbf{K}\left(\mathbf{x}-\mathbf{\bar{x}}\right)\ $which
stabilizes the system around $\mathbf{\bar{x}}$. Place all poles
at $-1$. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Control of the segway \label{ex:segway:matlab}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/xKQ9Z64Z0xY}{https://youtu.be/xKQ9Z64Z0xY}}

The segway is a vehicle with two wheels and a single axle. We consider
first of all that the segway moves in a straight line and therefore
a two-dimensional model will suffice (see Figure \ref{fig:segway_2fig}).

\begin{figure}[!h]
\centering \includegraphics[width=10cm]{segway_2fig} \caption{Segway which is the subject of the controllability study}

\label{fig:segway_2fig}
\end{figure}

This system has two degrees of freedom: the angle of the wheel $s$
and the pitch $\theta$. Its state vector is therefore the vector
$\mathbf{x}=(s,\theta,\dot{s},\dot{\theta})^{\text{T}}$. When it
is not controlled, the state equations of the segway are (refer to
Exercise \ref{ex:segway}):
\[
\left\{ \begin{array}{ccl}
\left(\begin{array}{l}
\dot{x}_{1}\\
\dot{x}_{2}\\
\dot{x}_{3}\\
\dot{x}_{4}
\end{array}\right) & = & \left(\begin{array}{c}
x_{3}\\
x_{4}\\
\frac{\mu_{3}\left(\mu_{2}x_{4}^{2}-\mu_{g}\cos x_{2}\right)\sin x_{2}+\left(\mu_{2}+\mu_{3}\cos x_{2}\right)u}{\mu_{1}\mu_{2}-\mu_{3}^{2}\cos^{2}x_{2}}\\
\frac{\left(\mu_{1}\mu_{g}-\mu_{3}^{2}x_{4}^{2}\cos x_{2}\right)\sin x_{2}-\left(\mu_{1}+\mu_{3}\cos x_{2}\right)u}{\mu_{1}\mu_{2}-\mu_{3}^{2}\cos^{2}x_{2}}
\end{array}\right)\\
y & = & x_{1}
\end{array}\right.
\]
where:
\[
\begin{array}{ccc}
\mu_{1}=J_{M}+\rho^{2}\left(m+M\right), &  & \mu_{2}=J_{p}+m\ell^{2},\\
\mu_{3}=\rho m\ell, &  & \mu_{g}=g\ell m
\end{array}
\]
The parameters of our system are the mass $M$ of the disk, its radius
$\rho$, its inertial momentum $J_{M}$, the mass $m$ of the body,
its inertial momentum $J_{p}$, the distance $\ell$ between its center
of gravity and the center of the disk. We have added the observation
equation $y=x_{1}$ in order to assume a situation where only the
angle of the wheel $s$ is measured. We will take $m=10~$Kg, $M=1~$Kg,
$\ell=1~$m, $g=10~$ms$^{-2}$, $\rho=1~$m, $J_{p}=10~$Kg.m$^{2}$
and $J_{M}=\frac{1}{2}M\rho^{2}$. Note that, since $\rho=1$, the
angle $s$ also correspond to the displacement of the segway.

1) Calculate the operating points of the system.

2) Linearize the system around an upper equilibrium point, for $s=0.$

3) By using the controllability matrix, determine whether the system
is controllable. 

4) Simulate this system by using Euler's method, in different situations.

5) We assume that we measure the angle $s$ using an odometer. Calculate
an output feedback controller which allows to place the segway at
a given position. We will place all the poles around $-2$ (be careful,
the pole placement algorithm usually does not allow two identical
poles). Propose a simulation to validate the stability of your controller.
Validate the robustness of your control by adding sensor noise to
the measure of $\mathbf{x}$, which is white and Gaussian.

6) Given the model of the tank, propose a 3D model for the segway.
The chosen state vector will be: 
\[
\mathbf{x}=(\theta,\dot{s},\dot{\theta},x,y,\psi,s_{1},s_{2})^{\text{T}}
\]
where $s_{1}$ is the angle of the right wheel, $s_{2}$ the angle
of the left wheel, $\psi$ is the heading of the segway and the $\left(x,y\right)$
the coordinates of the center of the Segway's axle. The input are
the body/wheels pair $u_{1}$ and the differential between the wheels
$u_{2}$. Here, $\dot{s}$ represents the average angular speed between
the two wheels, i.e. $\dot{s}=\frac{1}{2}\left(\dot{s}_{1}+\dot{s}_{2}\right)$.
Propose a control which allows to regulate the segway speed- and heading-wise. 

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:asserv:pendule:inv}Controlling an inverted
rod pendulum \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/ft7lOc4r1ws}{https://youtu.be/ft7lOc4r1ws}}

Let us consider the inverted rod pendulum represented on Figure \ref{fig:pendule_inverse},
composed of a pendulum placed in unstable equilibrium on a carriage.

\begin{figure}[!h]
\centering \includegraphics[width=5cm]{pendule_inverse_ctrl} \caption{Inverted rod pendulum that we need to control}

\label{fig:pendule_inverse} 
\end{figure}

The value $u$ is the force exerted on the carriage of mass $m_{c}=5~kg$,
$s$ indicates the position of the carriage, $\theta$ is the angle
between the pendulum. At the tip $\mathbf{b}$ of the pendulum of
length $\ell=4~m$ is a fixated mass $m_{r}=1~\text{Kg}$. Finally,
$\mathbf{a}$ is the point of articulation between the rod and the
carriage. As seen in Exercise \ref{ex:pendule_inverse}, the state
equations of this system are: 
\[
\left\{ \begin{array}{ccc}
\left(\begin{array}{l}
\dot{x}_{1}\\
\dot{x}_{2}\\
\dot{x}_{3}\\
\dot{x}_{4}
\end{array}\right) & = & \left(\begin{array}{c}
x_{3}\\
x_{4}\\
\frac{m_{r}(\sin x_{2})\cdot(g\cos x_{2}-\ell x_{4}^{2})+u}{m_{c}+m_{r}\sin^{2}x_{2}}\\
\frac{(\sin x_{2})\cdot((m_{c}+m_{r})g-m_{r}\ell x_{4}^{2}\cos x_{2})+\cos x_{2}u}{\ell(m_{c}+m_{r}\sin^{2}x_{2})}
\end{array}\right)\\
y & = & x_{1}
\end{array}\right.
\]
where: 
\[
\mathbf{x}=\left(x_{1},x_{2},x_{3},x_{4}\right)^{\text{T}}=(s,\theta,\dot{s},\dot{\theta})^{\text{T}}.
\]
The observation equation indicates that only the position of the carriage
$x_{1}$ is measured.

1) Calculate all the operating points of the system.

2) Linearize the system around the operating point $\mathbf{\bar{x}}=\left(0,0,0,0\right)$
and $\bar{u}=0$.

3) Obtain an output feedback controller which sets all the poles of
the looped system to $-2.$ We propose a control in position, which
means that the setpoint $w$ corresponds to $x_{1}.$ Illustrate by
a simulation the behavior of the controller.

4) Create a state feedback control which allows to raise the pendulum
when it leaves its bottom position. For this, we will attempt to stabilize
the mechanical energy of the pendulum before moving on to a linear
control. We will assume that $u\in\left[-u_{\max},u_{\max}\right].$
Illustrate on a simulation.

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:lqr}Linear Quadratic Regulator \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/257kfCdaKhs}{https://youtu.be/257kfCdaKhs}}

Consider the state space system
\[
\dot{\mathbf{x}}=\mathbf{A}\mathbf{x}+\mathbf{B}\mathbf{u}
\]
and the cost function
\[
J(\mathbf{x}(\cdot),\mathbf{u}(\cdot))=\int_{0}^{\infty}(\mathbf{x}^{\text{T}}\mathbf{Q}\mathbf{x}+\mathbf{u}^{\text{T}}\mathbf{R}\mathbf{u})\cdot dt.
\]

It can be shown that a feedback control law that minimizes the value
of the cost is given by $\mathbf{u}=-\mathbf{K}\mathbf{x}$ where
\[
\mathbf{K}=\mathbf{R}^{-1}\mathbf{B}^{\text{T}}\mathbf{P}
\]
where $\mathbf{P}$ is found by solving the continuous time algebraic
Riccati equation given by
\[
\mathbf{A}^{\text{T}}\mathbf{P}+\mathbf{P}\mathbf{A}-(\mathbf{P}\mathbf{B})\mathbf{R}^{-1}(\mathbf{B}^{\text{T}}\mathbf{P})+\mathbf{Q}=\mathbf{0}.
\]

We assume this result that can be found using optimal control theory.
The corresponding controller is called LQR (Linear Quadratic Regulator).
The main advantage of the LQR is that it allows us to give weights
to the required dynamics. In general, the matrices are chosen as diagonal. 

Consider the inverted pendulum of Exercise \ref{ex:asserv:pendule:inv}.
We assume that the state is measured without any error.

1) With a pole-placement, propose a controller for the system. Draw
the functions $s(t),\theta(t),u(t)$.

2) Find a value for $\mathbf{K}$ such that the system initialized
at $\mathbf{x}(0)=\left(2,0,0,0\right)$ satisfies $\forall t\geq5,|x_{1}(t)|<0.2$,
$|u(t)|\leq0.3$. Give the poles of the closed loop system. Compare
with the pole placement method.

3) Find a value for $\mathbf{K}$ such that the system initialized
at $\mathbf{x}(0)$ satisfies $\forall t\geq2,|x_{1}(t)|<0.2$. 

4) We now have $\mathbf{x}(0)=(50,0,0,0).$ How do we have to choose
the controller $\mathbf{K}$ to be able to get a stabilization at
$\mathbf{0}$?

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} \label{ex:asserv:voiture}Autonomous car \end{Exercice}

\textcolor{blue}{See the correction video at \href{https://youtu.be/cP5x4wiaFxc}{https://youtu.be/cP5x4wiaFxc}}

Here, we will address the case of a car which drives on an unknown
road. The car is equipped with (i) a rangefinder which measures the
lateral distance $d$ between the rear axle of the car and the edge
of the road, (ii) a speed sensor which measures the speed $v$ of
the front wheels, and (iii) an angle sensor which measures the angle
$\delta$ of the steering wheel (for reasons of simplification, we
will assume that $\delta$ corresponds also to the angle between the
front wheels and the axis of the car). For our simulations, we will
assume that our car is driving around a closed polygon as shown on
Figure \ref{fig:circuitvoiture}.

\begin{figure}[!h]
\centering \includegraphics[width=8cm]{circuitvoiture} \caption{Car turning around a polygon}

\label{fig:circuitvoiture} 
\end{figure}

1) Let $\mathbf{m}$, $\mathbf{a}$, $\mathbf{b}$ be three points
of $\mathbb{R}^{2}$ and $\overrightarrow{\mathbf{u}}$ a vector.
Show that the half-line $\mathcal{E}\left(\mathbf{m,}\overrightarrow{\mathbf{u}}\right)$
with vertex $\mathbf{m}$ and direction vector $\overrightarrow{\mathbf{u}}$
intersects the segment $\left[\mathbf{ab}\right]$ if and only if:
\[
\left\{ \begin{array}{cc}
\det\left(\mathbf{a}-\mathbf{m},\overrightarrow{\mathbf{u}}\right).\det\left(\mathbf{b}-\mathbf{m},\overrightarrow{\mathbf{u}}\right) & \leq0\\
\det(\mathbf{a}-\mathbf{m},\mathbf{b}-\mathbf{a}).\det(\overrightarrow{\mathbf{u}},\mathbf{b}-\mathbf{a}) & \geq0
\end{array}\right.
\]
Moreover, show that, in this case, the distance from the point $\mathbf{m}$
to the segment $\left[\mathbf{ab}\right]$ following the vector $\overrightarrow{\mathbf{u}}$
is given by: 
\[
d=\frac{\det(\mathbf{a}-\mathbf{m},\mathbf{b}-\mathbf{a})}{\det(\overrightarrow{\mathbf{u}},\mathbf{b}-\mathbf{a})}.
\]

2) We would like to make the car moving (without using a controller)
around the polygon using Euler's method. As seen in Exercise \ref{ex:modele:voiture},
we could take as evolution equation: 
\[
\left(\begin{array}{l}
\dot{x}\\
\dot{y}\\
\dot{\theta}\\
\dot{v}\\
\dot{\delta}
\end{array}\right)=\left(\begin{array}{c}
v\cos\delta\cos\theta\\
v\cos\delta\sin\theta\\
v\sin\delta\\
u_{1}\\
u_{2}
\end{array}\right)
\]
Here $\left(x,y\right)$ represents the coordinates of the center
of the car, $\theta$ its heading. The polygon representing the circuit
will be represented by the matrix:
\[
\mathbf{P}=\left(\begin{array}{ccccccccccccccccccccc}
-10 & \, & -10 & \, & 0 & \, & 10 & \, & 20 & \, & 32 & \, & 35 & \, & 30 & \, & 20 & \, & 0 & \, & -10\\
-5 &  & 5 &  & 15 &  & 20 &  & 20 &  & 15 &  & 10 &  & 0 &  & -3 &  & -6 &  & -5
\end{array}\right)
\]
Since the polygon is closed, the first and last columns of $\mathbf{P}$
are identical. Give an expression of the observation function of the
system which returns the distance measured by the rangefinder as well
as $v$ and $\delta$.

3) We would like the car to move with a constant speed along the road.
Of course, it is out of the question to involve the shape of the road
in the controller, since it is unknown. Moreover, the position and
orientation variables of the car are not measured (in other words
we have no compass or GPS). These quantities however are often unnecessary
in order to reach the given objective, which is following the road.
Indeed, are we not ourselves capable of driving a car on a road without
having a local map, without knowing where we are and where North is
? What we are interested in when driving a car is the relative position
of the car with respect to the road. The world as seen by the controller
is represented on Figure \ref{fig:voiturenord}. In this world, the
car moves laterally, like in a computer game, and the edge of the
road remains fixed. This world has to be such that the model used
by the controller has state variables describing this relative position
of the car with respect to the road and that the constancy of the
state variables of this model corresponds to a real situation in which
the car follows the road with a constant speed. We need to imagine
an ideal world for the controller in which the associated model admits
an operating point which corresponds to the desired behavior of our
real system. For this, we will assume that our car drives at a distance
$\bar{x}$ of the edge. This model has to have the same inputs $\mathbf{u}$
and outputs $\mathbf{y}$ as the real system, more precisely two inputs
(the acceleration of the front wheels $\dot{v}$ and the angular speed
of the steering wheel $\dot{\delta}$) and three outputs (the distance
$d$ of the center of the rear axle to the edge of the road, the speed
$v$ of the front wheels and the angle $\delta$ of the steering wheel).
Given the fact that only the relative position of the car is of interest
to us, our model must only contain four state variables: $x,\theta,v,\delta$,
as represented on the figure. One must be careful though, since the
meaning of the variable $x$ has changed since the previous model.
Find the state equations (in other words, the evolution equation and
the observation equation) of the system imagined by the controller.

4) Let us choose as operating point 
\[
\mathbf{\bar{x}}=\left(5,\pi/2,7,0\right)\text{ et }\mathbf{\bar{u}}=\left(0,0\right)
\]
which corresponds to a speed of $7ms^{-1}$ and a distance of $5m$
between the center of the rear axle and the edge of the road. Linearize
the system around its operating point.

5) We want our setpoints $w_{1}$ and $w_{2}$ to correspond to the
distance of the edge of the road and the speed of the car. Design
a controller by pole placement. All the poles in the interval $[-2,-1]$.

6) Test the behavior of your controller in the case where the car
is turning around the polygon. Note that the system being controlled
(in other words the turning car) by the controller is different than
that it thinks it is controlling (i.e. a car in a straight line).
You should obtain a behavior similar to that illustrated by Figure
\ref{fig:circuitvoiture}.

\begin{figure}[H]
\centering \includegraphics[width=9cm]{voiturenord} \caption{The controller imagines a simpler world than reality, with a straight
vertical wall}

\label{fig:voiturenord} 
\end{figure}

\rule{0.95\columnwidth}{1pt}

\begin{Exercice} Follow the car\label{exer:commande:feedback_lin}
\end{Exercice}

\textcolor{blue}{See the correction video at \href{http://tBeIozR3J8M}{tBeIozR3J8M}}

\noindent \textsc{First part}.\textendash{} (proportional and derivative
control)\emph{.} Let us consider a second-order system described by
the differential equation $\ddot{y}=u,$ where $u$ is the input and
$y$ the output.

1) Give a state representation for this system. The chosen state vector
is given by $\mathbf{x}=\left(y,\dot{y}\right)$.

2) We would like to control this system using a proportional and derivative
control of the type:
\[
u=k_{1}(w-y)+k_{2}\left(\dot{w}-\dot{y}\right)+\ddot{w}
\]
where $w$ is a known function (for instance a polynomial) called
\emph{setpoint} and which can here depend on the time $t$. Let us
note that here, we have assumed that $y$ and $\dot{y}$ were available
for the controller. Give the differential equation satisfied by the
error $e=w-y$ between the setpoint and the output $y$.

3) Calculate $k_{1}$ and $k_{2}$, allowing to have an error $e$
which converges towards $0$ in an exponential manner, with all the
poles equal to $-1.$ 

\noindent \textsc{Second part}.\textendash{} (control of a tank-like
vehicle). Let us consider the robotic vehicle on the left hand side
of Figure \ref{fig:robot_train1}, described by:
\[
\left\{ \begin{array}{ccc}
\dot{x} & = & v\cos\theta\\
\dot{y} & = & v\sin\theta\\
\dot{\theta} & = & u_{1}\\
\dot{v} & = & u_{2}
\end{array}\right.
\]
where $v$ is the speed of the robot, $\theta$ its orientation and
$(x,y)$ the coordinates of its center. We assume that we are capable
of measuring all the state variables of our robot with great precision.

\begin{figure}[H]
\centering \includegraphics[width=9cm]{robot_train1} \caption{Our robot (with eyes) follows a vehicle (here a car) which has\break
an attachment point (small white circle) to which the robot has to
attach}

\label{fig:robot_train1} 
\end{figure}

1) Let us denote by $\mathbf{x}=(x,y,\theta,v)$ the state vector
of our robot and $\mathbf{u}=\left(u_{1},u_{2}\right)$ the vector
of the inputs. Calculate $\ddot{x}$ and $\ddot{y}$ in function of
$\mathbf{x}$ of $\mathbf{u}$. Show that: 
\[
\left(\begin{array}{c}
\ddot{x}\\
\ddot{y}
\end{array}\right)=\mathbf{A}(\mathbf{x}).\mathbf{u}
\]
where $\mathbf{A}(\mathbf{x})$ is a $2\times2$ matrix.

2) Another mobile vehicle (on the right hand side of Figure \ref{fig:robot_train1})
tell us, in a wireless manner, the precise coordinates $\left(x_{a},y_{a}\right)$
of a virtual attachment point (in other words one that only exists
mentally), fixed with respect to this vehicle, to which we need to
position ourselves. This means that we want the center of the robot
$\left(x,y\right)$ to be such that $x(t)=x_{a}(t)$ and $y(t)=y_{a}(t)$.
This vehicle also sends us the first two derivatives $\left(\dot{x}_{a},\dot{y}_{a},\ddot{x}_{a},\ddot{y}_{a}\right)$
of the coordinates of the attachment points. Propose the expression
of a control $\mathbf{u}\left(\mathbf{x},x_{a},y_{a},\dot{x}_{a},\dot{y}_{a},\ddot{x}_{a},\ddot{y}_{a}\right)$
which ensures us that the distance between the position $\left(x,y\right)$
of our robot and that of the attachment point $\left(x_{a},y_{a}\right)$
decreases in an exponential manner. We will set the poles at $-1$. 

\noindent \textsc{Advice}.\textendash{} Perform a first loop as such:
$\mathbf{u}=\mathbf{A}^{-1}(\mathbf{x})\cdot\mathbf{q},$ where $\mathbf{q}=\left(q_{1},q_{2}\right)$
is our new input. This first loop will allow you to simplify your
system by making it linear. Then, proceed with a second, proportional
and derivative loop.

\bibliographystyle{unsrt}
\bibliography{interval}

\end{document}
