file cleanup + recompile all videos

master
= 2024-08-30 16:51:21 +02:00
parent a9622f1f00
commit 8e87f9b006
40 changed files with 37 additions and 176 deletions

View File

@ -8,21 +8,21 @@ disp('Photos will start in 3s')
pause(3)
PLOT_TESTS = [
%"results-diffdrive/straightline/chill/01-Aug-2024 15:34:03";
%"results-diffdrive/straightline/chill_errortheta_pisixths/01-Aug-2024 15:56:36";
%"results-diffdrive/square/01-Aug-2024 16:18:51";
%"results-diffdrive/circle/start_center/01-Aug-2024 16:46:41";
%"results-diffdrive/circle/start_tangent/01-Aug-2024 16:55:09";
%"results-diffdrive/circle/toofast/01-Aug-2024 17:35:25"
%"results-diffdrive/straightline/toofast/01-Aug-2024 15:37:48"
%"results-diffdrive/figure8/chill/15-Aug-2024 09:16:21";
%"results-diffdrive/figure8/toofast/15-Aug-2024 09:10:32"cd
"results-diffdrive/straightline/abrupt_stop_chill/27-Aug-2024 10:27:31";
"results-diffdrive/straightline/abrupt_stop_toofast/27-Aug-2024 10:44:35"
"results-diffdrive/sin/no_start_error/27-Aug-2024 19:28:17";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19:29:42";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19:31:17";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19:38:03"
%"results-diffdrive/straightline/chill/01-Aug-2024 15-34-03";
%"results-diffdrive/straightline/chill_errortheta_pisixths/01-Aug-2024 15-56-36";
%"results-diffdrive/square/01-Aug-2024 16-18-51";
%"results-diffdrive/circle/start_center/01-Aug-2024 16-46-41";
%"results-diffdrive/circle/start_tangent/01-Aug-2024 16-55-09";
%"results-diffdrive/circle/toofast/01-Aug-2024 17-35-25"
%"results-diffdrive/straightline/toofast/01-Aug-2024 15-37-48"
%"results-diffdrive/figure8/chill/15-Aug-2024 09-16-21";
%"results-diffdrive/figure8/toofast/15-Aug-2024 09-10-32"cd
"results-diffdrive/straightline/abrupt_stop_chill/27-Aug-2024 10-27-31";
"results-diffdrive/straightline/abrupt_stop_toofast/27-Aug-2024 10-44-35"
"results-diffdrive/sin/no_start_error/27-Aug-2024 19-28-17";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19-29-42";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19-31-17";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19-38-03"
]
s_ = size(PLOT_TESTS)

3
tesi.m
View File

@ -49,7 +49,8 @@ for i = 1:s_(1)
plot_results(t{n}, q{n}, ref_t{n}, U{n}, U_track{n}, U_corr{n});
end
f1 = [ TEST '/' datestr(datetime)];
% windows compatible
f1 = [ TEST '/' char(datetime, 'dd-MM-yyyy HH-mm-ss')];
f = ['results-diffdrive/' f1];
mkdir(f)
savefig(h, [f '/figure.fig']);

View File

