UnscentedKalmanEstimator.java

  1. /* Copyright 2002-2022 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.List;

  19. import org.hipparchus.filtering.kalman.ProcessEstimate;
  20. import org.hipparchus.filtering.kalman.unscented.UnscentedKalmanFilter;
  21. import org.hipparchus.linear.MatrixDecomposer;
  22. import org.hipparchus.util.UnscentedTransformProvider;
  23. import org.orekit.estimation.measurements.ObservedMeasurement;
  24. import org.orekit.propagation.Propagator;
  25. import org.orekit.propagation.conversion.NumericalPropagatorBuilder;
  26. import org.orekit.time.AbsoluteDate;
  27. import org.orekit.utils.ParameterDriver;
  28. import org.orekit.utils.ParameterDriversList;

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

  58.     /** Reference date. */
  59.     private final AbsoluteDate referenceDate;

  60.     /** Unscented Kalman filter process model. */
  61.     private final UnscentedKalmanModel processModel;

  62.     /** Filter. */
  63.     private final UnscentedKalmanFilter<MeasurementDecorator> filter;

  64.     /** Observer to retrieve current estimation info. */
  65.     private KalmanObserver observer;

  66.     /** Unscented Kalman filter estimator constructor (package private).
  67.      * @param decomposer decomposer to use for the correction phase
  68.      * @param propagatorBuilders propagators builders used to evaluate the orbit.
  69.      * @param processNoiseMatricesProviders providers for process noise matrices
  70.      * @param estimatedMeasurementParameters measurement parameters to estimate
  71.      * @param measurementProcessNoiseMatrix provider for measurement process noise matrix
  72.      * @param utProvider provider for the unscented transform.
  73.      */
  74.     UnscentedKalmanEstimator(final MatrixDecomposer decomposer,
  75.                              final List<NumericalPropagatorBuilder> propagatorBuilders,
  76.                              final List<CovarianceMatrixProvider> processNoiseMatricesProviders,
  77.                              final ParameterDriversList estimatedMeasurementParameters,
  78.                              final CovarianceMatrixProvider measurementProcessNoiseMatrix,
  79.                              final UnscentedTransformProvider utProvider) {
  80.         super(propagatorBuilders);
  81.         this.referenceDate = propagatorBuilders.get(0).getInitialOrbitDate();
  82.         this.observer      = null;

  83.         // Build the process model and measurement model
  84.         this.processModel = new UnscentedKalmanModel(propagatorBuilders, processNoiseMatricesProviders,
  85.                                                      estimatedMeasurementParameters, measurementProcessNoiseMatrix);

  86.         this.filter = new UnscentedKalmanFilter<>(decomposer, processModel, processModel.getEstimate(), utProvider);

  87.     }

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

  93.     /** Set the observer.
  94.      * @param observer the observer
  95.      */
  96.     public void setObserver(final KalmanObserver observer) {
  97.         this.observer = observer;
  98.     }

  99.     /** Process a single measurement.
  100.      * <p>
  101.      * Update the filter with the new measurement by calling the estimate method.
  102.      * </p>
  103.      * @param observedMeasurement the measurement to process
  104.      * @return estimated propagator
  105.      */
  106.     public Propagator[] estimationStep(final ObservedMeasurement<?> observedMeasurement) {
  107.         final ProcessEstimate estimate = filter.estimationStep(KalmanEstimatorUtil.decorateUnscented(observedMeasurement, referenceDate));
  108.         processModel.finalizeEstimation(observedMeasurement, estimate);
  109.         if (observer != null) {
  110.             observer.evaluationPerformed(processModel);
  111.         }
  112.         return processModel.getEstimatedPropagators();
  113.     }

  114.     /** Process several measurements.
  115.      * @param observedMeasurements the measurements to process in <em>chronologically sorted</em> order
  116.      * @return estimated propagator
  117.      */
  118.     public Propagator[] processMeasurements(final Iterable<ObservedMeasurement<?>> observedMeasurements) {
  119.         Propagator[] propagators = null;
  120.         for (ObservedMeasurement<?> observedMeasurement : observedMeasurements) {
  121.             propagators = estimationStep(observedMeasurement);
  122.         }
  123.         return propagators;
  124.     }

  125. }