forked from nickgkan/neuro-fuzzy-vehicle-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
control_vehicle.m
80 lines (68 loc) · 1.98 KB
/
control_vehicle.m
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
clear all
clc
close all
addpath 'files'
addpath 'src'
%% GLOBAL CONFIGURATION
global map;
global map_size;
map_size = 400;
maps = standard_plans();
max_iterations = 60;
%% FUZZY SYSTEMS
fis_files = {'fuzzy_system_5_rules.fis', 'fuzzy_system_3_rules.fis'};
for f = 1:1:2
fis_file = readfis(fis_files{f});
for map_id = [1 2 3 5 6]
if (map_id == 6) && (f == 2)
break;
end
create_map(maps{map_id});
figure('name', sprintf('Plan %d of version %d', map_id, f))
imshow(map);
[~] = approach_goal(fis_file, max_iterations, f == 1);
if f == 1 && map_id == 1
frame = getframe(gcf);
img = frame2im(frame);
[img, cmap] = rgb2ind(img, 256);
if map_id == 1
imwrite(...
img, cmap, 'animation.gif', 'gif',...
'LoopCount', Inf, 'DelayTime', 0.03...
);
else
imwrite(...
img, cmap, 'animation.gif', 'gif',...
'WriteMode', 'append', 'DelayTime', 0.03...
);
end
end
end
end
% Random maps
for f = 1:1:2
fis_file = readfis(fis_files{f});
for map_id=1:1:3
create_map(plangenerator(11));
figure('name', sprintf('Random plan %d of version %d', map_id, f))
imshow(map);
[~] = approach_goal(fis_file, max_iterations, false);
end
end
%% NEURO-FUZZY SYSTEMS
fis_files = {'neurofuzzy_system_5_rules.fis', 'neurofuzzy_system_3_rules.fis'};
N = 10;
for f=1:1:2
close all
fis_file = readfis(fis_files{f});
for map_id=1:1:N
if map_id < 8
create_map(maps{map_id});
else
create_map(plangenerator(11));
end
figure('name', sprintf('Plan %d of version %d', map_id, f))
imshow(map);
[~] = approach_goal(fis_file, max_iterations, false);
end
end