#+TITLE: Closed-Loop Shaping using Complementary Filters
:DRAWER:
#+LANGUAGE: en
#+EMAIL: dehaeze.thomas@gmail.com
#+AUTHOR: Dehaeze Thomas

#+PROPERTY: header-args:latex  :headers '("\\usepackage{tikz}" "\\usepackage{import}" "\\import{$HOME/Cloud/tikz/org/}{config.tex}")
#+PROPERTY: header-args:latex+ :imagemagick t :fit yes
#+PROPERTY: header-args:latex+ :iminoptions -scale 100% -density 150
#+PROPERTY: header-args:latex+ :imoutoptions -quality 100
#+PROPERTY: header-args:latex+ :results file raw replace
#+PROPERTY: header-args:latex+ :buffer no
#+PROPERTY: header-args:latex+ :tangle no
#+PROPERTY: header-args:latex+ :eval no-export
#+PROPERTY: header-args:latex+ :exports results
#+PROPERTY: header-args:latex+ :mkdirp yes
#+PROPERTY: header-args:latex+ :output-dir figs
#+PROPERTY: header-args:latex+ :post pdf2svg(file=*this*, ext="png")
:END:

#+begin_src latex :file detail_control_cf_arch.pdf
\tikzset{block/.default={0.8cm}{0.6cm}}
\tikzset{addb/.append style={scale=0.7}}
\tikzset{node distance=0.6}
\def\cdist{0.7}

\begin{tikzpicture}
  \node[addb={+}{}{}{}{-}] (addfb) at (0, 0){};
  \node[block, right=0.3 of addfb] (K){$k$};
  \node[block, right=2.2 of K] (G){$G^\prime$};
  \node[addb={+}{}{}{}{}, right=0.3 of G] (adddy){};
  \coordinate[] (KG) at ($(K.east)+(0.3, 0)$);
  \node[block, below=of KG] (Gm){$G$};
  \node[block, below=0.4 of Gm] (Hh){$H_H$};
  \node[addb={+}{}{}{}{}, below=0.4 of Hh] (addcf){};
  \node[block, right=0.3  of addcf] (Hl) {$H_L$};
  \node[addb={+}{}{}{}{}, right=2.1 of Hl] (addn) {};


  \draw[->] (addfb.east) -- (K.west) node[above left]{};
  \draw[->] (K.east) -- (G.west) node[above left]{$u$};
  \draw[->] (KG) node[branch]{} -- (Gm.north);
  \draw[->] (Gm.south) -- (Hh.north);
  \draw[->] (Hh.south) -- (addcf.north) node[above left]{};
  \draw[->] (Hl.west) -- (addcf.east);
  \draw[->] (addcf.west) -| (addfb.south) node[below right]{};
  \draw[->] (G.east) -- (adddy.west);
  \draw[<-] (addn.east) -- ++(0.5, 0) coordinate[](endpos) node[above left]{$n$};
  \draw[->] (adddy.east) -- (G-|endpos) node[above left]{$y$};
  \draw[->] (adddy-|addn) node[branch]{} -- (addn.north);
  \draw[<-] (addfb.west) -- ++(-0.5, 0) node[above right](r){$r$};
  \draw[->] (addn.west) -- (Hl.east) node[above right]{$y_m$};
  \draw[<-] (adddy.north) -- ++(0, 0.5) node[below right]{$d_y$};

  \begin{scope}[on background layer]
    \node[fit={(Hl.south east) (r.north west)}, inner sep=4pt, draw, fill=black!20!white, dashed, label={RT controller}] (Kfb) {};
  \end{scope}
\end{tikzpicture}
#+end_src

#+RESULTS:
[[file:figs/detail_control_cf_arch.png]]

#+begin_src latex :file detail_control_cf_arch_eq.pdf
\tikzset{block/.default={0.8cm}{0.6cm}}
\tikzset{addb/.append style={scale=0.7}}
\tikzset{node distance=0.6}
\def\cdist{0.7}

