-
Notifications
You must be signed in to change notification settings - Fork 1
/
precalculateParams.m
80 lines (80 loc) · 4.42 KB
/
precalculateParams.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
function precalculatedParams = precalculateParams(scenarioParam, filterParam)
% @author Florian Pfaff pfaff@kit.edu
% @date 2016-2023
% V3.1
arguments (Input)
scenarioParam (1,1) struct
filterParam (1,1) struct
end
arguments (Output)
precalculatedParams struct
end
precalculatedParams = struct();
switch filterParam.name
case 'twn'
if ~scenarioParam.useLikelihood && ~isa(scenarioParam.measNoise, 'ToroidalWNDistribution')
s = scenarioParam.measNoise.sample(100000);
precalculatedParams.measNoiseForFilter = ToroidalWNDistribution.mleNumerical(s);
end
case 'htgf'
if scenarioParam.useTransition
precalculatedParams.fTrans_tdxtd = ...
TdCondTdGridDistribution.fromFunction(scenarioParam.fTrans, filterParam.parameter, true, 'CartesianProduct', 2*scenarioParam.initialPrior.dim);
end
case 'iff'
filtertmp = HypertoroidalFourierFilter(repmat(filterParam.parameter, [1, scenarioParam.initialPrior.dim]), 'identity');
if scenarioParam.useTransition
precalculatedParams.hfdTrans = ...
filtertmp.getfTransAsHfd(scenarioParam.genNextStateWithoutNoiseFourier, scenarioParam.sysNoise);
end
case 'sqff'
filtertmp = HypertoroidalFourierFilter(repmat(filterParam.parameter, [1, scenarioParam.initialPrior.dim]), 'sqrt');
if scenarioParam.useTransition
precalculatedParams.hfdTrans = ...
filtertmp.getfTransAsHfd(scenarioParam.genNextStateWithoutNoiseFourier, scenarioParam.sysNoise);
end
case 'sgf'
if scenarioParam.useTransition
precalculatedParams.fTrans_sdxsd = ...
S2CondS2GridDistribution.fromFunction(scenarioParam.fTrans, filterParam.parameter, true, 'eq_point_set');
end
case 'hgf'
if scenarioParam.useTransition
precalculatedParams.fTrans_sdxsd = ...
SdCondSdGridDistribution.fromFunction(scenarioParam.fTrans, filterParam.parameter, true, 'eq_point_set', 2*scenarioParam.initialPrior.dim);
end
case 'hgfSymm'
if scenarioParam.useTransition
precalculatedParams.fTrans_sdxsd = ...
SdCondSdGridDistribution.fromFunction(scenarioParam.fTrans, filterParam.parameter, true, 'eq_point_set_symm', 2*scenarioParam.initialPrior.dim);
end
case 'hhgf'
precalculatedParams.priorForFilter = HyperhemisphericalGridDistribution.fromDistribution(scenarioParam.initialPrior, filterParam.parameter, 'eq_point_set_symm');
if scenarioParam.useTransition
precalculatedParams.fTrans_sdhalfxsdhalf = ...
SdHalfCondSdHalfGridDistribution.fromFunction( ...
scenarioParam.fTrans, filterParam.parameter, true, 'eq_point_set_symm', 2*scenarioParam.initialPrior.dim);
end
case 's3f'
switch scenarioParam.manifoldType
case 'se2'
precalculatedParams.priorForFilter = SE2StateSpaceSubdivisionGaussianDistribution( ...
FIGDistribution.fromDistribution(scenarioParam.initialPriorPeriodic, filterParam.parameter), ...
repmat(scenarioParam.initialPriorLinear, [filterParam.parameter, 1]));
precalculatedParams.condPeriodic = ...
TdCondTdGridDistribution.fromFunction(@(xkk, xk)scenarioParam.sysNoisePeriodic.pdf(xkk - xk), filterParam.parameter, false, 'CartesianProd', 2);
case 'se3'
precalculatedParams.priorForFilter = SE3StateSpaceSubdivisionGaussianDistribution( ...
HyperhemisphericalGridDistribution.fromDistribution(scenarioParam.initialPriorPeriodic, filterParam.parameter), ...
repmat(scenarioParam.initialPriorLinear, [filterParam.parameter, 1]));
precalculatedParams.condPeriodic = ...
SdHalfCondSdHalfGridDistribution.fromFunction(@(xkk, xk)cell2mat(arrayfun(@(i){scenarioParam.sysNoisePeriodic.shift(xk(:,i)).pdf(xkk)},1:size(xk,2))), filterParam.parameter, true, 'eq_point_set_symm', 8);
otherwise
error('Manifold type not supported.')
end
case 'se2bf'
noSamplesForFitting = 100000;
precalculatedParams.priorForFilter = SE2BinghamDistribution.fit(scenarioParam.initialPrior.sample(noSamplesForFitting));
precalculatedParams.sysNoiseForFilter = SE2BinghamDistribution.fit(scenarioParam.sysNoise.sample(noSamplesForFitting));
end
end