45 lines
1.1 KiB
Matlab
45 lines
1.1 KiB
Matlab
% Simulation Configuration
|
|
% :PROPERTIES:
|
|
% :header-args:matlab+: :tangle src/initializeSimConf.m
|
|
% :header-args:matlab+: :comments org :mkdirp yes
|
|
% :header-args:matlab+: :eval no :results none
|
|
% :END:
|
|
% <<sec:initializeSimConf>>
|
|
|
|
% This Matlab function is accessible [[file:src/initializeSimConf.m][here]].
|
|
|
|
|
|
function [] = initializeSimConf(opts_param)
|
|
%% Default values for opts
|
|
opts = struct('Ts', 1e-4, ... % Sampling time [s]
|
|
'Tsim', 10, ... % Simulation time [s]
|
|
'cl_time', 0, ... % Close Loop time [s]
|
|
'gravity', false ... % Gravity along the z axis
|
|
);
|
|
|
|
%% Populate opts with input parameters
|
|
if exist('opts_param','var')
|
|
for opt = fieldnames(opts_param)'
|
|
opts.(opt{1}) = opts_param.(opt{1});
|
|
end
|
|
end
|
|
|
|
%%
|
|
sim_conf = struct();
|
|
|
|
%%
|
|
sim_conf.Ts = opts.Ts;
|
|
sim_conf.Tsim = opts.Tsim;
|
|
sim_conf.cl_time = opts.cl_time;
|
|
|
|
%% Gravity
|
|
if opts.gravity
|
|
sim_conf.g = -9.8; %#ok
|
|
else
|
|
sim_conf.g = 0; %#ok
|
|
end
|
|
|
|
%% Save
|
|
save('./mat/sim_conf.mat', 'sim_conf');
|
|
end
|