1 /* Copyright 2002-2025 CS GROUP
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.orekit.estimation.sequential;
18
19 import java.util.Arrays;
20 import java.util.Collections;
21 import java.util.List;
22
23 import org.hipparchus.filtering.kalman.KalmanFilter;
24 import org.hipparchus.filtering.kalman.unscented.UnscentedKalmanFilter;
25 import org.hipparchus.linear.MatrixDecomposer;
26 import org.hipparchus.util.UnscentedTransformProvider;
27 import org.orekit.estimation.measurements.ObservedMeasurement;
28 import org.orekit.propagation.conversion.DSSTPropagatorBuilder;
29 import org.orekit.propagation.semianalytical.dsst.DSSTPropagator;
30 import org.orekit.utils.ParameterDriver;
31 import org.orekit.utils.ParameterDriversList;
32
33 /**
34 * Implementation of an Unscented Semi-analytical Kalman filter (USKF) to perform orbit determination.
35 * <p>
36 * The filter uses a {@link DSSTPropagatorBuilder}.
37 * </p>
38 * <p>
39 * The estimated parameters are driven by {@link ParameterDriver} objects. They are of 3 different types:<ol>
40 * <li><b>Orbital parameters</b>:The position and velocity of the spacecraft, or, more generally, its orbit.<br>
41 * These parameters are retrieved from the reference trajectory propagator builder when the filter is initialized.</li>
42 * <li><b>Propagation parameters</b>: Some parameters modeling physical processes (SRP or drag coefficients etc...).<br>
43 * They are also retrieved from the propagator builder during the initialization phase.</li>
44 * <li><b>Measurements parameters</b>: Parameters related to measurements (station biases, positions etc...).<br>
45 * They are passed down to the filter in its constructor.</li>
46 * </ol>
47 * <p>
48 * The Kalman filter implementation used is provided by the underlying mathematical library Hipparchus.
49 * All the variables seen by Hipparchus (states, covariances...) are normalized
50 * using a specific scale for each estimated parameters or standard deviation noise for each measurement components.
51 * </p>
52 *
53 * <p>An {@link SemiAnalyticalUnscentedKalmanEstimator} object is built using the {@link SemiAnalyticalUnscentedKalmanEstimatorBuilder#build() build}
54 * method of a {@link SemiAnalyticalUnscentedKalmanEstimatorBuilder}.</p>
55 *
56 * @author Gaƫtan Pierre
57 * @author Bryan Cazabonne
58 * @since 11.3
59 */
60 public class SemiAnalyticalUnscentedKalmanEstimator extends AbstractKalmanEstimator {
61
62 /** Unscented Kalman filter process model. */
63 private final SemiAnalyticalUnscentedKalmanModel processModel;
64
65 /** Filter. */
66 private final UnscentedKalmanFilter<MeasurementDecorator> filter;
67
68 /** Dummy scale. */
69 private final double[] scale;
70
71 /** Unscented Kalman filter estimator constructor (package private).
72 * @param decomposer decomposer to use for the correction phase
73 * @param propagatorBuilder propagator builder used to evaluate the orbit.
74 * @param processNoiseMatricesProvider provider for process noise matrix
75 * @param estimatedMeasurementParameters measurement parameters to estimate
76 * @param measurementProcessNoiseMatrix provider for measurement process noise matrix
77 * @param utProvider provider for the unscented transform
78 */
79 SemiAnalyticalUnscentedKalmanEstimator(final MatrixDecomposer decomposer,
80 final DSSTPropagatorBuilder propagatorBuilder,
81 final CovarianceMatrixProvider processNoiseMatricesProvider,
82 final ParameterDriversList estimatedMeasurementParameters,
83 final CovarianceMatrixProvider measurementProcessNoiseMatrix,
84 final UnscentedTransformProvider utProvider) {
85 super(decomposer, Collections.singletonList(propagatorBuilder));
86 // Build the process model and measurement model
87 this.processModel = new SemiAnalyticalUnscentedKalmanModel(propagatorBuilder, processNoiseMatricesProvider,
88 estimatedMeasurementParameters, measurementProcessNoiseMatrix);
89
90 // Unscented Kalman Filter of Hipparchus
91 this.filter = new UnscentedKalmanFilter<>(decomposer, processModel, processModel.getEstimate(), utProvider);
92
93 // Fill dummy scale with 1s
94 final int dim = processModel.getEstimate().getState().getDimension();
95 this.scale = new double[dim];
96 Arrays.fill(scale, 1.0);
97
98 }
99
100 /** {@inheritDoc}. */
101 @Override
102 protected KalmanEstimation getKalmanEstimation() {
103 return processModel;
104 }
105
106 /** {@inheritDoc}. */
107 @Override
108 protected KalmanFilter<MeasurementDecorator> getKalmanFilter() {
109 return filter;
110 }
111
112 /** {@inheritDoc}. */
113 @Override
114 protected double[] getScale() {
115 return scale;
116 }
117
118 /** {@inheritDoc}. */
119 @Override
120 public void setObserver(final KalmanObserver observer) {
121 processModel.setObserver(observer);
122 observer.init(getKalmanEstimation());
123 }
124
125 /** {@inheritDoc}. */
126 @Override
127 public KalmanObserver getObserver() {
128 return processModel.getObserver();
129 }
130
131 /** Process a single measurement.
132 * <p>
133 * Update the filter with the new measurement by calling the estimate method.
134 * </p>
135 * @param observedMeasurements the list of measurements to process
136 * @return estimated propagators
137 */
138 public DSSTPropagator processMeasurements(final List<ObservedMeasurement<?>> observedMeasurements) {
139 return processModel.processMeasurements(observedMeasurements, filter);
140 }
141
142 }
143