summaryrefslogtreecommitdiffstats
path: root/Kod
diff options
context:
space:
mode:
authorAlbin <albwa833@student.liu.se>2019-11-20 19:15:08 +0100
committerAlbin <albwa833@student.liu.se>2019-11-20 19:15:08 +0100
commit1a5ecc5ce4c739e0e9e22f13dd384c98a849572f (patch)
treede8174b67ba23901e4f2e92c0612cb5cc988ca3c /Kod
parent9b04ca018663d2f1015a3c77f545ed2df6b7b79d (diff)
downloadtfyy51-1a5ecc5ce4c739e0e9e22f13dd384c98a849572f.tar.gz
Bootstrap funkar för 4 bilar (blå 17, vit 82, bussen, grå 67)
Diffstat (limited to 'Kod')
-rw-r--r--Kod/bilbana/yc4/do_boot.m16
-rw-r--r--Kod/bilbana/yc4/do_car.m4
-rw-r--r--Kod/bilbana/yc4/main.m4
3 files changed, 19 insertions, 5 deletions
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);