State Feedback
Table of Contents
Reference
% system in ss
c = 1;
m = 1;
gamma = 1;
A = -gamma;
B = c/m;
C = 1;
D = 0;
Gss = ss(A,B,C,D);
% P controller
k = 5;
C = k;
% close loop
Gcl = feedback(C*Gss,1,-1);
x0 = 0;
t = linspace(0,5,100);
r = 70*ones(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y,tout,r,'--k'), xlabel('t'), ylim([0,75])
$$
\begin{align*}
u &= r-Ky = -KCx \\\\
\dot{x} &= Ax + Bu = Ax - BKCx = (A-BKC)x
\end{align*}
$$
$$
\begin{align*}
\dot{x} &= \left(\begin{bmatrix} 0 & 1 \\ 0 & 0\end{bmatrix} - \begin{bmatrix} 0 \\ 1\end{bmatrix} 1 \begin{bmatrix} 1 & 0 \end{bmatrix} \right) x \\\\
\dot{x} & = \begin{bmatrix} 0 & 1 \\ -1 & 0\end{bmatrix}x \\ \\
\text{eig} (A-BKC) &= \pm \,j
\end{align*}
$$
% to move towards the origin
% u = -y
A = [0 1;0 0];
B = [0 1]';
C = [1 0];
D = 0;
G = ss(A,B,C,D);
K = 1;
Gcl = feedback(G,K,-1);
x0 = [1 0]';
t = linspace(0,10,100);
r = zeros(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y), xlabel('t')
eig(Gcl)
A = [0 1;0 0];
B = [0 1]';
C = [1 0];
D = 0;
G = ss(A,B,C,D);
k1 = 1;
k2 = 1;
K = [k1 k2];
Gcl = ss(A-B*K,B,C,D);
x0 = [1 0]';
t = linspace(0,30,100);
r = zeros(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y,tout,zeros(size(tout)),'k--'), xlabel('t')
eig(Gcl)
A = [0 1;0 0];
B = [0 1]';
C = [1 0];
D = 0;
G = ss(A,B,C,D);
k1 = 0.1;
k2 = 1;
K = [k1 k2];
Gcl = ss(A-B*K,B,C,D);
x0 = [1 0]';
t = linspace(0,30,100);
r = zeros(size(t));
[y,tout] = lsim(Gcl,r,t,x0);
plot(tout,y,tout,zeros(size(tout)),'k--'), xlabel('t')
How should we pick the eigenvalues? (Mix of art and science)
$\quad\;\rightarrow$ no $k_1$ and $k_2$ exist
A = [2 0;
1 -1];
B = [1 1]';
C = [1 0];
P = [-0.5 + 1j, -0.5 - 1j];
%P = [-0.1 + 1j, -0.1 - 1j];
%P = [-0.5, -1];
%P = [-5, -4];
K = place(A,B,P)
x0 = [1 1]';
Gcl = ss(A-B*K,B,C, 0);
t = linspace(0,5,100);
u = zeros(size(t));
[y, tout] = lsim(Gcl,u,t,x0);
plot(tout,y,tout,zeros(size(tout)),'k--'), xlabel('t')
ctrb(A, B)
is the MATLAB function to form a controllability matrix, $C$Example 1
A = [2 0;
1 1];
B = [1 1]';
G = ctrb(A,B)
rank(G)
Example 2
A = [0 1;
0 0];
B = [0 1]';
G = ctrb(A,B)
rank(G)
$\quad \;$ 1) Make a copy of the system
$\quad \;$ 2) Add a notion of how wrong your estimate is to the model
obsv(A, C)
is the MATLAB function to form a observability matrixExample 1
A = [1 1;
4 -2];
C = [1 0;
0 1];
ob = obsv(A,C)
rank(ob)
$\quad\;$ Step 1) Design the stat feedback controller as if we had $x$ (which we don't)
$\quad\;$ Step 2) Estimate $x$ using an observer (that now also contains $u$)
$\quad\;$ or
%%html
<center><iframe src="https://www.youtube.com/embed/kQNUpNh6nBc?list=PLp8ijpvp8iCvFDYdcXqqYU5Ibl_aOqwjr?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/W6AUOyj5bFA?list=PLp8ijpvp8iCvFDYdcXqqYU5Ibl_aOqwjr?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/HmqOnsRH73w?list=PLp8ijpvp8iCvFDYdcXqqYU5Ibl_aOqwjr?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/m3-2ppIIWrk?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/S4WZTmEnbrY?list=PLp8ijpvp8iCvFDYdcXqqYU5Ibl_aOqwjr?rell=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/5tWhOK8Klo0?list=PLp8ijpvp8iCvFDYdcXqqYU5Ibl_aOqwjr?rel=0"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%javascript
$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')