From 1a5ecc5ce4c739e0e9e22f13dd384c98a849572f Mon Sep 17 00:00:00 2001 From: Albin Date: Wed, 20 Nov 2019 19:15:08 +0100 Subject: =?UTF-8?q?Bootstrap=20funkar=20f=C3=B6r=204=20bilar=20(bl=C3=A5?= =?UTF-8?q?=2017,=20vit=2082,=20bussen,=20gr=C3=A5=2067)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kod/bilbana/yc4/do_boot.m | 16 +++++++++++++++- Kod/bilbana/yc4/do_car.m | 4 ++-- Kod/bilbana/yc4/main.m | 4 ++-- 3 files changed, 19 insertions(+), 5 deletions(-) (limited to 'Kod/bilbana') diff --git a/Kod/bilbana/yc4/do_boot.m b/Kod/bilbana/yc4/do_boot.m index ffa7878..31f4db0 100644 --- a/Kod/bilbana/yc4/do_boot.m +++ b/Kod/bilbana/yc4/do_boot.m @@ -5,11 +5,25 @@ if car.running == true %% BEFORE FIRST LAP if car.lap == 0 t = toc(boot.time); - if t > 1 + if t > 0.6 car.constant = car.constant + 0.05; disp(car.constant) boot.time = tic; end end + %% First segment + if car.lap == 1 && car.segment == 1 + t = toc(boot.time); + if t > 3 + car.constant = car.constant + 0.05; + disp(car.constant) + boot.time = tic; + end + end + %% END BOOTSTRAP + if car.segment > 2 + boot.status = 0; + disp('END OF BOOTSTRAP') + end end end \ No newline at end of file diff --git a/Kod/bilbana/yc4/do_car.m b/Kod/bilbana/yc4/do_car.m index 46d1a9d..7b7ebfd 100644 --- a/Kod/bilbana/yc4/do_car.m +++ b/Kod/bilbana/yc4/do_car.m @@ -1,4 +1,4 @@ -function [car, stop, display_data] = do_car(car, t, display_data) +function [car, stop, display_data] = do_car(car, t, display_data, boot) %DO_CAR Ger nya värden till struct car, avgör om koden ska stoppas samt hämtar displaydata. %{ Input/Output: @@ -44,7 +44,7 @@ end %% READ INPUT FROM TRACK if car.running == true if car.lap ~= 0 - if toc(car.seg_tic) > 9.0 + if toc(car.seg_tic) > 9.0 && not(boot.status) set_car_speed(1, 0); set_car_speed(2, 0); %disp(strjoin({'AvÃ¥kning bil', num2str(car.num)})); diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index 6794831..b7221e3 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -150,8 +150,8 @@ while 1 drawnow %% CORE OF LOOP - [car1, car1.stop, display.data] = do_car(car1, t, display.data); - [car2, car2.stop, display.data] = do_car(car2, t, display.data); + [car1, car1.stop, display.data] = do_car(car1, t, display.data, boot1); + [car2, car2.stop, display.data] = do_car(car2, t, display.data, boot2); %% BOOTSTRAP if boot1.status [car1, boot1] = do_boot(car1, boot1); -- cgit v1.2.1