#+TITLE: Tikz Figures
:DRAWER:
#+HTML_LINK_HOME: ../index.html
#+HTML_LINK_UP:   ../index.html

#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="https://research.tdehaeze.xyz/css/style.css"/>
#+HTML_HEAD: <script type="text/javascript" src="https://research.tdehaeze.xyz/js/script.js"></script>

#+PROPERTY: header-args:latex  :headers '("\\usepackage{tikz}" "\\usepackage{import}" "\\import{/home/thomas/Cloud/thesis/papers/dehaeze21_mechatronics_approach_nass/tikz/}{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+ :eval no-export
#+PROPERTY: header-args:latex+ :exports both
#+PROPERTY: header-args:latex+ :mkdirp yes
#+PROPERTY: header-args:latex+ :output-dir figs
#+PROPERTY: header-args:latex+ :post pdf2svg(file=*this*, ext="png")
:END:

* Mechatronic Approach
#+begin_src latex :file nass_mechatronics_approach.pdf
\graphicspath{ {/home/thomas/Cloud/thesis/papers/dehaeze21_mechatronics_approach_nass/tikz/figs-tikz} }

\begin{tikzpicture}
  % Styles
  \tikzset{myblock/.style= {draw, fill=white, text width=3cm, align=center, minimum height=1.8cm}};
  \tikzset{mylabel/.style= {anchor=north, below, font=\bfseries\small, color=black, text width=3cm, align=center}};
  \tikzset{mymodel/.style= {anchor=south, above, font=\small, color=black, text width=3cm, align=center}};
  \tikzset{mystep/.style=  {->, ultra thick}};

  % Blocks
  \node[myblock, fill=lightblue, draw, label={[mylabel, text width=9.8cm] Dynamical Models / Simulations / Control}, minimum height = 6cm, text width = 9.8cm] (model) at (0, 0) {};

  \node[myblock, fill=lightgreen, label={[mylabel] $\mu$ Station}, left = 3 of model.south west, anchor=south east] (mustation) {};
  \node[myblock, fill=lightgreen, label={[mylabel] Disturbances},  left = 3 of model.west]                          (dist) {};
  \node[myblock, fill=lightgreen, label={[mylabel] $\nu$ Hexapod}, left = 3 of model.north west, anchor=north east] (nanohexapod) {};

  \node[myblock, fill=lightyellow, label={[mylabel] Mech. Design},    above = 1 of model.north] (mechanical) {};
  \node[myblock, fill=lightyellow, label={[mylabel] Instrumentation}, left  = 1 of mechanical]  (instrumentation) {};
  \node[myblock, fill=lightyellow, label={[mylabel] FEM},             right = 1 of mechanical]  (fem) {};

  \node[myblock, fill=lightred, label={[mylabel] Assembly},       right = 3 of model.north east, anchor=north west] (mounting) {};
  \node[myblock, fill=lightred, label={[mylabel] Test Benches},   right = 3 of model.east]                          (testbenches) {};
  \node[myblock, fill=lightred, label={[mylabel] Implementation}, right = 3 of model.south east, anchor=south west] (implementation) {};

  % Text
  \node[mymodel] at (mustation.south) {Multiple stages\\Complex dynamics\\Solid bodies};
  \node[mymodel] at (dist.south) {Ground motion\\Vibrations\\Position errors};
  \node[mymodel] at (nanohexapod.south) {Different concepts\\ Optimal geometry \\ Choice of sensors};

  \node[mymodel] at (instrumentation.south) {Sensors, Actuators\\Amplifiers\\Control electronics};
  \node[mymodel] at (mechanical.south) {Parts optimization\\Proper integration\\Ease of assembly};
  \node[mymodel] at (fem.south) {Optimize key parts:\\Flexible joints\\Plates};

  \node[mymodel] at (mounting.south) {Mounting Tools:\\Struts\\ Nano-Hexapod};
  \node[mymodel] at (testbenches.south) {Instrumentation\\APA, Struts\\Hexapod};
  \node[mymodel] at (implementation.south) {Test Benches\\$\mu$ Station};

  % Links
  \draw[->] (dist.east) -- node[above, midway]{Measurements} node[below,midway]{} (dist.east-|model.west);
  \draw[->] (mustation.east) -- node[above, midway]{Measurements} node[below, midway]{CAD Model} (mustation.east-|model.west);

  \draw[->] ($(nanohexapod.east-|model.west)+(0, 0.2)$) -- node[above, midway]{Optimization} ($(nanohexapod.east)+(0, 0.2)$);
  \draw[<-] ($(nanohexapod.east-|model.west)-(0, 0.2)$) -- node[below, midway]{Model} ($(nanohexapod.east)-(0, 0.2)$);

  \draw[->] ($(fem.south|-model.north)+(0.2, 0)$) -- node[right, midway]{Specif.} ($(fem.south)+(0.2,0)$);
  \draw[<-] ($(fem.south|-model.north)-(0.2, 0)$) -- node[left, midway,align=right]{Super\\Element}  ($(fem.south)-(0.2,0)$);

  \draw[->] ($(mechanical.south|-model.north)+(0.2, 0)$) -- node[right, midway]{Specif.} ($(mechanical.south)+(0.2,0)$);
  \draw[<-] ($(mechanical.south|-model.north)-(0.2, 0)$) -- node[left, midway]{3D parts}        ($(mechanical.south)-(0.2,0)$);

  \draw[->] ($(instrumentation.south|-model.north)+(0.2, 0)$) -- node[right, midway]{Specif.} ($(instrumentation.south)+(0.2,0)$);
  \draw[<-] ($(instrumentation.south|-model.north)-(0.2, 0)$) -- node[left, midway]{Model}         ($(instrumentation.south)-(0.2,0)$);

  \draw[->] ($(testbenches.west-|model.east)+(0, 0.2)$) -- node[above, midway]{Control Laws} ($(testbenches.west)+(0, 0.2)$);
  \draw[<-] ($(testbenches.west-|model.east)-(0, 0.2)$) -- node[below, midway]{Refinement}   ($(testbenches.west)-(0, 0.2)$);

  \draw[->] ($(implementation.west-|model.east)+(0, 0.2)$) -- node[above, midway]{Control Laws} ($(implementation.west)+(0, 0.2)$);
  \draw[<-] ($(implementation.west-|model.east)-(0, 0.2)$) -- node[below, midway]{Refinement}   ($(implementation.west)-(0, 0.2)$);

  % Main steps
  \node[font=\bfseries, rotate=90, anchor=south, above] (conceptual_phase_node) at (dist.west) {Conceptual Phase};
  \node[font=\bfseries, above] (detailed_phase_node) at (mechanical.north) {Detail Design Phase};
  \node[font=\bfseries, rotate=-90, anchor=south, above] (implementation_phase_node) at (testbenches.east) {Experimental Phase};
    \begin{scope}[on background layer]
      \node[fit={(conceptual_phase_node.north|-nanohexapod.north) (mustation.south east)}, fill=lightgreen!50!white, draw, dashed, inner sep=2pt] (conceptual_phase) {};
      \node[fit={(detailed_phase_node.north-|instrumentation.west) (fem.south east)}, fill=lightyellow!50!white, draw, dashed, inner sep=2pt] (detailed_phase) {};
      \node[fit={(implementation_phase_node.north|-mounting.north) (implementation.south west)}, fill=lightred!50!white, draw, dashed, inner sep=2pt] (implementation_phase) {};
      % \node[above left] at (dob.south east) {DOB};
    \end{scope}

  % Between main steps
  \draw[mystep, dashed, postaction={decorate,decoration={raise=1ex,text along path,text align=center,text={Concept Validation}}}] (conceptual_phase.north) to[out=90, in=180] (detailed_phase.west);
  \draw[mystep, dashed, postaction={decorate,decoration={raise=1ex,text along path,text align=center,text={Procurement}}}] (detailed_phase.east) to[out=0, in=90] (implementation_phase.north);

  % % Inside Model
  % \node[inner sep=1pt, outer sep=6pt, anchor=north west, draw, fill=white, thin] (multibodymodel) at ($(model.north west) - (0, 0.5)$)
  %   {\includegraphics[width=5.6cm]{simscape_nano_hexapod.png}};

  % \node[inner sep=1pt, outer sep=6pt, anchor=south west, draw, fill=white, thin] (simscape) at (model.south west)
  %   {\includegraphics[width=5.6cm]{simscape_picture.jpg}};

  % % Feedback Model
  % \node[inner sep=3pt, outer sep=6pt, anchor=north east, draw, fill=white, thin] (simscape_sim) at ($(model.north east) - (0, 0.5)$)
  %   {\includegraphics[width=3.6cm]{simscape_simulations.pdf}};

  % % FeedBack
  % \node[inner sep=3pt, outer sep=6pt, anchor=south east, draw, fill=white, thin] (feedback) at (model.south east)
  %   {\includegraphics[width=3.6cm]{classical_feedback_small.pdf}};
