summaryrefslogtreecommitdiffstats
path: root/Kod/bilbana/studentFunctions/run_simple_example.m
blob: 45794f06929e50e19ab8c0ab7e799ee8d45b1010 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
%% ---------------- Do not touch ---------------- %
disp('Startar bilbanan. Avsluta med q')
hf=figure('position',[0 0 eps eps],'menubar','none');
% ----------------------------------------------- %
%% User input
track_number = 1;
car = init_car(track_number); 

%% Init race track
initialize_counters(car.track_number)
config_IOs
start_race(car.track_number)

%% Start cars
start_control = 29; % 29 works for the white castrol car marked with number 82
car = update_control(start_control, car);

%% Running loop
while 1
    
    % ---------------- Do not touch ---------------- %
    % Check if user has pressed q
    if strcmp(get(hf,'currentcharacter'),'q')
        close(hf)
        break
    end
    % force the event queue to flush
    figure(hf)
    drawnow
    % ---------------------------------------------- %
    
    car = car_controller(car);
    
    pause(0.1) % Pause 0.1 s
end

terminate(1)
terminate(2)

% run file to plot results
plot_results();