coopPayloadSim.m 2.24 KB
Newer Older
mmroma's avatar
mmroma committed
1
%% Cooperative Payload Simulator
mmroma's avatar
mmroma committed
2
3
4
5
6
7
8
% Author: Matthew Romano (mmroma@umich.edu)
% Date: 1/21/2019

% This is the high level script that calls all of the necessary functions
% to run the simulation. When tuning and testing, changes should be made to
% the parameters files (called by setUpParameters() ).

mmroma's avatar
mmroma committed
9
%% Add Necessary Folders to MATLAB Path (add everything)
10
addpath(genpath(pwd));
mmroma's avatar
mmroma committed
11

12
%% Get user input
13
answer = input('Would you like to load from a matlab file? (Y/N) ', 's');
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

%% Create data
if strcmp(answer, 'N') == 1
    %% Set Up Parameters
    fprintf('Select desired trajectory: \n')
    menu = {'(1) Hover             ';
            '(2) Square            ';
            '(3) Rise and fall     ';
            '(4) Rectangle         ';
            '(5) Linear Function   ';
            '(6) Quadratic Function';
            '(7) Sine Curve        ';
            '(8) Circle            ';
            '(9) Vertical Circle   ';
            '(10) Helix            ';
            '(11) Cardioid         ';
            '(12) 3D Limaçon       ';
            '(13) Circles          ';
            '(14) Ellipse          ';
            '(15) Cycloid          ';
            '(16) Staircase        ';
            '(17) Triangle         ';
            '(18) Hourglass        ';
            '(19) Star             ';
            '(20) Spiral           ';
            '(21) Lissajous        ';
            '(22) Simple Flight    ';
            '(23) Pyramid          '
            };
    for index = 1:length(menu) 
        fprintf(1, '%s\n', menu{index});
    end
    traj = input('Enter trajectory number: ', 's');
    
    params = setUpParameters(str2num(traj));
    
    %% Simulate
    simData = runSimulation(params);
    
    %% Save Params & simData
    saveData(simData,params, 'run');

%% Load Data
elseif strcmp(answer, 'Y') == 1
58
59
    file = input('Enter file name: ', 's');
    load(file);
60
    params.curr_run = int8(str2double(extractBetween(file, (strfind(file, 'n')+1), (strfind(file, '.')-1))));
mmroma's avatar
mmroma committed
61

62
%% Display Error Message  
63
else
64
65
    msg = 'Error. Invalid input.';
    error(msg);
mmroma's avatar
mmroma committed
66
67
end 

68
%% Plot data (and save figures)
mmroma's avatar
mmroma committed
69
70
plotData(simData,params);

71
72
73
%% Animate 
% animate(strcat('Run',num2str(params.curr_run),'/','animation'), simData,params);
animate('none', simData,params);
mmroma's avatar
mmroma committed
74

75
76