\end{tikzpicture}
#+end_src

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

* HAC-LAC Representation (two columns)
#+begin_src latex :file nass_hac_lac_block_diagram.pdf
\graphicspath{ {/home/thomas/Cloud/thesis/papers/dehaeze21_mechatronics_approach_nass/tikz/figs-tikz} }

\begin{tikzpicture}
  \node[inner sep=3pt, fill=white, draw] (plant) at (0, 0)
  {\includegraphics[width=4.5cm]{nass_concept_schematic.pdf}};

  \coordinate[] (outputf) at ($(plant.south east)!0.75!(plant.north east)$);
  \coordinate[] (outputx) at ($(plant.south east)!0.25!(plant.north east)$);

  \node[block, left=0.6 of plant] (amp) {Amplifier};
  \node[DAC, left=0.6 of amp] (dac) {DAC};
  \node[ADC] (adc) at ($(plant.north-|dac) + (0, 0.2)$) {ADC};
  \node[addb, left=0.6 of dac] (addu) {};
  \node[block, above=0.4 of addu] (Kiff) {$\bm{K}_{\mathcal{L}}$};
  \node[block, left=0.6 of addu] (Kl) {$\bm{K}_{\mathcal{X}}$};
  \node[block, left=0.6 of Kl] (J) {$\bm{J}$};
  \node[block, left=0.6 of J] (pos_error) {Pos. Err.};

  \draw[->] (outputf) -- ++(0.2, 0)node[branch]{} |- (adc.east);
  \draw[->] (outputf) --node[midway, below]{$\bm{\tau}_m$} ++(0.8, 0);

  \draw[->] (outputx) -- ++(0.2, 0)node[branch]{} |- ($(plant.south)+(0, -0.2)$) -| (pos_error.south);
  \draw[->] (outputx) --node[midway, above]{$\bm{\mathcal{X}}_m$} ++(0.8, 0);

  \draw[->] (pos_error.east) -- node[midway, above]{$\bm{\epsilon}_{\mathcal{X}}$} (J.west);
  \draw[->] (J.east) -- node[midway, above]{$\bm{\epsilon}_{\mathcal{L}}$} (Kl.west);
  \draw[->] (Kl.east) -- node[midway, above]{$\bm{u}^\prime$} (addu.west);
  \draw[->] (addu.east) -- node[midway, above]{$\bm{u}$} (dac.west);
  \draw[->] (dac.east) -- (amp.west);
  \draw[->] (amp.east) -- (plant.west);
  \draw[->] (adc.west) -| (Kiff.north);
  \draw[->] (Kiff.south) -- (addu.north);
  \draw[<-] (pos_error.west) -- node[midway, above]{$\bm{r}_\mu$} ++(-0.8, 0);
