#+TITLE: Identification of the Stewart Platform using Simscape
:DRAWER:
#+HTML_LINK_HOME: ./index.html
#+HTML_LINK_UP: ./index.html

#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="./css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="./css/readtheorg.css"/>
#+HTML_HEAD: <script src="./js/jquery.min.js"></script>
#+HTML_HEAD: <script src="./js/bootstrap.min.js"></script>
#+HTML_HEAD: <script src="./js/jquery.stickytableheaders.min.js"></script>
#+HTML_HEAD: <script src="./js/readtheorg.js"></script>

#+PROPERTY: header-args:matlab  :session *MATLAB*
#+PROPERTY: header-args:matlab+ :tangle matlab/identification.m
#+PROPERTY: header-args:matlab+ :comments org
#+PROPERTY: header-args:matlab+ :exports both
#+PROPERTY: header-args:matlab+ :results none
#+PROPERTY: header-args:matlab+ :eval no-export
#+PROPERTY: header-args:matlab+ :noweb yes
#+PROPERTY: header-args:matlab+ :mkdirp yes
#+PROPERTY: header-args:matlab+ :output-dir figs
:END:

* Introduction                                                        :ignore:
We would like to extract a state space model of the Stewart Platform from the Simscape model.

The inputs are:
| Symbol                 | Meaning                                          |
|------------------------+--------------------------------------------------|
| $\bm{\mathcal{F}}_{d}$ | External forces applied in {B}                   |
| $\bm{\tau}$            | Joint forces                                     |
| $\bm{\mathcal{F}}$     | Cartesian forces applied by the Joints           |
| $\bm{D}_{w}$           | Fixed Based translation and rotations around {A} |

The outputs are:
| Symbol             | Meaning                                                                   |
|--------------------+---------------------------------------------------------------------------|
| $\bm{\mathcal{X}}$ | Relative Motion of {B} with respect to {A}                                |
| $\bm{\mathcal{L}}$ | Joint Displacement                                                        |
| $\bm{F}_{m}$       | Force Sensors in each strut                                               |
| $\bm{v}_{m}$       | Inertial Sensors located at $b_i$ measuring in the direction of the strut |


#+begin_quote
An important difference from basic Simulink models is that the states in a physical network are not independent in general, because some states have dependencies on other states through constraints.
#+end_quote



* Identification
** Matlab Init                                              :noexport:ignore:
#+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name)
  <<matlab-dir>>
#+end_src

#+begin_src matlab :exports none :results silent :noweb yes
  <<matlab-init>>
#+end_src

#+begin_src matlab :results none :exports none
  simulinkproject('./');
#+end_src

** Simscape Model

** Initialize the Stewart Platform
#+begin_src matlab
  stewart = initializeFramesPositions();
  stewart = generateGeneralConfiguration(stewart);
  stewart = computeJointsPose(stewart);
  stewart = initializeStrutDynamics(stewart);
  stewart = initializeCylindricalPlatforms(stewart);
  stewart = initializeCylindricalStruts(stewart);
  stewart = computeJacobian(stewart);
  stewart = initializeStewartPose(stewart);
#+end_src

** Identification
#+begin_src matlab
  %% Options for Linearized
  options = linearizeOptions;
  options.SampleTime = 0;

  %% Name of the Simulink File
  mdl = 'stewart_platform_identification';

  %% Input/Output definition
  clear io; io_i = 1;
  io(io_i) = linio([mdl, '/tau'],  1, 'openinput');  io_i = io_i + 1;
  io(io_i) = linio([mdl, '/Fext'], 1, 'openinput');  io_i = io_i + 1;
  io(io_i) = linio([mdl, '/X'],    1, 'openoutput'); io_i = io_i + 1;
  io(io_i) = linio([mdl, '/Vm'],   1, 'openoutput'); io_i = io_i + 1;
  io(io_i) = linio([mdl, '/Taum'], 1, 'openoutput'); io_i = io_i + 1;
  io(io_i) = linio([mdl, '/Lm'],   1, 'openoutput'); io_i = io_i + 1;

  %% Run the linearization
  G = linearize(mdl, io, options);
  G.InputName  = {'tau1', 'tau2', 'tau3', 'tau4', 'tau5', 'tau6', ...
                  'Fx', 'Fy', 'Fz', 'Mx', 'My', 'Mz'};

  G.OutputName = {'Xdx', 'Xdy', 'Xdz', 'Xrx', 'Xry', 'Xrz', ...
                  'Vm1', 'Vm2', 'Vm3', 'Vm4', 'Vm5', 'Vm6', ...
                  'taum1', 'taum2', 'taum3', 'taum4', 'taum5', 'taum6', ...
                  'Lm1', 'Lm2', 'Lm3', 'Lm4', 'Lm5', 'Lm6'};
