summaryrefslogtreecommitdiffstats
path: root/Kod/bilbana/yc4/choose_position.m
diff options
context:
space:
mode:
authorGustav Sörnäs <gusso230@student.liu.se>2019-11-12 15:58:24 +0100
committerGustav Sörnäs <gusso230@student.liu.se>2019-11-12 15:58:24 +0100
commitaa75fc7efb7faa767d28936657a0e4a011a94a06 (patch)
treeb591ccb1800c9c737ed6e50a6bc0d6d1b4504286 /Kod/bilbana/yc4/choose_position.m
parent7965f0663abff4d914d640df46184a9e40632946 (diff)
downloadtfyy51-aa75fc7efb7faa767d28936657a0e4a011a94a06.tar.gz
Fungerande merge
Diffstat (limited to 'Kod/bilbana/yc4/choose_position.m')
-rw-r--r--Kod/bilbana/yc4/choose_position.m16
1 files changed, 8 insertions, 8 deletions
diff --git a/Kod/bilbana/yc4/choose_position.m b/Kod/bilbana/yc4/choose_position.m
index 39be6e4..d6db2ca 100644
--- a/Kod/bilbana/yc4/choose_position.m
+++ b/Kod/bilbana/yc4/choose_position.m
@@ -5,19 +5,19 @@ function [new_position, seg_plus] = choose_position(position,segment, track)
% passerades. seg_plus anger om och med hur mycket car.segment bör
% justeras för att kompensera efter missad givare.
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];
+ 0 2.53 3.05 4.92 7.60 8.84 10.65 14.68 17.76];
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];
+ 0 2.53 3.05 4.92 7.60 8.84 10.65 14.68 17.76];
pos_c = position;
%% Vilken givare ligger närmast pos_c?
near = [];
for i = 1:length(track_len)
- diff = abs(track_len(track,i)-pos_c);
+ diff = abs(track_len(track, i) - pos_c);
if i == 1
- near = [i,diff];
+ near = [i, diff];
else
if diff < near(2)
- near = [i,diff];
+ near = [i, diff];
end
end
end
@@ -29,10 +29,10 @@ if near(1) == segment
disp('In right segment');
else
if near(2) < 0.7 % Behöver bli smartare. Typ jämföra andra normal miss med denna miss
- seg_plus = max(0, near(1) - segment)
- new_position = set_pos( track, segment + seg_plus);
+ seg_plus = max(0, near(1) - segment);
+ new_position = set_pos(track, segment + seg_plus);
else
- new_position = set_pos( track, segment); % ineff borde kombineras
+ new_position = set_pos(track, segment); % ineff borde kombineras
seg_plus = 0;
disp('In right segment ich');
end