From 06991623c226f3014ef51bb75bcbcbec6278ab00 Mon Sep 17 00:00:00 2001 From: Albin Date: Tue, 5 Nov 2019 18:08:21 +0100 Subject: =?UTF-8?q?Skapade=20lista=20=C3=B6ver=20approximationsdiff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kod/bilbana/yc4/main.m | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Kod/bilbana/yc4/main.m') diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index 793aefb..81df18b 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -32,6 +32,7 @@ car1.lap_times = []; car1.seg_times = []; car1.position = 0; car1.seg_len = [0.0 2.53 3.05 4.73 7.68 8.98 10.93 14.69 17.57]; +car1.approximation = []; %{ car2 = struct; @@ -112,7 +113,11 @@ while 1 end car1.segment = car1.segment + 1; car1.seg_tic = tic; + approximation = car1.position; % Måste vara innan nästa rad car1.position = car1.seg_len(car1.segment); + % Jämför get_position med indata + approximation = approximation - car1.position; + car1.approximation(car1.lap, car1.segment) = approximation; end if car1.new_lap == true if car1.lap == 0 -- cgit v1.2.1 From 25137d7c2b9d4987fbfd3e934acb84768d05f162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 5 Nov 2019 18:17:02 +0100 Subject: Tomrader --- Kod/bilbana/yc4/main.m | 2 -- 1 file changed, 2 deletions(-) (limited to 'Kod/bilbana/yc4/main.m') diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index 793aefb..e1d4736 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -98,7 +98,6 @@ while 1 %% CHECK LAP AND CHECKPOINT (CAR 1) if car1.running == true - %% CALC POSITION (CAR 1) if car1.lap > 1 last_seg_times1 = car1.seg_times(car1.lap - 1, 1:9); @@ -142,7 +141,6 @@ while 1 %% CHECK LAP AND CHECKPOINT (CAR 1) if car1.running == true - %% CALC POSITION (CAR 1) if car1.lap ~= 0 if car1.lap > 1 -- cgit v1.2.1 From 9605ca3f80511400489163d73fe013e5235e0332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 5 Nov 2019 18:22:41 +0100 Subject: 1->2 --- Kod/bilbana/yc4/main.m | 58 ++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) (limited to 'Kod/bilbana/yc4/main.m') diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index e1d4736..1c613a1 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -137,47 +137,45 @@ while 1 end %{ - TODO 1 -> 2 - - %% CHECK LAP AND CHECKPOINT (CAR 1) - if car1.running == true - %% CALC POSITION (CAR 1) - if car1.lap ~= 0 - if car1.lap > 1 - last_seg_times1 = car1.seg_times(car1.lap - 1, 1:9); - aprox_v = get_aprox_v(car1.segment, last_seg_times1); - car1.position = get_position(aprox_v, car1.position, delta_t); + %% CHECK LAP AND CHECKPOINT (CAR 2) + if car2.running == true + %% CALC POSITION (CAR 2) + if car2.lap ~= 0 + if car2.lap > 1 + last_seg_times1 = car2.seg_times(car2.lap - 1, 1:9); + aprox_v = get_aprox_v(car2.segment, last_seg_times2); %TODO ?? + car2.position = get_position(aprox_v, car2.position, delta_t); end end - if car1.new_check_point == true + if car2.new_check_point == true % beep; - if car1.lap ~= 0 - car1.seg_times(car1.lap, car1.segment) = toc(car1.seg_tic); + if car2.lap ~= 0 + car2.seg_times(car2.lap, car2.segment) = toc(car2.seg_tic); end - car1.segment = car1.segment + 1; - car1.seg_tic = tic; - car1.position = car1.seg_len(car1.segment); + car2.segment = car2.segment + 1; + car2.seg_tic = tic; + car2.position = car2.seg_len(car2.segment); end - if car1.new_lap == true - if car1.lap == 0 + if car2.new_lap == true + if car2.lap == 0 % dont save time for first lap - car1.segment = 1; - car1.lap = car1.lap + 1; - car1.seg_tic = tic; - car1.lap_tic = tic; + car2.segment = 1; + car2.lap = car2.lap + 1; + car2.seg_tic = tic; + car2.lap_tic = tic; continue; end beep; - car1.seg_times(car1.lap, car1.segment) = toc(car1.seg_tic); - car1.seg_tic = tic; - car1.lap_times(car1.lap) = toc(car1.lap_tic); - car1.lap_tic = tic; - car1.position = 0; + car2.seg_times(car2.lap, car2.segment) = toc(car2.seg_tic); + car2.seg_tic = tic; + car2.lap_times(car2.lap) = toc(car2.lap_tic); + car2.lap_tic = tic; + car2.position = 0; - display_data = {display_data, put_text(100, 32, 'L', strjoin({num2str(car1.lap), get_time_as_string(round(car1.lap_times(car1.lap) * 1000))}, ' '))}; + display_data = {display_data, put_text(100, 32, 'L', strjoin({num2str(car2.lap), get_time_as_string(round(car2.lap_times(car2.lap) * 1000))}, ' '))}; - car1.segment = 1; - car1.lap = car1.lap + 1; + car2.segment = 1; + car2.lap = car2.lap + 1; end end %} -- cgit v1.2.1 From 8ee1f181cf46e653dbfc99d4d2e41855df925447 Mon Sep 17 00:00:00 2001 From: Albin Date: Thu, 7 Nov 2019 12:58:31 +0100 Subject: lade till choose_position i main --- Kod/bilbana/yc4/main.m | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Kod/bilbana/yc4/main.m') diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index 81df18b..950a9f8 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -113,11 +113,18 @@ while 1 end car1.segment = car1.segment + 1; car1.seg_tic = tic; - approximation = car1.position; % Måste vara innan nästa rad - car1.position = car1.seg_len(car1.segment); + %approximation = car1.position; % Måste vara innan nästa rad + %car1.position = car1.seg_len(car1.segment); % Jämför get_position med indata - approximation = approximation - car1.position; - car1.approximation(car1.lap, car1.segment) = approximation; + %approximation = approximation - car1.position; + %car1.approximation(car1.lap, car1.segment) = approximation; + if car1.lap > 2 %Säkerhetsmarginal (Bör vara 1?) + x = choose_position(car1.position,car1.segment, 1); + car1.position = x(1); + car1.segment = car1.segment + x(2); + else + car1.position = car1.seg_len(car1.segment); + end end if car1.new_lap == true if car1.lap == 0 -- cgit v1.2.1 From fe544c6468464732bb64106f696bd6ffedade085 Mon Sep 17 00:00:00 2001 From: Albin Date: Thu, 7 Nov 2019 15:03:03 +0100 Subject: =?UTF-8?q?N=C3=A4stan=20fungerande=20primitiv=20hantering=20av=20?= =?UTF-8?q?missade=20givare?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kod/bilbana/yc4/main.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Kod/bilbana/yc4/main.m') diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index 950a9f8..0ff21c8 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -111,7 +111,9 @@ while 1 if car1.lap ~= 0 car1.seg_times(car1.lap, car1.segment) = toc(car1.seg_tic); end - car1.segment = car1.segment + 1; + if car1.segment < 9 + car1.segment = car1.segment + 1; + end car1.seg_tic = tic; %approximation = car1.position; % Måste vara innan nästa rad %car1.position = car1.seg_len(car1.segment); @@ -119,9 +121,10 @@ while 1 %approximation = approximation - car1.position; %car1.approximation(car1.lap, car1.segment) = approximation; if car1.lap > 2 %Säkerhetsmarginal (Bör vara 1?) - x = choose_position(car1.position,car1.segment, 1); - car1.position = x(1); - car1.segment = car1.segment + x(2); + disp(car1); + [car1.position,seg_plus] = choose_position(car1.position,car1.segment, 1); + %car1.position = x(1); + car1.segment = car1.segment + seg_plus; else car1.position = car1.seg_len(car1.segment); end -- cgit v1.2.1 From 11b47c710d1521f5b4c1193274f2b1e25b96645b Mon Sep 17 00:00:00 2001 From: aletu130 Date: Thu, 7 Nov 2019 15:47:00 +0100 Subject: =?UTF-8?q?n=C3=A5n=20sm=C3=A5=C3=A4ndring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kod/bilbana/yc4/main.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Kod/bilbana/yc4/main.m') diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index 0ff21c8..fca9819 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -122,7 +122,8 @@ while 1 %car1.approximation(car1.lap, car1.segment) = approximation; if car1.lap > 2 %Säkerhetsmarginal (Bör vara 1?) disp(car1); - [car1.position,seg_plus] = choose_position(car1.position,car1.segment, 1); + [car1.position, seg_plus] = ... + choose_position(car1.position,car1.segment, 1); %car1.position = x(1); car1.segment = car1.segment + seg_plus; else -- cgit v1.2.1 From fa7b4bf990ac16b58b06f9fbf1356a76f60d4c96 Mon Sep 17 00:00:00 2001 From: Albin Date: Thu, 7 Nov 2019 16:47:09 +0100 Subject: Nu funkar inget --- Kod/bilbana/yc4/main.m | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'Kod/bilbana/yc4/main.m') diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index fca9819..33b6944 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -107,30 +107,30 @@ while 1 car1.position = get_position(aprox_v, car1.position, t); end if car1.new_check_point == true - % beep; - if car1.lap ~= 0 - car1.seg_times(car1.lap, car1.segment) = toc(car1.seg_tic); - end - if car1.segment < 9 + if car1.new_lap == false + if car1.lap ~= 0 + car1.seg_times(car1.lap, car1.segment) = toc(car1.seg_tic); + end car1.segment = car1.segment + 1; - end - car1.seg_tic = tic; - %approximation = car1.position; % Måste vara innan nästa rad - %car1.position = car1.seg_len(car1.segment); - % Jämför get_position med indata - %approximation = approximation - car1.position; - %car1.approximation(car1.lap, car1.segment) = approximation; - if car1.lap > 2 %Säkerhetsmarginal (Bör vara 1?) - disp(car1); - [car1.position, seg_plus] = ... - choose_position(car1.position,car1.segment, 1); - %car1.position = x(1); - car1.segment = car1.segment + seg_plus; - else - car1.position = car1.seg_len(car1.segment); + car1.seg_tic = tic; + %approximation = car1.position; % Måste vara innan nästa rad + %car1.position = car1.seg_len(car1.segment); + % Jämför get_position med indata + %approximation = approximation - car1.position; + %car1.approximation(car1.lap, car1.segment) = approximation; + if car1.lap > 2 %Säkerhetsmarginal (Bör vara 1?) + disp(car1); + [car1.position, seg_plus] = ... + choose_position(car1.position,car1.segment, 1); + %car1.position = x(1); + car1.segment = car1.segment + seg_plus; + else + car1.position = car1.seg_len(car1.segment); + end end end if car1.new_lap == true + disp('----------NEW LAP!----------') if car1.lap == 0 % dont save time for first lap car1.segment = 1; -- cgit v1.2.1 From 84a1ee353c4d5de456254828542d4b604781db23 Mon Sep 17 00:00:00 2001 From: Albin Date: Fri, 8 Nov 2019 09:37:51 +0100 Subject: =?UTF-8?q?F=C3=B6rs=C3=B6kte=20fels=C3=B6ka=20och=20lade=20till?= =?UTF-8?q?=20timer=20f=C3=B6r=20eventuell=20missad=20givare?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kod/bilbana/yc4/main.m | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'Kod/bilbana/yc4/main.m') diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index 33b6944..2d450b1 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -33,6 +33,7 @@ car1.seg_times = []; car1.position = 0; car1.seg_len = [0.0 2.53 3.05 4.73 7.68 8.98 10.93 14.69 17.57]; car1.approximation = []; +car1.miss_time = uint64(0); %{ car2 = struct; @@ -105,32 +106,36 @@ while 1 last_seg_times1 = car1.seg_times(car1.lap - 1, 1:9); aprox_v = get_aprox_v(car1.segment, last_seg_times1); car1.position = get_position(aprox_v, car1.position, t); + if detect_missed( car1.position, car1.segment, 1) + disp('Miss?'); + disp(toc(car1.miss_time)); + if car1.miss_time == 0 + car1.miss_time = tic; + end + end end if car1.new_check_point == true - if car1.new_lap == false + if car1.new_lap == false % choose_position krachar vid nytt varv (seg 10) if car1.lap ~= 0 car1.seg_times(car1.lap, car1.segment) = toc(car1.seg_tic); end car1.segment = car1.segment + 1; car1.seg_tic = tic; - %approximation = car1.position; % Måste vara innan nästa rad - %car1.position = car1.seg_len(car1.segment); - % Jämför get_position med indata - %approximation = approximation - car1.position; - %car1.approximation(car1.lap, car1.segment) = approximation; - if car1.lap > 2 %Säkerhetsmarginal (Bör vara 1?) + if car1.lap > 2 % Säkerhetsmarginal (Bör vara 1?) disp(car1); [car1.position, seg_plus] = ... choose_position(car1.position,car1.segment, 1); %car1.position = x(1); car1.segment = car1.segment + seg_plus; + car1.miss_time = uint64(0); else car1.position = car1.seg_len(car1.segment); + car1.miss_time = uint64(0); end end end if car1.new_lap == true - disp('----------NEW LAP!----------') + disp('------------NEW LAP------------') if car1.lap == 0 % dont save time for first lap car1.segment = 1; -- cgit v1.2.1 From 2ad11b85f7d5d4a71477a02a1ca5ba8786652c35 Mon Sep 17 00:00:00 2001 From: Albin Date: Fri, 8 Nov 2019 11:59:19 +0100 Subject: Missade givare --- Kod/bilbana/yc4/main.m | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'Kod/bilbana/yc4/main.m') diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index 2d450b1..6612e4f 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -104,14 +104,15 @@ while 1 %% CALC POSITION (CAR 1) if car1.lap > 1 last_seg_times1 = car1.seg_times(car1.lap - 1, 1:9); - aprox_v = get_aprox_v(car1.segment, last_seg_times1); + aprox_v = get_aprox_v(car1.segment + detect_missed( car1.position, car1.segment, 1), car1.lap, car1.seg_times); car1.position = get_position(aprox_v, car1.position, t); if detect_missed( car1.position, car1.segment, 1) disp('Miss?'); - disp(toc(car1.miss_time)); - if car1.miss_time == 0 - car1.miss_time = tic; - end + + %disp(toc(car1.miss_time)); + %if car1.miss_time == 0 + % car1.miss_time = tic; + %end end end if car1.new_check_point == true @@ -123,14 +124,18 @@ while 1 car1.seg_tic = tic; if car1.lap > 2 % Säkerhetsmarginal (Bör vara 1?) disp(car1); - [car1.position, seg_plus] = ... - choose_position(car1.position,car1.segment, 1); - %car1.position = x(1); - car1.segment = car1.segment + seg_plus; - car1.miss_time = uint64(0); + [new_position, seg_plus] = ... + choose_position(car1.position, car1.segment, 1); + if seg_plus ~= 0 && car1.segment == 1 + disp('Hoppar över missad givare 1/2'); + else + car1.position = new_position; + car1.segment = car1.segment + seg_plus; + end + %car1.miss_time = uint64(0); else car1.position = car1.seg_len(car1.segment); - car1.miss_time = uint64(0); + %car1.miss_time = uint64(0); end end end -- cgit v1.2.1 From 5544888a5775b7ee21a1db9f540fb05702ecd10b Mon Sep 17 00:00:00 2001 From: Albin Date: Fri, 8 Nov 2019 11:59:38 +0100 Subject: Tvinga missade givare MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Med inställbar procent. Beep när givare tvingas hoppas över. --- Kod/bilbana/yc4/main.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Kod/bilbana/yc4/main.m') diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index 6612e4f..e2f223e 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -33,7 +33,8 @@ car1.seg_times = []; car1.position = 0; car1.seg_len = [0.0 2.53 3.05 4.73 7.68 8.98 10.93 14.69 17.57]; car1.approximation = []; -car1.miss_time = uint64(0); +car1.miss_probability = 0.1; +%car1.miss_time = uint64(0); %{ car2 = struct; @@ -91,6 +92,11 @@ while 1 %% READ if car1.running == true [car1.new_lap, car1.new_check_point, car1.time] = get_car_position(1); + if car1.new_check_point == true && rand < car1.miss_probability && car1.lap >= 4 + disp('Hoppar över givare'); + car1.new_check_point = false; + beep; + end end %{ if car2.running == true @@ -149,7 +155,7 @@ while 1 car1.lap_tic = tic; continue; end - beep; + % beep; car1.seg_times(car1.lap, car1.segment) = toc(car1.seg_tic); car1.seg_tic = tic; car1.lap_times(car1.lap) = toc(car1.lap_tic); @@ -267,7 +273,7 @@ while 1 highToc = t; %Om det nya v�rdet p� pausen �r h�gre �n den tidigare h�gsta s� sparas det som den h�gsta end if t > 0.1 - beep; + % beep; end break; end -- cgit v1.2.1