#+end_src

* States as the motion of the mobile platform
** Initialize the Stewart Platform
#+begin_src matlab
  stewart = initializeFramesPositions();
  stewart = generateGeneralConfiguration(stewart);
  stewart = computeJointsPose(stewart);
  stewart = initializeStrutDynamics(stewart);
  stewart = initializeCylindricalPlatforms(stewart);
  stewart = initializeCylindricalStruts(stewart);
  stewart = computeJacobian(stewart);
  stewart = initializeStewartPose(stewart);
#+end_src

** Identification
#+begin_src matlab
  %% Options for Linearized
  options = linearizeOptions;
  options.SampleTime = 0;

  %% Name of the Simulink File
  mdl = 'stewart_platform_identification_simple';

  %% Input/Output definition
  clear io; io_i = 1;
  io(io_i) = linio([mdl, '/tau'],  1, 'openinput');  io_i = io_i + 1;
  io(io_i) = linio([mdl, '/X'],    1, 'openoutput'); io_i = io_i + 1;
  io(io_i) = linio([mdl, '/Xdot'], 1, 'openoutput'); io_i = io_i + 1;

  %% Run the linearization
  G = linearize(mdl, io);
  % G.InputName  = {'tau1', 'tau2', 'tau3', 'tau4', 'tau5', 'tau6'};
  % G.OutputName = {'Xdx', 'Xdy', 'Xdz', 'Xrx', 'Xry', 'Xrz', 'Vdx', 'Vdy', 'Vdz', 'Vrx', 'Vry', 'Vrz'};
#+end_src

Let's check the size of =G=:
#+begin_src matlab :results replace output
  size(G)
#+end_src

#+RESULTS:
: size(G)
: State-space model with 12 outputs, 6 inputs, and 18 states.
: 'org_babel_eoe'
: ans =
:     'org_babel_eoe'

We expect to have only 12 states (corresponding to the 6dof of the mobile platform).
#+begin_src matlab :results replace output
  Gm = minreal(G);
#+end_src

#+RESULTS:
: Gm = minreal(G);
: 6 states removed.

And indeed, we obtain 12 states.

** Coordinate transformation
We can perform the following transformation using the =ss2ss= command.
#+begin_src matlab
  Gt = ss2ss(Gm, Gm.C);
#+end_src

Then, the =C= matrix of =Gt= is the unity matrix which means that the states of the state space model are equal to the measurements $\bm{Y}$.

The measurements are the 6 displacement and 6 velocities of mobile platform with respect to $\{B\}$.

We could perform the transformation by hand:
#+begin_src matlab
  At = Gm.C*Gm.A*pinv(Gm.C);

  Bt = Gm.C*Gm.B;

  Ct = eye(12);
  Dt = zeros(12, 6);

  Gt = ss(At, Bt, Ct, Dt);
#+end_src

** Analysis
#+begin_src matlab
  [V,D] = eig(Gt.A);
#+end_src

