1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.hipparchus.filtering.kalman.extended;
19
20 import org.hipparchus.exception.MathRuntimeException;
21 import org.hipparchus.filtering.kalman.AbstractKalmanFilter;
22 import org.hipparchus.filtering.kalman.Measurement;
23 import org.hipparchus.filtering.kalman.ProcessEstimate;
24 import org.hipparchus.linear.MatrixDecomposer;
25 import org.hipparchus.linear.RealMatrix;
26 import org.hipparchus.linear.RealVector;
27
28
29
30
31
32
33 public class ExtendedKalmanFilter<T extends Measurement> extends AbstractKalmanFilter<T> {
34
35
36 private final NonLinearProcess<T> process;
37
38
39
40
41
42
43 public ExtendedKalmanFilter(final MatrixDecomposer decomposer,
44 final NonLinearProcess<T> process,
45 final ProcessEstimate initialState) {
46 super(decomposer, initialState);
47 this.process = process;
48 }
49
50
51 @Override
52 public ProcessEstimate estimationStep(final T measurement)
53 throws MathRuntimeException {
54
55
56 final NonLinearEvolution evolution = process.getEvolution(getCorrected().getTime(),
57 getCorrected().getState(),
58 measurement);
59
60 final RealMatrix stm = evolution.getStateTransitionMatrix();
61 predict(evolution.getCurrentTime(), evolution.getCurrentState(),
62 stm, evolution.getProcessNoiseMatrix());
63
64
65 final RealMatrix h = evolution.getMeasurementJacobian();
66 final RealMatrix s = computeInnovationCovarianceMatrix(measurement.getCovariance(), h);
67 final RealVector innovation = (h == null) ? null : process.getInnovation(measurement, evolution, s);
68 correct(measurement, stm, innovation, h, s);
69 return getCorrected();
70
71 }
72
73 }