AbstractKalmanEstimator.java

  1. /* Copyright 2002-2024 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.linear.RealMatrix;
  20. import org.hipparchus.linear.RealVector;
  21. import org.orekit.propagation.conversion.PropagatorBuilder;
  22. import org.orekit.time.AbsoluteDate;
  23. import org.orekit.utils.ParameterDriver;
  24. import org.orekit.utils.ParameterDriversList;
  25. import org.orekit.utils.ParameterDriversList.DelegatingDriver;

  26. /**
  27.  * Base class for Kalman estimators.
  28.  * @author Romain Gerbaud
  29.  * @author Maxime Journot
  30.  * @author Luc Maisonobe
  31.  * @since 11.3
  32.  */
  33. public abstract class AbstractKalmanEstimator {

  34.     /** List of propagator builder. */
  35.     private final List<? extends PropagatorBuilder> builders;

  36.     /**
  37.      * Constructor.
  38.      * @param builders list of propagator builders
  39.      */
  40.     protected AbstractKalmanEstimator(final List<? extends PropagatorBuilder> builders) {
  41.         this.builders = builders;
  42.     }

  43.     /** Get the orbital parameters supported by this estimator.
  44.      * <p>
  45.      * If there are more than one propagator builder, then the names
  46.      * of the drivers have an index marker in square brackets appended
  47.      * to them in order to distinguish the various orbits. So for example
  48.      * with one builder generating Keplerian orbits the names would be
  49.      * simply "a", "e", "i"... but if there are several builders the
  50.      * names would be "a[0]", "e[0]", "i[0]"..."a[1]", "e[1]", "i[1]"...
  51.      * </p>
  52.      * @param estimatedOnly if true, only estimated parameters are returned
  53.      * @return orbital parameters supported by this estimator
  54.      */
  55.     public ParameterDriversList getOrbitalParametersDrivers(final boolean estimatedOnly) {

  56.         final ParameterDriversList estimated = new ParameterDriversList();
  57.         for (int i = 0; i < builders.size(); ++i) {
  58.             final String suffix = builders.size() > 1 ? "[" + i + "]" : null;
  59.             for (final ParameterDriver driver : builders.get(i).getOrbitalParametersDrivers().getDrivers()) {
  60.                 if (driver.isSelected() || !estimatedOnly) {
  61.                     if (suffix != null && !driver.getName().endsWith(suffix)) {
  62.                         // we add suffix only conditionally because the method may already have been called
  63.                         // and suffixes may have already been appended
  64.                         driver.setName(driver.getName() + suffix);
  65.                     }
  66.                     estimated.add(driver);
  67.                 }
  68.             }
  69.         }
  70.         return estimated;
  71.     }

  72.     /** Get the propagator parameters supported by this estimator.
  73.      * @param estimatedOnly if true, only estimated parameters are returned
  74.      * @return propagator parameters supported by this estimator
  75.      */
  76.     public ParameterDriversList getPropagationParametersDrivers(final boolean estimatedOnly) {

  77.         final ParameterDriversList estimated = new ParameterDriversList();
  78.         for (PropagatorBuilder builder : builders) {
  79.             for (final DelegatingDriver delegating : builder.getPropagationParametersDrivers().getDrivers()) {
  80.                 if (delegating.isSelected() || !estimatedOnly) {
  81.                     for (final ParameterDriver driver : delegating.getRawDrivers()) {
  82.                         estimated.add(driver);
  83.                     }
  84.                 }
  85.             }
  86.         }
  87.         return estimated;
  88.     }


  89.     /** Get the current measurement number.
  90.      * @return current measurement number
  91.      */
  92.     public int getCurrentMeasurementNumber() {
  93.         return getKalmanEstimation().getCurrentMeasurementNumber();
  94.     }

  95.     /** Get the current date.
  96.      * @return current date
  97.      */
  98.     public AbsoluteDate getCurrentDate() {
  99.         return getKalmanEstimation().getCurrentDate();
  100.     }

  101.     /** Get the "physical" estimated state (i.e. not normalized)
  102.      * <p>
  103.      * For the Semi-analytical Kalman Filters
  104.      * it corresponds to the corrected filter correction.
  105.      * In other words, it doesn't represent an orbital state.
  106.      * </p>
  107.      * @return the "physical" estimated state
  108.      */
  109.     public RealVector getPhysicalEstimatedState() {
  110.         return getKalmanEstimation().getPhysicalEstimatedState();
  111.     }

  112.     /** Get the "physical" estimated covariance matrix (i.e. not normalized)
  113.      * @return the "physical" estimated covariance matrix
  114.      */
  115.     public RealMatrix getPhysicalEstimatedCovarianceMatrix() {
  116.         return getKalmanEstimation().getPhysicalEstimatedCovarianceMatrix();
  117.     }

  118.     /** Get the list of estimated measurements parameters.
  119.      * @return the list of estimated measurements parameters
  120.      */
  121.     public ParameterDriversList getEstimatedMeasurementsParameters() {
  122.         return getKalmanEstimation().getEstimatedMeasurementsParameters();
  123.     }

  124.     /** Get the provider for kalman filter estimations.
  125.      * @return the provider for Kalman filter estimations
  126.      */
  127.     protected abstract KalmanEstimation getKalmanEstimation();

  128. }