@ -1,141 +0,0 @@
TEST = 'cardioid'
CONTROLLER = 3
sim_data = load(['tests/' TEST '/common.mat']);
sim_data.q0 = set_initial_conditions(sim_data.INITIAL_CONDITIONS);
[ref dref] = set_trajectory(sim_data.TRAJECTORY);
sim_data.ref = ref;
sim_data.dref = dref;
data = load(['tests/' TEST '/' num2str(CONTROLLER) '.mat']);
sim_data.PREDICTION_HORIZON = data.PREDICTION_HORIZON;
sim_data.U_corr_history = zeros(2,1,sim_data.PREDICTION_HORIZON);
sim_data
[t, q, ref_t, U, U_track, U_corr] = simulate_discr(sim_data);
figure('Name', [TEST ' ' num2str(CONTROLLER)] );
plot_results(t,q,ref_t,U,U_track,U_corr);
%% FUNCTION DECLARATIONS
% Discrete-time simulation
function [t, q, ref_t, U, U_track, U_corr] = simulate_discr(sim_data)
tc = sim_data.tc;
steps = sim_data.tfin/tc
q = sim_data.q0';
t = 0;
[u_discr, u_track, u_corr, U_corr_history] = control_act(t, q, sim_data);
sim_data.U_corr_history = U_corr_history;
U = u_discr';
U_corr = u_corr';
U_track = u_track';
for n = 1:steps
sim_data.old_u_corr = u_corr;
sim_data.old_u_track = u_track;
sim_data.old_u = u_discr;
tspan = [(n-1)*tc n*tc];
z0 = q(end, :);
%[v, z] = ode45(@sistema_discr, tspan, z0, u_discr);
[v, z] = ode45(@(v, z) sistema_discr(v, z, u_discr), tspan, z0);
q = [q; z];
t = [t; v];
[u_discr, u_track, u_corr, U_corr_history] = control_act(t(end), q(end, :), sim_data);
sim_data.U_corr_history = U_corr_history;
U = [U; ones(length(v), 1)*u_discr'];
U_corr = [U_corr; ones(length(v), 1)*u_corr'];
U_track = [U_track; ones(length(v), 1)*u_track'];
end
ref_t = double(subs(sim_data.ref, t'))';
end
%%
% Plots
function plot_results(t, x, ref, U, U_track, U_corr)
subplot(4,2,1)
hold on
title("trajectory / state")
plot(ref(:, 1), ref(:, 2), "DisplayName", "Ref")
plot(x(:, 1), x(:, 2), "DisplayName", "state")
rectangle('Position', [x(1,1)-0.075, x(1,2)-0.075, 0.15, 0.15], 'Curvature', [1,1])
xlabel('x')
ylabel('y')
legend()
subplot(4,2,3)
plot(t, U(:, 1))
xlabel('t')
ylabel('input v')
subplot(4,2,4)
plot(t, U(:, 2))
xlabel('t')
ylabel('input w')
hold off
subplot(4,2,5)
plot(t, U_corr(:, 1))
xlabel('t')
ylabel('correction input v')
subplot(4,2,6)
plot(t, U_corr(:, 2))
xlabel('t')
ylabel('correction input w')
subplot(4,2,7)
plot(t, U_track(:, 1))
xlabel('t')
ylabel('tracking input v')
subplot(4,2,8)
plot(t, U_track(:, 2))
xlabel('t')
ylabel('tracking input w')
ex = ref(:, 1) - x(:, 1);
ey = ref(:, 2) - x(:, 2);
subplot(8,8,5)
hold on
xlabel('t')
ylabel('x')
plot(t, ref(:, 1), "DisplayName", "X_{ref}");
plot(t, x(:, 1), "DisplayName", "X");
legend()
hold off
subplot(8,8,6)
plot(t, ex);
xlabel('t')
ylabel('x error')
subplot(8,8,13)
hold on
xlabel('t')
ylabel('y')
plot(t, ref(:, 2), "DisplayName", "Y_{ref}");
plot(t, x(:, 2), "DisplayName", "Y");
legend()
hold off
subplot(8,8,14)
plot(t, ey);
xlabel('t')
ylabel('y error')
subplot(4, 4, 4);
error_norm = sqrt(ex.*ex + ey.*ey);
plot(t, error_norm );
xlabel("t")
ylabel("error norm")
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -5,24 +5,23 @@ disp('Waiting 5s')
pause(1)
PLOT_TESTS = [
"results-diffdrive/straightline/chill/01-Aug-2024 15:34:03";
"results-diffdrive/straightline/chill_errortheta_pisixths/01-Aug-2024 15:56:36";
"results-diffdrive/square/01-Aug-2024 16:18:51";
"results-diffdrive/circle/start_center/01-Aug-2024 16:46:41";
"results-diffdrive/circle/start_tangent/01-Aug-2024 16:55:09";
"results-diffdrive/circle/toofast/01-Aug-2024 17:35:25"
"results-diffdrive/straightline/toofast/01-Aug-2024 15:37:48"
"results-diffdrive/figure8/chill/15-Aug-2024 09:16:21";
"results-diffdrive/figure8/toofast/15-Aug-2024 09:10:32";
"results-diffdrive/straightline/abrupt_stop_chill/27-Aug-2024 10:27:31";
"results-diffdrive/straightline/abrupt_stop_toofast/27-Aug-2024 10:44:35"
"results-diffdrive/cardioid/start_tangent/01-Aug-2024 18:53:41";
"results-diffdrive/figure8/fancyreps/09-Aug-2024 13:04:44";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19:28:17";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19:29:42";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19:31:17";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19:38:03"
"results-diffdrive/straightline/chill/01-Aug-2024 15-34-03";
"results-diffdrive/straightline/chill_errortheta_pisixths/01-Aug-2024 15-56-36";
"results-diffdrive/square/01-Aug-2024 16-18-51";
"results-diffdrive/circle/start_center/01-Aug-2024 16-46-41";
"results-diffdrive/circle/start_tangent/01-Aug-2024 16-55-09";
"results-diffdrive/circle/toofast/01-Aug-2024 17-35-25"
"results-diffdrive/straightline/toofast/01-Aug-2024 15-37-48"
"results-diffdrive/figure8/chill/15-Aug-2024 09-16-21";
"results-diffdrive/figure8/toofast/15-Aug-2024 09-10-32";
"results-diffdrive/straightline/abrupt_stop_chill/27-Aug-2024 10-27-31";
"results-diffdrive/straightline/abrupt_stop_toofast/27-Aug-2024 10-44-35"
"results-diffdrive/cardioid/start_tangent/01-Aug-2024 18-53-41";
"results-diffdrive/figure8/fancyreps/09-Aug-2024 13-04-44";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19-28-17";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19-29-42";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19-31-17";
"results-diffdrive/sin/no_start_error/27-Aug-2024 19-38-03"
]
s_ = size(PLOT_TESTS)
@ -40,6 +39,8 @@ for i = 1:s_(1)
close all; pause(2); video(q{2}', ref_t{2}', Q_pred{2}, U_track{2}, U_corr{2}, 1, 0.12, t{2}, 4, sim_data{2}.tc*0.25, "track and 1-step");
close all; pause(2); video(q{3}', ref_t{3}', Q_pred{3}, U_track{3}, U_corr{3}, 3, 0.12, t{3}, 4, sim_data{3}.tc*0.25, "track and multistep");
movefile("*.gif", dir);
%movefile("*.gif", dir);
%movefile("*.avi", dir);
movefile("*.mp4", dir);
end