From 0e1a9de685c999fdd0e5252c741cef9d06b16451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 19 Nov 2019 16:22:33 +0100 Subject: NOT WORKING seg_len and track_len --- Kod/bilbana/yc4/choose_position.m | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Kod/bilbana/yc4/choose_position.m') diff --git a/Kod/bilbana/yc4/choose_position.m b/Kod/bilbana/yc4/choose_position.m index cd18f85..874f223 100644 --- a/Kod/bilbana/yc4/choose_position.m +++ b/Kod/bilbana/yc4/choose_position.m @@ -1,16 +1,14 @@ -function [new_position, seg_plus] = choose_position(position,segment, track) +function [new_position, seg_plus] = choose_position(position,segment, track, track_len) %CHOOSE_POSITION Välj vad position ska vara % Kör endast vid ny indata. Kollar om indatan är rimlig eller om någon % 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 = [0 2.53 3.05 4.73 7.68 8.98 10.93 14.96 17.57; - 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(i) - pos_c); if i == 1 near = [i, diff]; else @@ -22,7 +20,7 @@ end disp(near); %% Beräkning av passerad givare seg_plus = max(0, near(1) - segment) -new_position = track_len(track, segment + seg_plus); +new_position = track_len(segment + seg_plus); end -- cgit v1.2.1