-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_terrain.m
61 lines (49 loc) · 1.45 KB
/
test_terrain.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
function test_terrain()
dists = [];
times = [];
realtimes = [];
rd = [];
ts = [];
delete(gcp('nocreate'))
parpool(3);
try
load test_data.mat
end
npar = 16;
tic
j = 0;
while true
ii = randperm(npar);
for i = 1:npar
j = mod(ii(i) - 1, 4) + 1;
k = ceil(ii(i)/8);
rd = [rd; j];
ts = [ts; 1 + (k-1)*3];
in(i) = Simulink.SimulationInput('biped_sim_interactive');
in(i) = in(i).setVariable('rollout_depth', rd(end));
in(i) = in(i).setVariable('transition_samples', ts(end));
in(i) = in(i).setVariable('env', Environment(generate_environment_gapsteps()));
in(i) = in(i).setModelParameter('ReturnWorkspaceOutputs', 'on');
in(i) = in(i).setModelParameter('StopTime', sprintf('%f', 100 / ts(end)));
end
out = parsim(in, 'ShowProgress', true);
toc
for i = 1:npar
if out(i).ErrorMessage
disp(out(i).ErrorMessage);
end
x = out(i).X.body.x.Data(end);
t = out(i).X.body.x.Time(end);
rt = out(i).SimulationMetadata.TimingInfo.ExecutionElapsedWallTime;
dists = [dists; x];
times = [times; t];
realtimes = [realtimes; rt];
end
fprintf('%d data points\n', size(dists, 1));
save test_data.mat dists times realtimes rd ts
% j = j + 1;
% if j > 50
% delete(gcp('nocreate'))
% j = 0;
% end
end