diff options
Diffstat (limited to 'Kod/bilbana/yc4/choose_position.m')
| -rw-r--r-- | Kod/bilbana/yc4/choose_position.m | 8 |
1 files changed, 3 insertions, 5 deletions
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 |