\begin{tikzpicture}
  \node[addb={+}{}{}{}{-}] (addfb) at (0, 0){};
  \node[addb={+}{}{}{}{-}, right=0.3 of addfb] (addK){};
  \node[block, right=0.6 of addK] (K){$k$};
  \node[block, right=1.5 of K] (G){$G^\prime$};
  \node[addb={+}{}{}{}{}, right=0.3 of G] (adddy){};
  \node[block, below right=0.5 and -0.15 of K] (Gm){$G$};
  \node[block, below left =0.5 and -0.15 of K] (Hh){$H_H$};
  \node[block, below=1.5 of K] (Hl) {$H_L$};
  \node[addb={+}{}{}{}{}, right=3.0 of Hl] (addn) {};

  \draw[->] (addfb.east) -- (addK.west);
  \draw[->] (addK.east) -- (K.west);
  \draw[->] (K.east) -- (G.west) node[above left]{$u$};
  \draw[->] (G.east) -- (adddy.west);
  \draw[->] ($(G.west)+(-0.5, 0)$) node[branch](cffb){} |- (Gm.east);
  \draw[->] (Gm.west) -- (Hh.east);
  \draw[->] (Hh.west) -| (addK.south);
  \draw[<-] (addn.east) -- ++(0.5, 0) coordinate[](endpos) node[above left]{$n$};
  \draw[->] (adddy.east) -- (G-|endpos) node[above left]{$y$};
  \draw[->] (adddy-|addn) node[branch]{} -- (addn.north);
  \draw[<-] (addfb.west) -- ++(-0.5, 0) node[above right](r){$r$};
  \draw[->] (addn.west) -- (Hl.east) node[above right]{$y_m$};
  \draw[<-] (adddy.north) -- ++(0, 0.5) node[below right]{$d_y$};
  \draw[->] (Hl.west) -| (addfb.south) node[below right]{};

  \begin{scope}[on background layer]
    \node[fit={(Hl.south -| cffb) (r.north west)}, inner sep=4pt, draw, fill=black!20!white, dashed, label={RT controller}] (Kfb) {};
  \end{scope}
\end{tikzpicture}
#+end_src

#+RESULTS:
[[file:figs/detail_control_cf_arch_eq.png]]

#+begin_src latex :file detail_control_cf_arch_class.pdf
\tikzset{block/.default={0.8cm}{0.6cm}}
\tikzset{addb/.append style={scale=0.7}}
\tikzset{node distance=0.6}
\def\cdist{0.7}

\begin{tikzpicture}
  \node[addb={+}{}{}{}{-}] (addfb) at (0, 0){};
  \node[block, right=of addfb] (K){$K$};
  \node[block, right=of K] (G){$G^\prime$};
  \node[addb={+}{}{}{}{}, right=of G] (adddy){};
  \node[addb={+}{}{}{}{}, below right=0.7 and 0.3 of adddy] (addn) {};
  \node[block] (Hl) at (K|-addn) {$H_L$};

  \draw[->] (addfb.east) -- (K.west) node[above left]{};
  \draw[->] (K.east) -- (G.west) node[above left]{$u$};
  \draw[->] (G.east) -- (adddy.west);
  \draw[<-] (addn.east) -- ++(\cdist, 0) coordinate[](endpos) node[above left]{$n$};
  \draw[->] (G-|addn)node[branch]{} -- (addn.north);
  \draw[->] (adddy.east) -- (G-|endpos) node[above left]{$y$};
  \draw[<-] (addfb.west) -- ++(-\cdist, 0) node[above right](r){$r$};
  \draw[->] (addn.west) -- (Hl.east);
  \draw[->] (Hl.west) -| (addfb.south);
  \draw[<-] (adddy.north) -- ++(0, \cdist) node[below right]{$d_y$};

  \begin{scope}[on background layer]
    \node[fit={(Hl.south east) (r.north west)}, inner sep=4pt, draw, fill=black!20!white, dashed, label={RT controller}] (Kfb) {};
  \end{scope}
\end{tikzpicture}
#+end_src

