summaryrefslogtreecommitdiffstats
path: root/Kod/bilbana/yc4
diff options
context:
space:
mode:
authorAlbin <albwa833@student.liu.se>2019-11-07 16:47:09 +0100
committerAlbin <albwa833@student.liu.se>2019-11-07 16:47:09 +0100
commitfa7b4bf990ac16b58b06f9fbf1356a76f60d4c96 (patch)
tree7692585f0061430fbec81e2e04ec052723a349de /Kod/bilbana/yc4
parent11b47c710d1521f5b4c1193274f2b1e25b96645b (diff)
downloadtfyy51-fa7b4bf990ac16b58b06f9fbf1356a76f60d4c96.tar.gz
Nu funkar inget
Diffstat (limited to 'Kod/bilbana/yc4')
-rw-r--r--Kod/bilbana/yc4/choose_position.m3
-rw-r--r--Kod/bilbana/yc4/main.m40
2 files changed, 21 insertions, 22 deletions
diff --git a/Kod/bilbana/yc4/choose_position.m b/Kod/bilbana/yc4/choose_position.m
index 035d6e3..312990c 100644
--- a/Kod/bilbana/yc4/choose_position.m
+++ b/Kod/bilbana/yc4/choose_position.m
@@ -4,12 +4,11 @@ function [new_position, seg_plus] = choose_position(position,segment, track)
% givare missats. Sedan väljs position efter vilken givare det var som
% passerades. seg_plus anger om och med hur mycket car.segment bör
% justeras för att kompensera efter missad givare.
-track_len = [19.60 2.53 3.05 4.73 7.68 8.98 10.93 14.96 17.57;
+track_len = [0 2.53 3.05 4.73 7.68 8.98 10.93 14.96 17.57;
0 0 0 0 0 0 0 0 0];
set_pos = [0 2.53 3.05 4.73 7.68 8.98 10.93 14.96 17.57;
0 0 0 0 0 0 0 0 0];
pos_c = position;
-pos_i = track_len( track, segment);
%% Vilken givare ligger närmast pos_c?
near = [];
for i = 1:length(track_len)
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;