blob: 726fe8296c68ba6d6f82bea01bd0d57b67166568 (
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
42
43
44
45
46
47
48
49
50
51
52
53
|
disp('Startar bilbanan. Avsluta med q.')
hf=figure('position',[0 0 eps eps],'menubar','none');
initialize_counters(1)
initialize_counters(2)
start_race(1)
start_race(2)
config_IOs
car1 = struct;
car2 = struct;
while 1
%% PRE-LOOP
if strcmp(get(hf,'currentcharacter'),'q')
close(hf)
break
end
figure(hf)
drawnow
%% READ
[car1.new_lap, car1.new_check_point, car1.time] = get_car_position(1);
[car2.new_lap, car2.new_check_point, car2.time] = get_car_position(2);
if car1.new_lap || car1.new_check_point == true || car2.new_lap == true || car2.new_check_point == true
disp('###')
end
if car1.new_check_point
beep;
disp('car 1 cp')
end
if car2.new_check_point
beep;
disp('car 2 cp')
end
if car1.new_lap
beep;
disp('car 1 lap')
end
if car2.new_lap
beep;
disp('car 2 lap')
end
pause(0.1)
end
%%
terminate(1)
terminate(2)
|