-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisaster.m
More file actions
92 lines (77 loc) · 2.77 KB
/
disaster.m
File metadata and controls
92 lines (77 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
clc
clear all
close all
%load('results-diffdrive/circle/start_center/10-09-2024 13-27-12/workspace_composite.mat')
%load('results-diffdrive/circle/start_center/10-09-2024 15-33-08/workspace_composite.mat')
%load('/home/emamaker/documents/Università/tesi/tesi-sim/results-diffdrive/square/10-09-2024 13-53-35/workspace_composite.mat')
load('results-diffdrive/figure8/toofast/10-09-2024-22-35-17/workspace_composite.mat')
y = cell(1,3);
for n = 1:3
y{n} = [q{n}(:,1) + sim_data{n}.b*cos(q{n}(:,3)), q{n}(:,2) + sim_data{n}.b*sin(q{n}(:,3))];
end
figure(1)
hold on
plot(ref_t{n}(:, 1), ref_t{n}(:, 2), "DisplayName", "Ref", "LineStyle", "--", 'LineWidth', 2)
for n=1:3
plot(y{n}(:, 1), y{n}(:, 2), "DisplayName", ['state' num2str(n)], 'LineWidth', 2)
end
legend()
hold off
%U_corr{1} = U{1} - U_track{1}
plot_input(2, t, U, 'sat')
plot_input(3, t, U_track, 'track')
plot_input(4, t, U_corr, 'corr')
plot_traj(t, y, ref_t)
function plot_input(nfig, t, input, name)
figure(nfig)
subplot(2,1,1)
hold on
plot(t{1}, input{1}(:,1), "DisplayName", ['w_r ' num2str(1) name], 'LineWidth', 2, 'LineStyle', '-.')
plot(t{2}, input{2}(:,1), "DisplayName", ['w_r ' num2str(2) name], 'LineWidth', 4, 'LineStyle', ':')
plot(t{3}, input{3}(:,1), "DisplayName", ['w_r ' num2str(3) name], 'LineWidth', 2, 'LineStyle', '--')
subplot(2,1,2)
hold on
plot(t{1}, input{1}(:,2), "DisplayName", ['w_l ' num2str(1) name], 'LineWidth', 2, 'LineStyle', '-.')
plot(t{2}, input{2}(:,2), "DisplayName", ['w_l ' num2str(2) name], 'LineWidth', 4, 'LineStyle', ':')
plot(t{3}, input{3}(:,2), "DisplayName", ['w_l ' num2str(3) name], 'LineWidth', 2, 'LineStyle', '--') %{
%{
for n=1:3
subplot(2,1,1)
hold on
plot(t{n}, input{n}(:,1), "DisplayName", ['w_r ' num2str(n) name], 'LineWidth', 2, 'LineStyle', '-.')
subplot(2,1,2)
hold on
plot(t{n}, input{n}(:,2), "DisplayName", ['w_l ' num2str(n) name], 'LineWidth', 2, 'LineStyle', '-.')
end
%}
subplot(2,1,1)
legend()
subplot(2,1,2)
legend
hold off
end
function plot_traj(t, q, ref_t)
figure(10)
for n=1:3
ref = ref_t{n};
x = q{n};
ex = ref(:, 1) - x(:, 1);
ey = ref(:, 2) - x(:, 2);
subplot(2,2,1)
hold on
plot(t{n}, x(:,1), 'DisplayName', ['x ' num2str(n)], 'LineWidth', 2)
legend()
subplot(2,2,2)
hold on
plot(t{n}, x(:,2), 'DisplayName', ['y ' num2str(n)], 'LineWidth', 2)
legend()
subplot(2,2,3)
hold on
plot(t{n}, ex, 'DisplayName', ['errx ' num2str(n)], 'LineWidth', 2)
legend()
subplot(2,2,4)
hold on
plot(t{n}, ey, 'DisplayName', ['erry ' num2str(n)], 'LineWidth', 2)
legend()
end
end