#+RESULTS:
[[file:figs/detail_control_cf_arch_class.png]]

#+begin_src latex :file detail_control_cf_input_uncertainty.pdf
\tikzset{block/.default={0.8cm}{0.6cm}}
\tikzset{addb/.append style={scale=0.7}}
\tikzset{node distance=0.6}
\def\cdist{0.7}

\begin{tikzpicture}
  % Blocs
  \node[block] (G) {$G$};

  \node[addb, left= of G] (addi) {};
  \node[block, above left=0.3 and 0.3 of addi] (deltai) {$\Delta_I$};
  \node[block, left= of deltai] (wi) {$w_I$};
  \node[branch] (branch) at ($(wi.west|-addi)+(-0.4, 0)$) {};

  % Connections and labels
  \draw[->] (branch.center) |- (wi.west);
  \draw[->] ($(branch)+(-0.6, 0)$) -- (addi.west);
  \draw[->] (wi.east) -- (deltai.west);
  \draw[->] (deltai.east) -| (addi.north);
  \draw[->] (addi.east) -- (G.west);
  \draw[->] (G.east) -- ++(0.6, 0);

  \begin{scope}[on background layer]
    \node[fit={(branch|-wi.north) (G.south east)}, inner sep=6pt, draw, dashed, fill=black!20!white] (Gp) {};
    \node[below left] at (Gp.north east) {$G\prime$};
  \end{scope}
\end{tikzpicture}
#+end_src

#+RESULTS:
[[file:figs/detail_control_cf_input_uncertainty.png]]

#+begin_src latex :file detail_control_cf_arch_tunable_params.pdf
\tikzset{block/.default={0.8cm}{0.6cm}}
\tikzset{addb/.append style={scale=0.7}}
\tikzset{node distance=0.6}
\def\cdist{0.7}

\begin{tikzpicture}
  \node[addb={+}{}{}{}{-}] (addfb) at (0, 0){};
  \node[block, right=of addfb] (Hh){$H_H^{-1}$};
  \node[block, right=of Hh] (Ginv){$G^{-1}$};
  \node[block, right=of Ginv] (G){$G^\prime$};
  \node[addb={+}{}{}{}{}, right=of G] (adddy){};
  \node[addb={+}{}{}{}{}, below right=1.2 and 0.3 of adddy] (addn) {};
  \node[block] (Hl) at (Hh|-addn) {$H_L$};

  \node[color=colorred] (wb) at ($0.5*(Hh.south) + 0.5*(Hl.north)$) {$\bullet$};
  \draw[-, color=colorred] ($(wb) + (-0.6, 0)$)node[left]{$\omega_0$} -- (wb.center);
  \draw[->, color=colorred] (wb.center) -- (Hh.south);
  \draw[->, color=colorred] (wb.center) -- (Hl.north);

  \draw[->] (addfb.east) -- (Hh.west);
  \draw[->] (Hh.east) -- (Ginv.west);
  \draw[->] (Ginv.east) -- (G.west) node[above left]{$u$};
  \draw[->] (G.east) -- (adddy.west);
  \draw[<-] (addn.east) -- ++(\cdist, 0) coordinate[](endpos) node[above left]{$n$};
  \draw[->] (G-|addn)node[branch]{} -- (addn.north);
  \draw[->] (adddy.east) -- (G-|endpos) node[above left]{$y$};
  \draw[<-] (addfb.west) -- ++(-\cdist, 0) node[above right](r){$r$};
  \draw[->] (addn.west) -- (Hl.east);
  \draw[->] (Hl.west) -| (addfb.south);
  \draw[<-] (adddy.north) -- ++(0, \cdist) node[below right]{$d_y$};

  \begin{scope}[on background layer]
    \node[fit={(Hl.south -| Ginv.east) (r.north west)}, inner sep=4pt, draw, fill=black!20!white, dashed, label={RT controller}] (Kfb) {};
  \end{scope}
\end{tikzpicture}
#+end_src

#+RESULTS:
[[file:figs/detail_control_cf_arch_tunable_params.png]]
