From e66efbbe8df2dd4e7de0a1e9bd129cf92e00f92f Mon Sep 17 00:00:00 2001 From: vikle012 Date: Wed, 11 Sep 2019 13:57:14 +0200 Subject: Initializes repo. --- Kod/bilbana/studentFunctions/update_position.m | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Kod/bilbana/studentFunctions/update_position.m (limited to 'Kod/bilbana/studentFunctions/update_position.m') diff --git a/Kod/bilbana/studentFunctions/update_position.m b/Kod/bilbana/studentFunctions/update_position.m new file mode 100644 index 0000000..dfca55f --- /dev/null +++ b/Kod/bilbana/studentFunctions/update_position.m @@ -0,0 +1,39 @@ +function [car, gateway_passed] = update_position(car_in) + +car = car_in; + +[lap_car, chk_pnt, time] = get_car_position(car.track_number); + +if lap_car == true + % New lap + + % Update position on track + car.position = 1; + + % Add lap to lap counter + car.lap = car.lap + 1; + + % Update gw passed + gateway_passed = true; + + % Make sound + beep; + +elseif chk_pnt == true && car.position ~= 0 + % CP passed + + % Update position + car.position = car.position + 1; + + % update gw passed + gateway_passed = true; + + % Make sound + beep; + +else + gateway_passed = false; + +end + +end \ No newline at end of file -- cgit v1.2.1