#+begin_src matlab :exports results :results value table replace :tangle no :post addhdr(*this*)
  ws = imag(diag(D))/2/pi;
  [ws,I] = sort(ws)

  xi = 100*real(diag(D))./imag(diag(D));
  xi = xi(I);

  data2orgtable([[1:length(ws(ws>0))]', ws(ws>0), xi(xi>0)], {}, {'Mode Number', 'Resonance Frequency [Hz]', 'Damping Ratio [%]'}, ' %.1f ');
#+end_src

#+RESULTS:
| Mode Number | Resonance Frequency [Hz] | Damping Ratio [%] |
|-------------+--------------------------+-------------------|
|         1.0 |                    174.5 |               0.9 |
|         2.0 |                    174.5 |               0.7 |
|         3.0 |                    202.1 |               0.7 |
|         4.0 |                    237.3 |               0.6 |
|         5.0 |                    237.3 |               0.5 |
|         6.0 |                    283.8 |               0.5 |

** Visualizing the modes
To visualize the i'th mode, we may excite the system using the inputs $U_i$ such that $B U_i$ is co-linear to $\xi_i$ (the mode we want to excite).

\[ U(t) = e^{\alpha t} (  ) \]

Let's first sort the modes and just take the modes corresponding to a eigenvalue with a positive imaginary part.
#+begin_src matlab
  ws = imag(diag(D));
  [ws,I] = sort(ws)
  ws = ws(7:end); I = I(7:end);
#+end_src

#+begin_src matlab
  for i = 1:length(ws)
#+end_src

#+begin_src matlab
  i_mode = I(i); % the argument is the i'th mode
#+end_src

#+begin_src matlab
  lambda_i = D(i_mode, i_mode);
  xi_i = V(:,i_mode);

  a_i = real(lambda_i);
  b_i = imag(lambda_i);
#+end_src

Let do 10 periods of the mode.
#+begin_src matlab
  t = linspace(0, 10/(imag(lambda_i)/2/pi), 1000);
  U_i = pinv(Gt.B) * real(xi_i * lambda_i * (cos(b_i * t) + 1i*sin(b_i * t)));
#+end_src

#+begin_src matlab
  U = timeseries(U_i, t);
#+end_src

Simulation:
#+begin_src matlab
  load('mat/conf_simscape.mat');
  set_param(conf_simscape, 'StopTime', num2str(t(end)));
  sim(mdl);
#+end_src

Save the movie of the mode shape.
#+begin_src matlab
  smwritevideo(mdl, sprintf('figs/mode%i', i), ...
               'PlaybackSpeedRatio', 1/(b_i/2/pi), ...
               'FrameRate', 30, ...
               'FrameSize', [800, 400]);
#+end_src

#+begin_src matlab
  end
#+end_src

#+name: fig:mode1
#+caption: Identified mode - 1
[[file:figs/mode1.gif]]

#+name: fig:mode3
#+caption: Identified mode - 3
[[file:figs/mode3.gif]]

#+name: fig:mode5
#+caption: Identified mode - 5
[[file:figs/mode5.gif]]

** Identification
#+begin_src matlab
  %% Options for Linearized
  options = linearizeOptions;
  options.SampleTime = 0;

  %% Name of the Simulink File
  mdl = 'stewart_platform_identification';

  %% Input/Output definition
  clear io; io_i = 1;
  io(io_i) = linio([mdl, '/tau'],  1, 'openinput');  io_i = io_i + 1;
  io(io_i) = linio([mdl, '/Lm'],    1, 'openoutput'); io_i = io_i + 1;

  %% Run the linearization
  G = linearize(mdl, io, options);
  % G.InputName  = {'tau1', 'tau2', 'tau3', 'tau4', 'tau5', 'tau6'};
  % G.OutputName = {'Xdx', 'Xdy', 'Xdz', 'Xrx', 'Xry', 'Xrz', 'Vdx', 'Vdy', 'Vdz', 'Vrx', 'Vry', 'Vrz'};
#+end_src

#+begin_src matlab
  size(G)
#+end_src

** Change of states
#+begin_src matlab
  At = G.C*G.A*pinv(G.C);

  Bt = G.C*G.B;

  Ct = eye(12);
  Dt = zeros(12, 6);
#+end_src

#+begin_src matlab
  Gt = ss(At, Bt, Ct, Dt);
#+end_src

#+begin_src matlab
  size(Gt)
#+end_src

* Simple Model without any sensor
** Matlab Init                                              :noexport:ignore:
#+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name)
  <<matlab-dir>>
#+end_src

#+begin_src matlab :exports none :results silent :noweb yes
  <<matlab-init>>
#+end_src

#+begin_src matlab :results none :exports none
  simulinkproject('./');
#+end_src

** Simscape Model
#+begin_src matlab
  open 'stewart_identification_simple.slx'
#+end_src


** Initialize the Stewart Platform
#+begin_src matlab
  stewart = initializeFramesPositions();
  stewart = generateGeneralConfiguration(stewart);
  stewart = computeJointsPose(stewart);
  stewart = initializeStrutDynamics(stewart);
  stewart = initializeCylindricalPlatforms(stewart);
  stewart = initializeCylindricalStruts(stewart);
  stewart = computeJacobian(stewart);
  stewart = initializeStewartPose(stewart);
#+end_src

** Identification
#+begin_src matlab
  stateorder = {...
      'stewart_platform_identification_simple/Solver Configuration/EVAL_KEY/INPUT_1_1_1',...
      'stewart_platform_identification_simple/Solver Configuration/EVAL_KEY/INPUT_2_1_1',...
      'stewart_platform_identification_simple/Solver Configuration/EVAL_KEY/INPUT_3_1_1',...
      'stewart_platform_identification_simple/Solver Configuration/EVAL_KEY/INPUT_4_1_1',...
      'stewart_platform_identification_simple/Solver Configuration/EVAL_KEY/INPUT_5_1_1',...
      'stewart_platform_identification_simple/Solver Configuration/EVAL_KEY/INPUT_6_1_1',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_1.Subsystem.cylindrical_joint.Rz.q',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_2.Subsystem.cylindrical_joint.Rz.q',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_3.Subsystem.cylindrical_joint.Rz.q',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_4.Subsystem.cylindrical_joint.Rz.q',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_5.Subsystem.cylindrical_joint.Rz.q',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_6.Subsystem.cylindrical_joint.Rz.q',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_1.Subsystem.cylindrical_joint.Pz.p',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_2.Subsystem.cylindrical_joint.Pz.p',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_3.Subsystem.cylindrical_joint.Pz.p',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_4.Subsystem.cylindrical_joint.Pz.p',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_5.Subsystem.cylindrical_joint.Pz.p',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_6.Subsystem.cylindrical_joint.Pz.p',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_1.Subsystem.cylindrical_joint.Rz.w',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_2.Subsystem.cylindrical_joint.Rz.w',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_3.Subsystem.cylindrical_joint.Rz.w',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_4.Subsystem.cylindrical_joint.Rz.w',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_5.Subsystem.cylindrical_joint.Rz.w',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_6.Subsystem.cylindrical_joint.Rz.w',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_1.Subsystem.cylindrical_joint.Pz.v',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_2.Subsystem.cylindrical_joint.Pz.v',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_3.Subsystem.cylindrical_joint.Pz.v',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_4.Subsystem.cylindrical_joint.Pz.v',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_5.Subsystem.cylindrical_joint.Pz.v',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_6.Subsystem.cylindrical_joint.Pz.v',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_1.Subsystem.spherical_joint_F.S.Q',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_2.Subsystem.spherical_joint_F.S.Q',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_3.Subsystem.spherical_joint_F.S.Q',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_4.Subsystem.spherical_joint_F.S.Q',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_5.Subsystem.spherical_joint_F.S.Q',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_6.Subsystem.spherical_joint_F.S.Q',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_2.Subsystem.spherical_joint_F.S.w',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_3.Subsystem.spherical_joint_F.S.w',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_4.Subsystem.spherical_joint_F.S.w',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_5.Subsystem.spherical_joint_F.S.w',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_6.Subsystem.spherical_joint_F.S.w',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_1.Subsystem.spherical_joint_F.S.w',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_1.Subsystem.spherical_joint_M.S.Q',...
      'stewart_platform_identification_simple.Stewart_Platform.Strut_1.Subsystem.spherical_joint_M.S.w'};
#+end_src


#+begin_src matlab
  %% Options for Linearized
  options = linearizeOptions;
  options.SampleTime = 0;

  %% Name of the Simulink File
  mdl = 'stewart_platform_identification_simple';

  %% Input/Output definition
  clear io; io_i = 1;
  io(io_i) = linio([mdl, '/tau'],  1, 'openinput');  io_i = io_i + 1;
  io(io_i) = linio([mdl, '/X'],     1, 'openoutput'); io_i = io_i + 1;
  io(io_i) = linio([mdl, '/Xdot'],  1, 'openoutput'); io_i = io_i + 1;

  %% Run the linearization
  G = linearize(mdl, io, options);
  G.InputName  = {'tau1', 'tau2', 'tau3', 'tau4', 'tau5', 'tau6'};

  G.OutputName = {'Xdx', 'Xdy', 'Xdz', 'Xrx', 'Xry', 'Xrz', 'Vdx', 'Vdy', 'Vdz', 'Vrx', 'Vry', 'Vrz'};
#+end_src

#+begin_src matlab
  size(G)
#+end_src

#+begin_src matlab
  G.StateName
#+end_src

* Cartesian Plot
From a force applied in the Cartesian frame to a displacement in the Cartesian frame.
#+begin_src matlab :results none
  figure;
  hold on;
  plot(freqs, abs(squeeze(freqresp(G.G_cart(1, 1), freqs, 'Hz'))));
  plot(freqs, abs(squeeze(freqresp(G.G_cart(2, 1), freqs, 'Hz'))));
  plot(freqs, abs(squeeze(freqresp(G.G_cart(3, 1), freqs, 'Hz'))));
  hold off;
  set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
  xlabel('Frequency [Hz]'); ylabel('Amplitude');
#+end_src

#+begin_src matlab :results none
  figure;
  bode(G.G_cart, freqs);
#+end_src

* From a force to force sensor
#+begin_src matlab :results none
  figure;
  hold on;
  plot(freqs, abs(squeeze(freqresp(G.G_forc(1, 1), freqs, 'Hz'))), 'k-', 'DisplayName', '$F_{m_i}/F_{i}$');
  hold off;
  set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
  xlabel('Frequency [Hz]'); ylabel('Amplitude [N/N]');
  legend('location', 'southeast');
#+end_src

#+begin_src matlab :results none
  figure;
  hold on;
  plot(freqs, abs(squeeze(freqresp(G.G_forc(1, 1), freqs, 'Hz'))), 'k-', 'DisplayName', '$F_{m_i}/F_{i}$');
  plot(freqs, abs(squeeze(freqresp(G.G_forc(2, 1), freqs, 'Hz'))), 'k--', 'DisplayName', '$F_{m_j}/F_{i}$');
  plot(freqs, abs(squeeze(freqresp(G.G_forc(3, 1), freqs, 'Hz'))), 'k--', 'HandleVisibility', 'off');
  plot(freqs, abs(squeeze(freqresp(G.G_forc(4, 1), freqs, 'Hz'))), 'k--', 'HandleVisibility', 'off');
  plot(freqs, abs(squeeze(freqresp(G.G_forc(5, 1), freqs, 'Hz'))), 'k--', 'HandleVisibility', 'off');
  plot(freqs, abs(squeeze(freqresp(G.G_forc(6, 1), freqs, 'Hz'))), 'k--', 'HandleVisibility', 'off');
  hold off;
  set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
  xlabel('Frequency [Hz]'); ylabel('Amplitude [N/N]');
  legend('location', 'southeast');
#+end_src

* From a force applied in the leg to the displacement of the leg
#+begin_src matlab :results none
  figure;
  hold on;
  plot(freqs, abs(squeeze(freqresp(G.G_legs(1, 1), freqs, 'Hz'))), 'k-', 'DisplayName', '$D_{i}/F_{i}$');
  hold off;
  set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
  xlabel('Frequency [Hz]'); ylabel('Amplitude [m/N]');
#+end_src

#+begin_src matlab :results none
  figure;
  hold on;
  plot(freqs, abs(squeeze(freqresp(G.G_legs(1, 1), freqs, 'Hz'))), 'k-', 'DisplayName', '$D_{i}/F_{i}$');
  plot(freqs, abs(squeeze(freqresp(G.G_legs(2, 1), freqs, 'Hz'))), 'k--', 'DisplayName', '$D_{j}/F_{i}$');
  plot(freqs, abs(squeeze(freqresp(G.G_legs(3, 1), freqs, 'Hz'))), 'k--', 'HandleVisibility', 'off');
  plot(freqs, abs(squeeze(freqresp(G.G_legs(4, 1), freqs, 'Hz'))), 'k--', 'HandleVisibility', 'off');
  plot(freqs, abs(squeeze(freqresp(G.G_legs(5, 1), freqs, 'Hz'))), 'k--', 'HandleVisibility', 'off');
  plot(freqs, abs(squeeze(freqresp(G.G_legs(6, 1), freqs, 'Hz'))), 'k--', 'HandleVisibility', 'off');
  hold off;
  set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
  xlabel('Frequency [Hz]'); ylabel('Amplitude [m/N]');
  legend('location', 'northeast');
#+end_src

* Transmissibility
#+begin_src matlab :results none
  figure;
  hold on;
  plot(freqs, abs(squeeze(freqresp(G.G_tran(1, 1), freqs, 'Hz'))));
  plot(freqs, abs(squeeze(freqresp(G.G_tran(2, 2), freqs, 'Hz'))));
  plot(freqs, abs(squeeze(freqresp(G.G_tran(3, 3), freqs, 'Hz'))));
  hold off;
  set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
  xlabel('Frequency [Hz]'); ylabel('Amplitude [m/m]');
#+end_src

#+begin_src matlab :results none
  figure;
  hold on;
  plot(freqs, abs(squeeze(freqresp(G.G_tran(4, 4), freqs, 'Hz'))));
  plot(freqs, abs(squeeze(freqresp(G.G_tran(5, 5), freqs, 'Hz'))));
  plot(freqs, abs(squeeze(freqresp(G.G_tran(6, 6), freqs, 'Hz'))));
  hold off;
  set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
  xlabel('Frequency [Hz]'); ylabel('Amplitude [$\frac{rad/s}{rad/s}$]');
#+end_src

#+begin_src matlab :results none
  figure;
  hold on;
  plot(freqs, abs(squeeze(freqresp(G.G_tran(1, 1), freqs, 'Hz'))));
  plot(freqs, abs(squeeze(freqresp(G.G_tran(1, 2), freqs, 'Hz'))));
  plot(freqs, abs(squeeze(freqresp(G.G_tran(1, 3), freqs, 'Hz'))));
  hold off;
  set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
  xlabel('Frequency [Hz]'); ylabel('Amplitude [m/m]');
#+end_src

* Compliance
From a force applied in the Cartesian frame to a relative displacement of the mobile platform with respect to the base.

#+begin_src matlab :results none
  figure;
  hold on;
  plot(freqs, abs(squeeze(freqresp(G.G_comp(1, 1), freqs, 'Hz'))));
  plot(freqs, abs(squeeze(freqresp(G.G_comp(2, 2), freqs, 'Hz'))));
  plot(freqs, abs(squeeze(freqresp(G.G_comp(3, 3), freqs, 'Hz'))));
  hold off;
  set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
  xlabel('Frequency [Hz]'); ylabel('Amplitude [m/N]');
#+end_src

* Inertial
From a force applied on the Cartesian frame to the absolute displacement of the mobile platform.

#+begin_src matlab :results none
  figure;
  hold on;
  plot(freqs, abs(squeeze(freqresp(G.G_iner(1, 1), freqs, 'Hz'))));
  plot(freqs, abs(squeeze(freqresp(G.G_iner(2, 2), freqs, 'Hz'))));
  plot(freqs, abs(squeeze(freqresp(G.G_iner(3, 3), freqs, 'Hz'))));
  hold off;
  set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
  xlabel('Frequency [Hz]'); ylabel('Amplitude [m/N]');
#+end_src

