Slip the simscape folder into 3 folders
This commit is contained in:
parent
355b9b1ef6
commit
85c0b6e031
508
functions/index.org
Normal file
508
functions/index.org
Normal file
@ -0,0 +1,508 @@
|
|||||||
|
#+TITLE: Matlab Functions used for the NASS Project
|
||||||
|
:DRAWER:
|
||||||
|
#+STARTUP: overview
|
||||||
|
|
||||||
|
#+LANGUAGE: en
|
||||||
|
#+EMAIL: dehaeze.thomas@gmail.com
|
||||||
|
#+AUTHOR: Dehaeze Thomas
|
||||||
|
|
||||||
|
#+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: <link rel="stylesheet" type="text/css" href="../css/zenburn.css"/>
|
||||||
|
#+HTML_HEAD: <script type="text/javascript" src="../js/jquery.min.js"></script>
|
||||||
|
#+HTML_HEAD: <script type="text/javascript" src="../js/bootstrap.min.js"></script>
|
||||||
|
#+HTML_HEAD: <script type="text/javascript" src="../js/jquery.stickytableheaders.min.js"></script>
|
||||||
|
#+HTML_HEAD: <script type="text/javascript" src="../js/readtheorg.js"></script>
|
||||||
|
|
||||||
|
#+HTML_MATHJAX: align: center tagside: right font: TeX
|
||||||
|
|
||||||
|
#+PROPERTY: header-args:matlab :session *MATLAB*
|
||||||
|
#+PROPERTY: header-args:matlab+ :comments org
|
||||||
|
#+PROPERTY: header-args:matlab+ :results none
|
||||||
|
#+PROPERTY: header-args:matlab+ :exports both
|
||||||
|
#+PROPERTY: header-args:matlab+ :eval no-export
|
||||||
|
#+PROPERTY: header-args:matlab+ :output-dir figs
|
||||||
|
#+PROPERTY: header-args:matlab+ :tangle no
|
||||||
|
#+PROPERTY: header-args:matlab+ :mkdirp yes
|
||||||
|
|
||||||
|
#+PROPERTY: header-args:shell :eval no-export
|
||||||
|
|
||||||
|
#+PROPERTY: header-args:latex :headers '("\\usepackage{tikz}" "\\usepackage{import}" "\\import{$HOME/Cloud/thesis/latex/}{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 raw replace :buffer no
|
||||||
|
#+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
|
||||||
|
:END:
|
||||||
|
|
||||||
|
* Functions
|
||||||
|
<<sec:functions>>
|
||||||
|
** computePsdDispl
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args:matlab+: :tangle ../src/computePsdDispl.m
|
||||||
|
:header-args:matlab+: :comments none :mkdirp yes :eval no
|
||||||
|
:END:
|
||||||
|
<<sec:computePsdDispl>>
|
||||||
|
|
||||||
|
This Matlab function is accessible [[file:../src/computePsdDispl.m][here]].
|
||||||
|
|
||||||
|
#+begin_src matlab
|
||||||
|
function [psd_object] = computePsdDispl(sys_data, t_init, n_av)
|
||||||
|
i_init = find(sys_data.time > t_init, 1);
|
||||||
|
|
||||||
|
han_win = hanning(ceil(length(sys_data.Dx(i_init:end, :))/n_av));
|
||||||
|
Fs = 1/sys_data.time(2);
|
||||||
|
|
||||||
|
[pdx, f] = pwelch(sys_data.Dx(i_init:end, :), han_win, [], [], Fs);
|
||||||
|
[pdy, ~] = pwelch(sys_data.Dy(i_init:end, :), han_win, [], [], Fs);
|
||||||
|
[pdz, ~] = pwelch(sys_data.Dz(i_init:end, :), han_win, [], [], Fs);
|
||||||
|
|
||||||
|
[prx, ~] = pwelch(sys_data.Rx(i_init:end, :), han_win, [], [], Fs);
|
||||||
|
[pry, ~] = pwelch(sys_data.Ry(i_init:end, :), han_win, [], [], Fs);
|
||||||
|
[prz, ~] = pwelch(sys_data.Rz(i_init:end, :), han_win, [], [], Fs);
|
||||||
|
|
||||||
|
psd_object = struct(...
|
||||||
|
'f', f, ...
|
||||||
|
'dx', pdx, ...
|
||||||
|
'dy', pdy, ...
|
||||||
|
'dz', pdz, ...
|
||||||
|
'rx', prx, ...
|
||||||
|
'ry', pry, ...
|
||||||
|
'rz', prz);
|
||||||
|
end
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** computeSetpoint
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args:matlab+: :tangle ../src/computeSetpoint.m
|
||||||
|
:header-args:matlab+: :comments none :mkdirp yes :eval no
|
||||||
|
:END:
|
||||||
|
<<sec:computeSetpoint>>
|
||||||
|
|
||||||
|
This Matlab function is accessible [[file:../src/computeSetpoint.m][here]].
|
||||||
|
|
||||||
|
#+begin_src matlab
|
||||||
|
function setpoint = computeSetpoint(ty, ry, rz)
|
||||||
|
%%
|
||||||
|
setpoint = zeros(6, 1);
|
||||||
|
|
||||||
|
%% Ty
|
||||||
|
Ty = [1 0 0 0 ;
|
||||||
|
0 1 0 ty ;
|
||||||
|
0 0 1 0 ;
|
||||||
|
0 0 0 1 ];
|
||||||
|
|
||||||
|
% Tyinv = [1 0 0 0 ;
|
||||||
|
% 0 1 0 -ty ;
|
||||||
|
% 0 0 1 0 ;
|
||||||
|
% 0 0 0 1 ];
|
||||||
|
|
||||||
|
%% Ry
|
||||||
|
Ry = [ cos(ry) 0 sin(ry) 0 ;
|
||||||
|
0 1 0 0 ;
|
||||||
|
-sin(ry) 0 cos(ry) 0 ;
|
||||||
|
0 0 0 1 ];
|
||||||
|
|
||||||
|
% TMry = Ty*Ry*Tyinv;
|
||||||
|
|
||||||
|
%% Rz
|
||||||
|
Rz = [cos(rz) -sin(rz) 0 0 ;
|
||||||
|
sin(rz) cos(rz) 0 0 ;
|
||||||
|
0 0 1 0 ;
|
||||||
|
0 0 0 1 ];
|
||||||
|
|
||||||
|
% TMrz = Ty*TMry*Rz*TMry'*Tyinv;
|
||||||
|
|
||||||
|
%% All stages
|
||||||
|
% TM = TMrz*TMry*Ty;
|
||||||
|
|
||||||
|
TM = Ty*Ry*Rz;
|
||||||
|
|
||||||
|
[thetax, thetay, thetaz] = RM2angle(TM(1:3, 1:3));
|
||||||
|
|
||||||
|
setpoint(1:3) = TM(1:3, 4);
|
||||||
|
setpoint(4:6) = [thetax, thetay, thetaz];
|
||||||
|
|
||||||
|
%% Custom Functions
|
||||||
|
function [thetax, thetay, thetaz] = RM2angle(R)
|
||||||
|
if abs(abs(R(3, 1)) - 1) > 1e-6 % R31 != 1 and R31 != -1
|
||||||
|
thetay = -asin(R(3, 1));
|
||||||
|
thetax = atan2(R(3, 2)/cos(thetay), R(3, 3)/cos(thetay));
|
||||||
|
thetaz = atan2(R(2, 1)/cos(thetay), R(1, 1)/cos(thetay));
|
||||||
|
else
|
||||||
|
thetaz = 0;
|
||||||
|
if abs(R(3, 1)+1) < 1e-6 % R31 = -1
|
||||||
|
thetay = pi/2;
|
||||||
|
thetax = thetaz + atan2(R(1, 2), R(1, 3));
|
||||||
|
else
|
||||||
|
thetay = -pi/2;
|
||||||
|
thetax = -thetaz + atan2(-R(1, 2), -R(1, 3));
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** converErrorBasis
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args:matlab+: :tangle ../src/converErrorBasis.m
|
||||||
|
:header-args:matlab+: :comments none :mkdirp yes :eval no
|
||||||
|
:END:
|
||||||
|
<<sec:converErrorBasis>>
|
||||||
|
|
||||||
|
This Matlab function is accessible [[file:../src/converErrorBasis.m][here]].
|
||||||
|
|
||||||
|
#+begin_src matlab
|
||||||
|
function error_nass = convertErrorBasis(pos, setpoint, ty, ry, rz)
|
||||||
|
% convertErrorBasis -
|
||||||
|
%
|
||||||
|
% Syntax: convertErrorBasis(p_error, ty, ry, rz)
|
||||||
|
%
|
||||||
|
% Inputs:
|
||||||
|
% - p_error - Position error of the sample w.r.t. the granite [m, rad]
|
||||||
|
% - ty - Measured translation of the Ty stage [m]
|
||||||
|
% - ry - Measured rotation of the Ry stage [rad]
|
||||||
|
% - rz - Measured rotation of the Rz stage [rad]
|
||||||
|
%
|
||||||
|
% Outputs:
|
||||||
|
% - P_nass - Position error of the sample w.r.t. the NASS base [m]
|
||||||
|
% - R_nass - Rotation error of the sample w.r.t. the NASS base [rad]
|
||||||
|
%
|
||||||
|
% Example:
|
||||||
|
%
|
||||||
|
|
||||||
|
%% If line vector => column vector
|
||||||
|
if size(pos, 2) == 6
|
||||||
|
pos = pos';
|
||||||
|
end
|
||||||
|
|
||||||
|
if size(setpoint, 2) == 6
|
||||||
|
setpoint = setpoint';
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Position of the sample in the frame fixed to the Granite
|
||||||
|
P_granite = [pos(1:3); 1]; % Position [m]
|
||||||
|
R_granite = [setpoint(1:3); 1]; % Reference [m]
|
||||||
|
|
||||||
|
%% Transformation matrices of the stages
|
||||||
|
% T-y
|
||||||
|
TMty = [1 0 0 0 ;
|
||||||
|
0 1 0 ty ;
|
||||||
|
0 0 1 0 ;
|
||||||
|
0 0 0 1 ];
|
||||||
|
|
||||||
|
% R-y
|
||||||
|
TMry = [ cos(ry) 0 sin(ry) 0 ;
|
||||||
|
0 1 0 0 ;
|
||||||
|
-sin(ry) 0 cos(ry) 0 ;
|
||||||
|
0 0 0 1 ];
|
||||||
|
|
||||||
|
% R-z
|
||||||
|
TMrz = [cos(rz) -sin(rz) 0 0 ;
|
||||||
|
sin(rz) cos(rz) 0 0 ;
|
||||||
|
0 0 1 0 ;
|
||||||
|
0 0 0 1 ];
|
||||||
|
|
||||||
|
%% Compute Point coordinates in the new reference fixed to the NASS base
|
||||||
|
% P_nass = TMrz*TMry*TMty*P_granite;
|
||||||
|
P_nass = TMrz\TMry\TMty\P_granite;
|
||||||
|
R_nass = TMrz\TMry\TMty\R_granite;
|
||||||
|
|
||||||
|
dx = R_nass(1)-P_nass(1);
|
||||||
|
dy = R_nass(2)-P_nass(2);
|
||||||
|
dz = R_nass(3)-P_nass(3);
|
||||||
|
|
||||||
|
%% Compute new basis vectors linked to the NASS base
|
||||||
|
% ux_nass = TMrz*TMry*TMty*[1; 0; 0; 0];
|
||||||
|
% ux_nass = ux_nass(1:3);
|
||||||
|
% uy_nass = TMrz*TMry*TMty*[0; 1; 0; 0];
|
||||||
|
% uy_nass = uy_nass(1:3);
|
||||||
|
% uz_nass = TMrz*TMry*TMty*[0; 0; 1; 0];
|
||||||
|
% uz_nass = uz_nass(1:3);
|
||||||
|
|
||||||
|
ux_nass = TMrz\TMry\TMty\[1; 0; 0; 0];
|
||||||
|
ux_nass = ux_nass(1:3);
|
||||||
|
uy_nass = TMrz\TMry\TMty\[0; 1; 0; 0];
|
||||||
|
uy_nass = uy_nass(1:3);
|
||||||
|
uz_nass = TMrz\TMry\TMty\[0; 0; 1; 0];
|
||||||
|
uz_nass = uz_nass(1:3);
|
||||||
|
|
||||||
|
%% Rotations error w.r.t. granite Frame
|
||||||
|
% Rotations error w.r.t. granite Frame
|
||||||
|
rx_nass = pos(4);
|
||||||
|
ry_nass = pos(5);
|
||||||
|
rz_nass = pos(6);
|
||||||
|
|
||||||
|
% Rotation matrices of the Sample w.r.t. the Granite
|
||||||
|
Mrx_error = [1 0 0 ;
|
||||||
|
0 cos(-rx_nass) -sin(-rx_nass) ;
|
||||||
|
0 sin(-rx_nass) cos(-rx_nass)];
|
||||||
|
|
||||||
|
Mry_error = [ cos(-ry_nass) 0 sin(-ry_nass) ;
|
||||||
|
0 1 0 ;
|
||||||
|
-sin(-ry_nass) 0 cos(-ry_nass)];
|
||||||
|
|
||||||
|
Mrz_error = [cos(-rz_nass) -sin(-rz_nass) 0 ;
|
||||||
|
sin(-rz_nass) cos(-rz_nass) 0 ;
|
||||||
|
0 0 1];
|
||||||
|
|
||||||
|
% Rotation matrix of the Sample w.r.t. the Granite
|
||||||
|
Mr_error = Mrz_error*Mry_error*Mrx_error;
|
||||||
|
|
||||||
|
%% Use matrix to solve
|
||||||
|
R = Mr_error/[ux_nass, uy_nass, uz_nass]; % Rotation matrix from NASS base to Sample
|
||||||
|
|
||||||
|
[thetax, thetay, thetaz] = RM2angle(R);
|
||||||
|
|
||||||
|
error_nass = [dx; dy; dz; thetax; thetay; thetaz];
|
||||||
|
|
||||||
|
%% Custom Functions
|
||||||
|
function [thetax, thetay, thetaz] = RM2angle(R)
|
||||||
|
if abs(abs(R(3, 1)) - 1) > 1e-6 % R31 != 1 and R31 != -1
|
||||||
|
thetay = -asin(R(3, 1));
|
||||||
|
% thetaybis = pi-thetay;
|
||||||
|
thetax = atan2(R(3, 2)/cos(thetay), R(3, 3)/cos(thetay));
|
||||||
|
% thetaxbis = atan2(R(3, 2)/cos(thetaybis), R(3, 3)/cos(thetaybis));
|
||||||
|
thetaz = atan2(R(2, 1)/cos(thetay), R(1, 1)/cos(thetay));
|
||||||
|
% thetazbis = atan2(R(2, 1)/cos(thetaybis), R(1, 1)/cos(thetaybis));
|
||||||
|
else
|
||||||
|
thetaz = 0;
|
||||||
|
if abs(R(3, 1)+1) < 1e-6 % R31 = -1
|
||||||
|
thetay = pi/2;
|
||||||
|
thetax = thetaz + atan2(R(1, 2), R(1, 3));
|
||||||
|
else
|
||||||
|
thetay = -pi/2;
|
||||||
|
thetax = -thetaz + atan2(-R(1, 2), -R(1, 3));
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** generateDiagPidControl
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args:matlab+: :tangle ../src/generateDiagPidControl.m
|
||||||
|
:header-args:matlab+: :comments none :mkdirp yes :eval no
|
||||||
|
:END:
|
||||||
|
<<sec:generateDiagPidControl>>
|
||||||
|
|
||||||
|
This Matlab function is accessible [[file:../src/generateDiagPidControl.m][here]].
|
||||||
|
|
||||||
|
#+begin_src matlab
|
||||||
|
function [K] = generateDiagPidControl(G, fs)
|
||||||
|
%%
|
||||||
|
pid_opts = pidtuneOptions(...
|
||||||
|
'PhaseMargin', 50, ...
|
||||||
|
'DesignFocus', 'disturbance-rejection');
|
||||||
|
|
||||||
|
%%
|
||||||
|
K = tf(zeros(6));
|
||||||
|
|
||||||
|
for i = 1:6
|
||||||
|
input_name = G.InputName(i);
|
||||||
|
output_name = G.OutputName(i);
|
||||||
|
K(i, i) = tf(pidtune(minreal(G(output_name, input_name)), 'PIDF', 2*pi*fs, pid_opts));
|
||||||
|
end
|
||||||
|
|
||||||
|
K.InputName = G.OutputName;
|
||||||
|
K.OutputName = G.InputName;
|
||||||
|
end
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** identifyPlant
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args:matlab+: :tangle ../src/identifyPlant.m
|
||||||
|
:header-args:matlab+: :comments none :mkdirp yes :eval no
|
||||||
|
:END:
|
||||||
|
<<sec:identifyPlant>>
|
||||||
|
|
||||||
|
This Matlab function is accessible [[file:../src/identifyPlant.m][here]].
|
||||||
|
|
||||||
|
#+begin_src matlab
|
||||||
|
function [sys] = identifyPlant(opts_param)
|
||||||
|
%% Default values for opts
|
||||||
|
opts = struct();
|
||||||
|
|
||||||
|
%% Populate opts with input parameters
|
||||||
|
if exist('opts_param','var')
|
||||||
|
for opt = fieldnames(opts_param)'
|
||||||
|
opts.(opt{1}) = opts_param.(opt{1});
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Options for Linearized
|
||||||
|
options = linearizeOptions;
|
||||||
|
options.SampleTime = 0;
|
||||||
|
|
||||||
|
%% Name of the Simulink File
|
||||||
|
mdl = 'sim_nano_station_id';
|
||||||
|
|
||||||
|
%% Input/Output definition
|
||||||
|
io(1) = linio([mdl, '/Fn'], 1, 'input'); % Cartesian forces applied by NASS
|
||||||
|
io(2) = linio([mdl, '/Dw'], 1, 'input'); % Ground Motion
|
||||||
|
io(3) = linio([mdl, '/Fs'], 1, 'input'); % External forces on the sample
|
||||||
|
io(4) = linio([mdl, '/Fnl'], 1, 'input'); % Forces applied on the NASS's legs
|
||||||
|
io(5) = linio([mdl, '/Fd'], 1, 'input'); % Disturbance Forces
|
||||||
|
io(6) = linio([mdl, '/Dsm'], 1, 'output'); % Displacement of the sample
|
||||||
|
io(7) = linio([mdl, '/Fnlm'], 1, 'output'); % Force sensor in NASS's legs
|
||||||
|
io(8) = linio([mdl, '/Dnlm'], 1, 'output'); % Displacement of NASS's legs
|
||||||
|
io(9) = linio([mdl, '/Es'], 1, 'output'); % Position Error w.r.t. NASS base
|
||||||
|
io(10) = linio([mdl, '/Vlm'], 1, 'output'); % Measured absolute velocity of the legs
|
||||||
|
|
||||||
|
%% Run the linearization
|
||||||
|
G = linearize(mdl, io, options);
|
||||||
|
G.InputName = {'Fnx', 'Fny', 'Fnz', 'Mnx', 'Mny', 'Mnz', ...
|
||||||
|
'Dgx', 'Dgy', 'Dgz', ...
|
||||||
|
'Fsx', 'Fsy', 'Fsz', 'Msx', 'Msy', 'Msz', ...
|
||||||
|
'F1', 'F2', 'F3', 'F4', 'F5', 'F6', ...
|
||||||
|
'Frzz', 'Ftyx', 'Ftyz'};
|
||||||
|
G.OutputName = {'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz', ...
|
||||||
|
'Fm1', 'Fm2', 'Fm3', 'Fm4', 'Fm5', 'Fm6', ...
|
||||||
|
'Dm1', 'Dm2', 'Dm3', 'Dm4', 'Dm5', 'Dm6', ...
|
||||||
|
'Edx', 'Edy', 'Edz', 'Erx', 'Ery', 'Erz', ...
|
||||||
|
'Vm1', 'Vm2', 'Vm3', 'Vm4', 'Vm5', 'Vm6'};
|
||||||
|
|
||||||
|
%% Create the sub transfer functions
|
||||||
|
minreal_tol = sqrt(eps);
|
||||||
|
% From forces applied in the cartesian frame to displacement of the sample in the cartesian frame
|
||||||
|
sys.G_cart = minreal(G({'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz'}, {'Fnx', 'Fny', 'Fnz', 'Mnx', 'Mny', 'Mnz'}), minreal_tol, false);
|
||||||
|
% From ground motion to Sample displacement
|
||||||
|
sys.G_gm = minreal(G({'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz'}, {'Dgx', 'Dgy', 'Dgz'}), minreal_tol, false);
|
||||||
|
% From direct forces applied on the sample to displacement of the sample
|
||||||
|
sys.G_fs = minreal(G({'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz'}, {'Fsx', 'Fsy', 'Fsz', 'Msx', 'Msy', 'Msz'}), minreal_tol, false);
|
||||||
|
% From forces applied on NASS's legs to force sensor in each leg
|
||||||
|
sys.G_iff = minreal(G({'Fm1', 'Fm2', 'Fm3', 'Fm4', 'Fm5', 'Fm6'}, {'F1', 'F2', 'F3', 'F4', 'F5', 'F6'}), minreal_tol, false);
|
||||||
|
% From forces applied on NASS's legs to displacement of each leg
|
||||||
|
sys.G_dleg = minreal(G({'Dm1', 'Dm2', 'Dm3', 'Dm4', 'Dm5', 'Dm6'}, {'F1', 'F2', 'F3', 'F4', 'F5', 'F6'}), minreal_tol, false);
|
||||||
|
% From forces/torques applied by the NASS to position error
|
||||||
|
sys.G_plant = minreal(G({'Edx', 'Edy', 'Edz', 'Erx', 'Ery', 'Erz'}, {'Fnx', 'Fny', 'Fnz', 'Mnx', 'Mny', 'Mnz'}), minreal_tol, false);
|
||||||
|
% From forces/torques applied by the NASS to velocity of the actuator
|
||||||
|
sys.G_geoph = minreal(G({'Vm1', 'Vm2', 'Vm3', 'Vm4', 'Vm5', 'Vm6'}, {'F1', 'F2', 'F3', 'F4', 'F5', 'F6'}), minreal_tol, false);
|
||||||
|
% From various disturbance forces to position error
|
||||||
|
sys.G_dist = minreal(G({'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz'}, {'Frzz', 'Ftyx', 'Ftyz'}), minreal_tol, false);
|
||||||
|
|
||||||
|
%% We remove low frequency and high frequency dynamics that are usually unstable
|
||||||
|
% using =freqsep= is risky as it may change the shape of the transfer functions
|
||||||
|
% f_min = 0.1; % [Hz]
|
||||||
|
% f_max = 1e4; % [Hz]
|
||||||
|
|
||||||
|
% [~, sys.G_cart] = freqsep(freqsep(sys.G_cart, 2*pi*f_max), 2*pi*f_min);
|
||||||
|
% [~, sys.G_gm] = freqsep(freqsep(sys.G_gm, 2*pi*f_max), 2*pi*f_min);
|
||||||
|
% [~, sys.G_fs] = freqsep(freqsep(sys.G_fs, 2*pi*f_max), 2*pi*f_min);
|
||||||
|
% [~, sys.G_iff] = freqsep(freqsep(sys.G_iff, 2*pi*f_max), 2*pi*f_min);
|
||||||
|
% [~, sys.G_dleg] = freqsep(freqsep(sys.G_dleg, 2*pi*f_max), 2*pi*f_min);
|
||||||
|
% [~, sys.G_plant] = freqsep(freqsep(sys.G_plant, 2*pi*f_max), 2*pi*f_min);
|
||||||
|
|
||||||
|
%% We finally verify that the system is stable
|
||||||
|
if ~isstable(sys.G_cart) || ~isstable(sys.G_gm) || ~isstable(sys.G_fs) || ~isstable(sys.G_iff) || ~isstable(sys.G_dleg) || ~isstable(sys.G_plant)
|
||||||
|
warning('One of the identified system is unstable');
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** runSimulation
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args:matlab+: :tangle ../src/runSimulation.m
|
||||||
|
:header-args:matlab+: :comments none :mkdirp yes :eval no
|
||||||
|
:END:
|
||||||
|
<<sec:runSimulation>>
|
||||||
|
|
||||||
|
This Matlab function is accessible [[file:../src/runSimulation.m][here]].
|
||||||
|
|
||||||
|
#+begin_src matlab
|
||||||
|
function [] = runSimulation(sys_name, sys_mass, ctrl_type, act_damp)
|
||||||
|
%% Load the controller and save it for the simulation
|
||||||
|
if strcmp(ctrl_type, 'cl') && strcmp(act_damp, 'none')
|
||||||
|
K_obj = load('./mat/K_fb.mat');
|
||||||
|
K = K_obj.(sprintf('K_%s_%s', sys_mass, sys_name)); %#ok
|
||||||
|
save('./mat/controllers.mat', 'K');
|
||||||
|
elseif strcmp(ctrl_type, 'cl') && strcmp(act_damp, 'iff')
|
||||||
|
K_obj = load('./mat/K_fb_iff.mat');
|
||||||
|
K = K_obj.(sprintf('K_%s_%s_iff', sys_mass, sys_name)); %#ok
|
||||||
|
save('./mat/controllers.mat', 'K');
|
||||||
|
elseif strcmp(ctrl_type, 'ol')
|
||||||
|
K = tf(zeros(6)); %#ok
|
||||||
|
save('./mat/controllers.mat', 'K');
|
||||||
|
else
|
||||||
|
error('ctrl_type should be cl or ol');
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Active Damping
|
||||||
|
if strcmp(act_damp, 'iff')
|
||||||
|
K_iff_crit = load('./mat/K_iff_crit.mat');
|
||||||
|
K_iff = K_iff_crit.(sprintf('K_iff_%s_%s', sys_mass, sys_name)); %#ok
|
||||||
|
save('./mat/controllers.mat', 'K_iff', '-append');
|
||||||
|
elseif strcmp(act_damp, 'none')
|
||||||
|
K_iff = tf(zeros(6)); %#ok
|
||||||
|
save('./mat/controllers.mat', 'K_iff', '-append');
|
||||||
|
end
|
||||||
|
|
||||||
|
%%
|
||||||
|
if strcmp(sys_name, 'pz')
|
||||||
|
initializeNanoHexapod(struct('actuator', 'piezo'));
|
||||||
|
elseif strcmp(sys_name, 'vc')
|
||||||
|
initializeNanoHexapod(struct('actuator', 'lorentz'));
|
||||||
|
else
|
||||||
|
error('sys_name should be pz or vc');
|
||||||
|
end
|
||||||
|
|
||||||
|
if strcmp(sys_mass, 'light')
|
||||||
|
initializeSample(struct('mass', 1));
|
||||||
|
elseif strcmp(sys_mass, 'heavy')
|
||||||
|
initializeSample(struct('mass', 50));
|
||||||
|
else
|
||||||
|
error('sys_mass should be light or heavy');
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Run the simulation
|
||||||
|
sim('sim_nano_station_ctrl.slx');
|
||||||
|
|
||||||
|
%% Split the Dsample matrix into vectors
|
||||||
|
[Dx, Dy, Dz, Rx, Ry, Rz] = matSplit(Es.Data, 1); %#ok
|
||||||
|
time = Dsample.Time; %#ok
|
||||||
|
|
||||||
|
%% Save the result
|
||||||
|
filename = sprintf('sim_%s_%s_%s_%s', sys_mass, sys_name, ctrl_type, act_damp);
|
||||||
|
save(sprintf('./mat/%s.mat', filename), ...
|
||||||
|
'time', 'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz', 'K');
|
||||||
|
end
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Inverse Kinematics of the Hexapod
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args:matlab+: :tangle ../src/inverseKinematicsHexapod.m
|
||||||
|
:header-args:matlab+: :comments none :mkdirp yes :eval no
|
||||||
|
:END:
|
||||||
|
<<sec:inverseKinematicsHexapod>>
|
||||||
|
|
||||||
|
This Matlab function is accessible [[file:src/inverseKinematicsHexapod.m][here]].
|
||||||
|
|
||||||
|
#+begin_src matlab
|
||||||
|
function [L] = inverseKinematicsHexapod(hexapod, AP, ARB)
|
||||||
|
% inverseKinematicsHexapod - Compute the initial position of each leg to have the wanted Hexapod's position
|
||||||
|
%
|
||||||
|
% Syntax: inverseKinematicsHexapod(hexapod, AP, ARB)
|
||||||
|
%
|
||||||
|
% Inputs:
|
||||||
|
% - hexapod - Hexapod object containing the geometry of the hexapod
|
||||||
|
% - AP - Position vector of point OB expressed in frame {A} in [m]
|
||||||
|
% - ARB - Rotation Matrix expressed in frame {A}
|
||||||
|
|
||||||
|
% Wanted Length of the hexapod's legs [m]
|
||||||
|
L = zeros(6, 1);
|
||||||
|
|
||||||
|
for i = 1:length(L)
|
||||||
|
Bbi = hexapod.pos_top_tranform(i, :)' - 1e-3*[0 ; 0 ; hexapod.TP.thickness+hexapod.Leg.sphere.top+hexapod.SP.thickness.top+hexapod.jacobian]; % [m]
|
||||||
|
Aai = hexapod.pos_base(i, :)' + 1e-3*[0 ; 0 ; hexapod.BP.thickness+hexapod.Leg.sphere.bottom+hexapod.SP.thickness.bottom-hexapod.h-hexapod.jacobian]; % [m]
|
||||||
|
|
||||||
|
L(i) = sqrt(AP'*AP + Bbi'*Bbi + Aai'*Aai - 2*AP'*Aai + 2*AP'*(ARB*Bbi) - 2*(ARB*Bbi)'*Aai);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#+end_src
|
2553
simscape/index.html
2553
simscape/index.html
File diff suppressed because it is too large
Load Diff
1970
simscape/index.org
1970
simscape/index.org
File diff suppressed because it is too large
Load Diff
1476
simscape_subsystems/index.html
Normal file
1476
simscape_subsystems/index.html
Normal file
File diff suppressed because it is too large
Load Diff
1122
simscape_subsystems/index.org
Normal file
1122
simscape_subsystems/index.org
Normal file
File diff suppressed because it is too large
Load Diff
325
simulink_project/index.html
Normal file
325
simulink_project/index.html
Normal file
@ -0,0 +1,325 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||||
|
<head>
|
||||||
|
<!-- 2019-12-11 mer. 17:06 -->
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>Simulink Project for the NASS</title>
|
||||||
|
<meta name="generator" content="Org mode" />
|
||||||
|
<meta name="author" content="Dehaeze Thomas" />
|
||||||
|
<style type="text/css">
|
||||||
|
<!--/*--><![CDATA[/*><!--*/
|
||||||
|
.title { text-align: center;
|
||||||
|
margin-bottom: .2em; }
|
||||||
|
.subtitle { text-align: center;
|
||||||
|
font-size: medium;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top:0; }
|
||||||
|
.todo { font-family: monospace; color: red; }
|
||||||
|
.done { font-family: monospace; color: green; }
|
||||||
|
.priority { font-family: monospace; color: orange; }
|
||||||
|
.tag { background-color: #eee; font-family: monospace;
|
||||||
|
padding: 2px; font-size: 80%; font-weight: normal; }
|
||||||
|
.timestamp { color: #bebebe; }
|
||||||
|
.timestamp-kwd { color: #5f9ea0; }
|
||||||
|
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
|
||||||
|
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
|
||||||
|
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
|
||||||
|
.underline { text-decoration: underline; }
|
||||||
|
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
|
||||||
|
p.verse { margin-left: 3%; }
|
||||||
|
pre {
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
box-shadow: 3px 3px 3px #eee;
|
||||||
|
padding: 8pt;
|
||||||
|
font-family: monospace;
|
||||||
|
overflow: auto;
|
||||||
|
margin: 1.2em;
|
||||||
|
}
|
||||||
|
pre.src {
|
||||||
|
position: relative;
|
||||||
|
overflow: visible;
|
||||||
|
padding-top: 1.2em;
|
||||||
|
}
|
||||||
|
pre.src:before {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
background-color: white;
|
||||||
|
top: -10px;
|
||||||
|
right: 10px;
|
||||||
|
padding: 3px;
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
pre.src:hover:before { display: inline;}
|
||||||
|
/* Languages per Org manual */
|
||||||
|
pre.src-asymptote:before { content: 'Asymptote'; }
|
||||||
|
pre.src-awk:before { content: 'Awk'; }
|
||||||
|
pre.src-C:before { content: 'C'; }
|
||||||
|
/* pre.src-C++ doesn't work in CSS */
|
||||||
|
pre.src-clojure:before { content: 'Clojure'; }
|
||||||
|
pre.src-css:before { content: 'CSS'; }
|
||||||
|
pre.src-D:before { content: 'D'; }
|
||||||
|
pre.src-ditaa:before { content: 'ditaa'; }
|
||||||
|
pre.src-dot:before { content: 'Graphviz'; }
|
||||||
|
pre.src-calc:before { content: 'Emacs Calc'; }
|
||||||
|
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
|
||||||
|
pre.src-fortran:before { content: 'Fortran'; }
|
||||||
|
pre.src-gnuplot:before { content: 'gnuplot'; }
|
||||||
|
pre.src-haskell:before { content: 'Haskell'; }
|
||||||
|
pre.src-hledger:before { content: 'hledger'; }
|
||||||
|
pre.src-java:before { content: 'Java'; }
|
||||||
|
pre.src-js:before { content: 'Javascript'; }
|
||||||
|
pre.src-latex:before { content: 'LaTeX'; }
|
||||||
|
pre.src-ledger:before { content: 'Ledger'; }
|
||||||
|
pre.src-lisp:before { content: 'Lisp'; }
|
||||||
|
pre.src-lilypond:before { content: 'Lilypond'; }
|
||||||
|
pre.src-lua:before { content: 'Lua'; }
|
||||||
|
pre.src-matlab:before { content: 'MATLAB'; }
|
||||||
|
pre.src-mscgen:before { content: 'Mscgen'; }
|
||||||
|
pre.src-ocaml:before { content: 'Objective Caml'; }
|
||||||
|
pre.src-octave:before { content: 'Octave'; }
|
||||||
|
pre.src-org:before { content: 'Org mode'; }
|
||||||
|
pre.src-oz:before { content: 'OZ'; }
|
||||||
|
pre.src-plantuml:before { content: 'Plantuml'; }
|
||||||
|
pre.src-processing:before { content: 'Processing.js'; }
|
||||||
|
pre.src-python:before { content: 'Python'; }
|
||||||
|
pre.src-R:before { content: 'R'; }
|
||||||
|
pre.src-ruby:before { content: 'Ruby'; }
|
||||||
|
pre.src-sass:before { content: 'Sass'; }
|
||||||
|
pre.src-scheme:before { content: 'Scheme'; }
|
||||||
|
pre.src-screen:before { content: 'Gnu Screen'; }
|
||||||
|
pre.src-sed:before { content: 'Sed'; }
|
||||||
|
pre.src-sh:before { content: 'shell'; }
|
||||||
|
pre.src-sql:before { content: 'SQL'; }
|
||||||
|
pre.src-sqlite:before { content: 'SQLite'; }
|
||||||
|
/* additional languages in org.el's org-babel-load-languages alist */
|
||||||
|
pre.src-forth:before { content: 'Forth'; }
|
||||||
|
pre.src-io:before { content: 'IO'; }
|
||||||
|
pre.src-J:before { content: 'J'; }
|
||||||
|
pre.src-makefile:before { content: 'Makefile'; }
|
||||||
|
pre.src-maxima:before { content: 'Maxima'; }
|
||||||
|
pre.src-perl:before { content: 'Perl'; }
|
||||||
|
pre.src-picolisp:before { content: 'Pico Lisp'; }
|
||||||
|
pre.src-scala:before { content: 'Scala'; }
|
||||||
|
pre.src-shell:before { content: 'Shell Script'; }
|
||||||
|
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
|
||||||
|
/* additional language identifiers per "defun org-babel-execute"
|
||||||
|
in ob-*.el */
|
||||||
|
pre.src-cpp:before { content: 'C++'; }
|
||||||
|
pre.src-abc:before { content: 'ABC'; }
|
||||||
|
pre.src-coq:before { content: 'Coq'; }
|
||||||
|
pre.src-groovy:before { content: 'Groovy'; }
|
||||||
|
/* additional language identifiers from org-babel-shell-names in
|
||||||
|
ob-shell.el: ob-shell is the only babel language using a lambda to put
|
||||||
|
the execution function name together. */
|
||||||
|
pre.src-bash:before { content: 'bash'; }
|
||||||
|
pre.src-csh:before { content: 'csh'; }
|
||||||
|
pre.src-ash:before { content: 'ash'; }
|
||||||
|
pre.src-dash:before { content: 'dash'; }
|
||||||
|
pre.src-ksh:before { content: 'ksh'; }
|
||||||
|
pre.src-mksh:before { content: 'mksh'; }
|
||||||
|
pre.src-posh:before { content: 'posh'; }
|
||||||
|
/* Additional Emacs modes also supported by the LaTeX listings package */
|
||||||
|
pre.src-ada:before { content: 'Ada'; }
|
||||||
|
pre.src-asm:before { content: 'Assembler'; }
|
||||||
|
pre.src-caml:before { content: 'Caml'; }
|
||||||
|
pre.src-delphi:before { content: 'Delphi'; }
|
||||||
|
pre.src-html:before { content: 'HTML'; }
|
||||||
|
pre.src-idl:before { content: 'IDL'; }
|
||||||
|
pre.src-mercury:before { content: 'Mercury'; }
|
||||||
|
pre.src-metapost:before { content: 'MetaPost'; }
|
||||||
|
pre.src-modula-2:before { content: 'Modula-2'; }
|
||||||
|
pre.src-pascal:before { content: 'Pascal'; }
|
||||||
|
pre.src-ps:before { content: 'PostScript'; }
|
||||||
|
pre.src-prolog:before { content: 'Prolog'; }
|
||||||
|
pre.src-simula:before { content: 'Simula'; }
|
||||||
|
pre.src-tcl:before { content: 'tcl'; }
|
||||||
|
pre.src-tex:before { content: 'TeX'; }
|
||||||
|
pre.src-plain-tex:before { content: 'Plain TeX'; }
|
||||||
|
pre.src-verilog:before { content: 'Verilog'; }
|
||||||
|
pre.src-vhdl:before { content: 'VHDL'; }
|
||||||
|
pre.src-xml:before { content: 'XML'; }
|
||||||
|
pre.src-nxml:before { content: 'XML'; }
|
||||||
|
/* add a generic configuration mode; LaTeX export needs an additional
|
||||||
|
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
|
||||||
|
pre.src-conf:before { content: 'Configuration File'; }
|
||||||
|
|
||||||
|
table { border-collapse:collapse; }
|
||||||
|
caption.t-above { caption-side: top; }
|
||||||
|
caption.t-bottom { caption-side: bottom; }
|
||||||
|
td, th { vertical-align:top; }
|
||||||
|
th.org-right { text-align: center; }
|
||||||
|
th.org-left { text-align: center; }
|
||||||
|
th.org-center { text-align: center; }
|
||||||
|
td.org-right { text-align: right; }
|
||||||
|
td.org-left { text-align: left; }
|
||||||
|
td.org-center { text-align: center; }
|
||||||
|
dt { font-weight: bold; }
|
||||||
|
.footpara { display: inline; }
|
||||||
|
.footdef { margin-bottom: 1em; }
|
||||||
|
.figure { padding: 1em; }
|
||||||
|
.figure p { text-align: center; }
|
||||||
|
.equation-container {
|
||||||
|
display: table;
|
||||||
|
text-align: center;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.equation {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
.equation-label {
|
||||||
|
display: table-cell;
|
||||||
|
text-align: right;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
.inlinetask {
|
||||||
|
padding: 10px;
|
||||||
|
border: 2px solid gray;
|
||||||
|
margin: 10px;
|
||||||
|
background: #ffffcc;
|
||||||
|
}
|
||||||
|
#org-div-home-and-up
|
||||||
|
{ text-align: right; font-size: 70%; white-space: nowrap; }
|
||||||
|
textarea { overflow-x: auto; }
|
||||||
|
.linenr { font-size: smaller }
|
||||||
|
.code-highlighted { background-color: #ffff00; }
|
||||||
|
.org-info-js_info-navigation { border-style: none; }
|
||||||
|
#org-info-js_console-label
|
||||||
|
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
|
||||||
|
.org-info-js_search-highlight
|
||||||
|
{ background-color: #ffff00; color: #000000; font-weight: bold; }
|
||||||
|
.org-svg { width: 90%; }
|
||||||
|
/*]]>*/-->
|
||||||
|
</style>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../css/htmlize.css"/>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../css/readtheorg.css"/>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../css/zenburn.css"/>
|
||||||
|
<script type="text/javascript" src="../js/jquery.min.js"></script>
|
||||||
|
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
|
||||||
|
<script type="text/javascript" src="../js/jquery.stickytableheaders.min.js"></script>
|
||||||
|
<script type="text/javascript" src="../js/readtheorg.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
/*
|
||||||
|
@licstart The following is the entire license notice for the
|
||||||
|
JavaScript code in this tag.
|
||||||
|
|
||||||
|
Copyright (C) 2012-2019 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
The JavaScript code in this tag is free software: you can
|
||||||
|
redistribute it and/or modify it under the terms of the GNU
|
||||||
|
General Public License (GNU GPL) as published by the Free Software
|
||||||
|
Foundation, either version 3 of the License, or (at your option)
|
||||||
|
any later version. The code is distributed WITHOUT ANY WARRANTY;
|
||||||
|
without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
|
||||||
|
|
||||||
|
As additional permission under GNU GPL version 3 section 7, you
|
||||||
|
may distribute non-source (e.g., minimized or compacted) forms of
|
||||||
|
that code without the copy of the GNU GPL normally required by
|
||||||
|
section 4, provided you include this license notice and a URL
|
||||||
|
through which recipients can access the Corresponding Source.
|
||||||
|
|
||||||
|
|
||||||
|
@licend The above is the entire license notice
|
||||||
|
for the JavaScript code in this tag.
|
||||||
|
*/
|
||||||
|
<!--/*--><![CDATA[/*><!--*/
|
||||||
|
function CodeHighlightOn(elem, id)
|
||||||
|
{
|
||||||
|
var target = document.getElementById(id);
|
||||||
|
if(null != target) {
|
||||||
|
elem.cacheClassElem = elem.className;
|
||||||
|
elem.cacheClassTarget = target.className;
|
||||||
|
target.className = "code-highlighted";
|
||||||
|
elem.className = "code-highlighted";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function CodeHighlightOff(elem, id)
|
||||||
|
{
|
||||||
|
var target = document.getElementById(id);
|
||||||
|
if(elem.cacheClassElem)
|
||||||
|
elem.className = elem.cacheClassElem;
|
||||||
|
if(elem.cacheClassTarget)
|
||||||
|
target.className = elem.cacheClassTarget;
|
||||||
|
}
|
||||||
|
/*]]>*///-->
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="org-div-home-and-up">
|
||||||
|
<a accesskey="h" href="../index.html"> UP </a>
|
||||||
|
|
|
||||||
|
<a accesskey="H" href="../index.html"> HOME </a>
|
||||||
|
</div><div id="content">
|
||||||
|
<h1 class="title">Simulink Project for the NASS</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Simulink Project is used for the study of the NASS using Simscape.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
From the <a href="https://mathworks.com/products/simulink/projects.html">Simulink project</a> mathworks page:
|
||||||
|
</p>
|
||||||
|
<blockquote>
|
||||||
|
<p>
|
||||||
|
Simulink® and Simulink Projects provide a collaborative, scalable environment that enables teams to manage their files and data in one place.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
With Simulink Projects, you can:
|
||||||
|
</p>
|
||||||
|
<ul class="org-ul">
|
||||||
|
<li><b>Collaborate</b>: Enforce companywide standards such as company tools, libraries, and standard startup and shutdown scripts. Share your work with rich sharing options including MATLAB® toolboxes, email, and archives.</li>
|
||||||
|
<li><b>Automate</b>: Set up your project environment correctly every time by automating steps such as loading the data, managing the path, and opening the models.</li>
|
||||||
|
<li><b>Integrate with source control</b>: Enable easy integration with source control and configuration management tools.</li>
|
||||||
|
</ul>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The project can be opened using the <code>simulinkproject</code> function:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="org-src-container">
|
||||||
|
<pre class="src src-matlab">simulinkproject<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-string">'./'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
When the project opens, a startup script is ran.
|
||||||
|
The startup script is defined below and is exported to the <code>project_startup.m</code> script.
|
||||||
|
</p>
|
||||||
|
<div class="org-src-container">
|
||||||
|
<pre class="src src-matlab">project = simulinkproject;
|
||||||
|
projectRoot = project.RootFolder;
|
||||||
|
|
||||||
|
myCacheFolder = fullfile<span class="org-rainbow-delimiters-depth-1">(</span>projectRoot, <span class="org-string">'.SimulinkCache'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
|
||||||
|
myCodeFolder = fullfile<span class="org-rainbow-delimiters-depth-1">(</span>projectRoot, <span class="org-string">'.SimulinkCode'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
|
||||||
|
|
||||||
|
Simulink.fileGenControl<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-string">'set'</span>,...
|
||||||
|
<span class="org-string">'CacheFolder'</span>, myCacheFolder,...
|
||||||
|
<span class="org-string">'CodeGenFolder'</span>, myCodeFolder,...
|
||||||
|
<span class="org-string">'createDir'</span>, <span class="org-constant">true</span><span class="org-rainbow-delimiters-depth-1">)</span>;
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
When the project closes, it runs the <code>project_shutdown.m</code> script defined below.
|
||||||
|
</p>
|
||||||
|
<div class="org-src-container">
|
||||||
|
<pre class="src src-matlab">Simulink.fileGenControl<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-string">'reset'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The project also permits to automatically add defined folder to the path when the project is opened.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div id="postamble" class="status">
|
||||||
|
<p class="author">Author: Dehaeze Thomas</p>
|
||||||
|
<p class="date">Created: 2019-12-11 mer. 17:06</p>
|
||||||
|
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
82
simulink_project/index.org
Normal file
82
simulink_project/index.org
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#+TITLE: Simulink Project for the NASS
|
||||||
|
:DRAWER:
|
||||||
|
#+STARTUP: overview
|
||||||
|
|
||||||
|
#+LANGUAGE: en
|
||||||
|
#+EMAIL: dehaeze.thomas@gmail.com
|
||||||
|
#+AUTHOR: Dehaeze Thomas
|
||||||
|
|
||||||
|
#+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: <link rel="stylesheet" type="text/css" href="../css/zenburn.css"/>
|
||||||
|
#+HTML_HEAD: <script type="text/javascript" src="../js/jquery.min.js"></script>
|
||||||
|
#+HTML_HEAD: <script type="text/javascript" src="../js/bootstrap.min.js"></script>
|
||||||
|
#+HTML_HEAD: <script type="text/javascript" src="../js/jquery.stickytableheaders.min.js"></script>
|
||||||
|
#+HTML_HEAD: <script type="text/javascript" src="../js/readtheorg.js"></script>
|
||||||
|
|
||||||
|
#+HTML_MATHJAX: align: center tagside: right font: TeX
|
||||||
|
|
||||||
|
#+PROPERTY: header-args:matlab :session *MATLAB*
|
||||||
|
#+PROPERTY: header-args:matlab+ :comments org
|
||||||
|
#+PROPERTY: header-args:matlab+ :results none
|
||||||
|
#+PROPERTY: header-args:matlab+ :exports both
|
||||||
|
#+PROPERTY: header-args:matlab+ :eval no-export
|
||||||
|
#+PROPERTY: header-args:matlab+ :output-dir figs
|
||||||
|
#+PROPERTY: header-args:matlab+ :tangle no
|
||||||
|
#+PROPERTY: header-args:matlab+ :mkdirp yes
|
||||||
|
|
||||||
|
#+PROPERTY: header-args:shell :eval no-export
|
||||||
|
|
||||||
|
#+PROPERTY: header-args:latex :headers '("\\usepackage{tikz}" "\\usepackage{import}" "\\import{$HOME/Cloud/thesis/latex/}{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 raw replace :buffer no
|
||||||
|
#+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
|
||||||
|
:END:
|
||||||
|
|
||||||
|
Simulink Project is used for the study of the NASS using Simscape.
|
||||||
|
|
||||||
|
From the [[https://mathworks.com/products/simulink/projects.html][Simulink project]] mathworks page:
|
||||||
|
#+begin_quote
|
||||||
|
Simulink® and Simulink Projects provide a collaborative, scalable environment that enables teams to manage their files and data in one place.
|
||||||
|
|
||||||
|
With Simulink Projects, you can:
|
||||||
|
- *Collaborate*: Enforce companywide standards such as company tools, libraries, and standard startup and shutdown scripts. Share your work with rich sharing options including MATLAB® toolboxes, email, and archives.
|
||||||
|
- *Automate*: Set up your project environment correctly every time by automating steps such as loading the data, managing the path, and opening the models.
|
||||||
|
- *Integrate with source control*: Enable easy integration with source control and configuration management tools.
|
||||||
|
#+end_quote
|
||||||
|
|
||||||
|
The project can be opened using the =simulinkproject= function:
|
||||||
|
|
||||||
|
#+begin_src matlab
|
||||||
|
simulinkproject('./');
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
When the project opens, a startup script is ran.
|
||||||
|
The startup script is defined below and is exported to the =project_startup.m= script.
|
||||||
|
#+begin_src matlab :eval no :tangle ../src/project_startup.m
|
||||||
|
project = simulinkproject;
|
||||||
|
projectRoot = project.RootFolder;
|
||||||
|
|
||||||
|
myCacheFolder = fullfile(projectRoot, '.SimulinkCache');
|
||||||
|
myCodeFolder = fullfile(projectRoot, '.SimulinkCode');
|
||||||
|
|
||||||
|
Simulink.fileGenControl('set',...
|
||||||
|
'CacheFolder', myCacheFolder,...
|
||||||
|
'CodeGenFolder', myCodeFolder,...
|
||||||
|
'createDir', true);
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
When the project closes, it runs the =project_shutdown.m= script defined below.
|
||||||
|
#+begin_src matlab :eval no :tangle ../src/project_shutdown.m
|
||||||
|
Simulink.fileGenControl('reset');
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
The project also permits to automatically add defined folder to the path when the project is opened.
|
Loading…
Reference in New Issue
Block a user