SemiAnalyticalUnscentedKalmanEstimator.java

  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. import java.util.Arrays;
  19. import java.util.Collections;
  20. import java.util.List;

  21. import org.hipparchus.filtering.kalman.KalmanFilter;
  22. import org.hipparchus.filtering.kalman.unscented.UnscentedKalmanFilter;
  23. import org.hipparchus.linear.MatrixDecomposer;
  24. import org.hipparchus.util.UnscentedTransformProvider;
  25. import org.orekit.estimation.measurements.ObservedMeasurement;
  26. import org.orekit.propagation.conversion.DSSTPropagatorBuilder;
  27. import org.orekit.propagation.semianalytical.dsst.DSSTPropagator;
  28. import org.orekit.utils.ParameterDriver;
  29. import org.orekit.utils.ParameterDriversList;

  30. /**
  31.  * Implementation of an Unscented Semi-analytical Kalman filter (USKF) to perform orbit determination.
  32.  * <p>
  33.  * The filter uses a {@link DSSTPropagatorBuilder}.
  34.  * </p>
  35.  * <p>
  36.  * The estimated parameters are driven by {@link ParameterDriver} objects. They are of 3 different types:<ol>
  37.  *   <li><b>Orbital parameters</b>:The position and velocity of the spacecraft, or, more generally, its orbit.<br>
  38.  *       These parameters are retrieved from the reference trajectory propagator builder when the filter is initialized.</li>
  39.  *   <li><b>Propagation parameters</b>: Some parameters modeling physical processes (SRP or drag coefficients etc...).<br>
  40.  *       They are also retrieved from the propagator builder during the initialization phase.</li>
  41.  *   <li><b>Measurements parameters</b>: Parameters related to measurements (station biases, positions etc...).<br>
  42.  *       They are passed down to the filter in its constructor.</li>
  43.  * </ol>
  44.  * <p>
  45.  * The Kalman filter implementation used is provided by the underlying mathematical library Hipparchus.
  46.  * All the variables seen by Hipparchus (states, covariances...) are normalized
  47.  * using a specific scale for each estimated parameters or standard deviation noise for each measurement components.
  48.  * </p>
  49.  *
  50.  * <p>An {@link SemiAnalyticalUnscentedKalmanEstimator} object is built using the {@link SemiAnalyticalUnscentedKalmanEstimatorBuilder#build() build}
  51.  * method of a {@link SemiAnalyticalUnscentedKalmanEstimatorBuilder}.</p>
  52.  *
  53.  * @author GaĆ«tan Pierre
  54.  * @author Bryan Cazabonne
  55.  * @since 11.3
  56.  */
  57. public class SemiAnalyticalUnscentedKalmanEstimator extends AbstractKalmanEstimator {

  58.     /** Unscented Kalman filter process model. */
  59.     private final SemiAnalyticalUnscentedKalmanModel processModel;

  60.     /** Filter. */
  61.     private final UnscentedKalmanFilter<MeasurementDecorator> filter;

  62.     /** Dummy scale. */
  63.     private final double[] scale;

  64.     /** Unscented Kalman filter estimator constructor (package private).
  65.      * @param decomposer decomposer to use for the correction phase
  66.      * @param propagatorBuilder propagator builder used to evaluate the orbit.
  67.      * @param processNoiseMatricesProvider provider for process noise matrix
  68.      * @param estimatedMeasurementParameters measurement parameters to estimate
  69.      * @param measurementProcessNoiseMatrix provider for measurement process noise matrix
  70.      * @param utProvider provider for the unscented transform
  71.      */
  72.     SemiAnalyticalUnscentedKalmanEstimator(final MatrixDecomposer decomposer,
  73.                                            final DSSTPropagatorBuilder propagatorBuilder,
  74.                                            final CovarianceMatrixProvider processNoiseMatricesProvider,
  75.                                            final ParameterDriversList estimatedMeasurementParameters,
  76.                                            final CovarianceMatrixProvider measurementProcessNoiseMatrix,
  77.                                            final UnscentedTransformProvider utProvider) {
  78.         super(decomposer, Collections.singletonList(propagatorBuilder));
  79.         // Build the process model and measurement model
  80.         this.processModel = new SemiAnalyticalUnscentedKalmanModel(propagatorBuilder, processNoiseMatricesProvider,
  81.                                                                    estimatedMeasurementParameters, measurementProcessNoiseMatrix);

  82.         // Unscented Kalman Filter of Hipparchus
  83.         this.filter = new UnscentedKalmanFilter<>(decomposer, processModel, processModel.getEstimate(), utProvider);

  84.         // Fill dummy scale with 1s
  85.         final int dim = processModel.getEstimate().getState().getDimension();
  86.         this.scale = new double[dim];
  87.         Arrays.fill(scale, 1.0);

  88.     }

  89.     /** {@inheritDoc}. */
  90.     @Override
  91.     protected KalmanEstimation getKalmanEstimation() {
  92.         return processModel;
  93.     }

  94.     /** {@inheritDoc}. */
  95.     @Override
  96.     protected KalmanFilter<MeasurementDecorator> getKalmanFilter() {
  97.         return filter;
  98.     }

  99.     /** {@inheritDoc}. */
  100.     @Override
  101.     protected double[] getScale() {
  102.         return scale;
  103.     }

  104.     /** {@inheritDoc}. */
  105.     @Override
  106.     public void setObserver(final KalmanObserver observer) {
  107.         processModel.setObserver(observer);
  108.         observer.init(getKalmanEstimation());
  109.     }

  110.     /** {@inheritDoc}. */
  111.     @Override
  112.     public KalmanObserver getObserver() {
  113.         return processModel.getObserver();
  114.     }

  115.     /** Process a single measurement.
  116.      * <p>
  117.      * Update the filter with the new measurement by calling the estimate method.
  118.      * </p>
  119.      * @param observedMeasurements the list of measurements to process
  120.      * @return estimated propagators
  121.      */
  122.     public DSSTPropagator processMeasurements(final List<ObservedMeasurement<?>> observedMeasurements) {
  123.         return processModel.processMeasurements(observedMeasurements, filter);
  124.     }

  125. }