diff options
| author | matuv053 <matuv053@student.liu.se> | 2019-11-19 16:55:06 +0100 |
|---|---|---|
| committer | matuv053 <matuv053@student.liu.se> | 2019-11-19 16:55:06 +0100 |
| commit | 6869c4440735e6b85181a9cdafbbd808e640661c (patch) | |
| tree | ba4f94c42971083b9353545d6673212bdf26800f /Kod/bilbana/yc4/choose_position.m | |
| parent | 598dfd1872739cf6dcdb8b925fbf2c2e0f2a5ea0 (diff) | |
| parent | 213226a8618cd2b87dd8bb5a05d7339e3cb3054a (diff) | |
| download | tfyy51-6869c4440735e6b85181a9cdafbbd808e640661c.tar.gz | |
Merge branch 'parameter-track-length'
Diffstat (limited to 'Kod/bilbana/yc4/choose_position.m')
| -rw-r--r-- | Kod/bilbana/yc4/choose_position.m | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Kod/bilbana/yc4/choose_position.m b/Kod/bilbana/yc4/choose_position.m index cd18f85..5d2dee3 100644 --- a/Kod/bilbana/yc4/choose_position.m +++ b/Kod/bilbana/yc4/choose_position.m @@ -1,16 +1,17 @@ -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; + +track_len = track_len(1: length(track_len) - 1); + %% 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 +23,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 |