\end{tikzpicture}
#+end_src

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

* HAC-LAC alternative (one column)
#+begin_src latex :file nass_hac_lac_block_diagram_without_elec.pdf
\graphicspath{ {/home/thomas/Cloud/thesis/papers/dehaeze21_mechatronics_approach_nass/tikz/figs-tikz} }

\begin{tikzpicture}
  % Plant
  \node[inner sep=3pt, fill=white, draw] (plant) at (0, 0)
  {\includegraphics[width=4cm]{nass_concept_schematic.pdf}};

  % Plant outputs
  \coordinate[] (outputf) at ($(plant.south east)!0.8!(plant.north east)$);
  \coordinate[] (outputx) at ($(plant.south east)!0.2!(plant.north east)$);

  % Blocks
  \node[addb, left=0.6 of plant] (addu) {};
  \node[block, above=0.4 of addu] (Kiff) {$\bm{K}_{\text{\tiny IFF}}$};
  \node[block, left=1.0 of addu] (Kl) {$\bm{K}_{\mathcal{L}}$};
  \node[block, left=0.6 of Kl] (J) {$\bm{J}$};
  \node[addb={+}{}{}{}{-}, left=0.6 of J] (pos_error) {};

  % Lines
  \draw[->] (outputf) -- ++(0.2, 0)node[below]{$\bm{\tau}$} |- ($(plant.north)+(0, 0.2)$) -| (Kiff.north);
  \draw[->] (outputx) -- ++(0.6, 0)node[above]{$\bm{\mathcal{X}}$} |- ($(plant.south)+(0, -0.4)$) -| (pos_error.south);
  \draw[->] (pos_error.east) -- node[midway, above]{$\bm{\epsilon}_{\mathcal{X}}$} (J.west);
  \draw[->] (J.east) -- node[midway, above]{$\bm{\epsilon}_{\mathcal{L}}$} (Kl.west);
  \draw[->] (Kl.east) -- node[near start, above]{$\bm{u}^\prime$} (addu.west);
  \draw[->] (addu.east) -- node[midway, above]{$\bm{u}$} (plant.west);
  \draw[->] (Kiff.south) -- (addu.north);
  \draw[<-] (pos_error.west) -- node[midway, above]{$\bm{r}$} ++(-0.6, 0);

  % Damped plant
  \begin{scope}[on background layer]
    \node[fit={(plant.south-|Kiff.west) ($(plant.north east)+(0.2cm,0.2cm)$)}, fill=black!10!white, draw, dashed, inner sep=0.2cm] (damped_plant) {};
    \node[above right, align=left] at (damped_plant.south west) {\small Damped\\Plant};
  \end{scope}
\end{tikzpicture}
#+end_src

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

* Mass Spring Damper Model
#+begin_src latex :file mass_spring_damper_hac_lac.pdf
\begin{tikzpicture}
  % ====================
  % Parameters
  % ====================
  \def\bracs{0.05} % Brace spacing vertically
  \def\brach{-12pt} % Brace shift horizontaly
  % ====================

  % ====================
  % Ground
  % ====================
  \draw (-0.9, 0) -- (0.9, 0);
  \draw[dashed] (0.9, 0) -- ++(0.5, 0);
  \draw[->] (1.3, 0) -- ++(0, 0.4) node[right]{$w$};
  % ====================

  % ====================
  % Granite
  \begin{scope}[shift={(0, 0)}]
    \draw[fill=white] (-0.9, 1.2) rectangle (0.9, 2.0) node[pos=0.5]{$\scriptstyle\text{granite}$};
    \draw[spring] (-0.7, 0)   -- ++(0, 1.2);
    \draw[damper] ( 0,   0)   -- ++(0, 1.2);

    \draw[dashed] ( 0.9, 2.0) -- ++(2.0, 0) coordinate(xg);

    % \draw[decorate, decoration={brace, amplitude=8pt}, xshift=\brach] %
    % (-0.9, \bracs) -- ++(0, 2.0) node[midway,rotate=90,anchor=south,yshift=10pt]{Granite};
  \end{scope}
  % ====================

  % ====================
  % Stages
  \begin{scope}[shift={(0, 2.0)}]
    \draw[fill=white] (-0.9, 1.2) rectangle (0.9, 2.0) node[pos=0.5]{$\scriptstyle\mu\text{-station}$};
    \draw[spring]   (-0.7, 0) -- ++(0, 1.2);
    \draw[damper]   ( 0,   0) -- ++(0, 1.2);
    \draw[actuator] ( 0.7, 0) -- ++(0, 1.2) node[midway, right=0.1](ft){$f_t$};

    % \draw[decorate, decoration={brace, amplitude=8pt}, xshift=\brach] %
    % (-0.9, \bracs) -- ++(0, 2.0) node[midway,rotate=90,anchor=south,yshift=10pt]{$\mu\text{-station}$};
  \end{scope}
  % ====================


  % ====================
  % NASS
  \begin{scope}[shift={(0, 4.0)}]
    \draw[fill=white] (-0.9, 1.5) rectangle (0.9, 2.3) node[pos=0.5]{$\scriptstyle\nu\text{-hexapod}$};
    \draw[dashed] (0.9, 2.3) -- ++(2.0, 0) coordinate(xnpos);

    \draw[spring]   (-0.7, 0) -- ++(0, 1.2) node[midway, left=0.1]{};
    \draw[damper]   ( 0,   0) -- ++(0, 1.2) node[midway, left=0.2]{};
    \draw[actuator] ( 0.7, 0) -- ++(0, 1.2) coordinate[midway, below right=0.2 and 0.1](f);

    \node[forcesensor={1.8}{0.3}] (fsensn) at (0, 1.2){};

    % \draw[decorate, decoration={brace, amplitude=8pt}, xshift=\brach] %
    % (-0.9, \bracs) -- ++(0, 2.2) node[midway,rotate=90,anchor=south,yshift=10pt]{$\nu\text{-hexapod}$};
  \end{scope}
  % ====================

  % ====================
  % Measured Displacement
  \draw[<->, dashed] ($(xg)+(-0.1, 0)$) node[above left](d){$d$} -- ($(xnpos)+(-0.1, 0)$);
  % ====================

  % ====================
  % IFF Control
  \node[block={2em}{1.5em}, right=0.6 of fsensn] (iff) {$K_{\scriptscriptstyle IFF}$};
  \node[addb] (ctrladd) at (f-|iff) {};
  \node[block={2em}{1.5em}, below=0.6 of ctrladd] (ctrl) {$K_{X}$};

  \draw[->] (fsensn.east)  -- node[midway, above]{$\tau_m$} (iff.west);
  \draw[->] (iff.south)    -- (ctrladd.north);
  \draw[->] (ctrladd.west) -- (f.east) node[above right]{$u$};
  \draw[->] (d.west)       -| (ctrl.south);
  \draw[->] (ctrl.north)   -- (ctrladd.south);
  % ====================
\end{tikzpicture}
#+end_src

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