1   /* Copyright 2002-2021 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.List;
20  
21  import org.orekit.propagation.PropagationType;
22  import org.orekit.propagation.Propagator;
23  import org.orekit.propagation.SpacecraftState;
24  import org.orekit.propagation.conversion.OrbitDeterminationPropagatorBuilder;
25  import org.orekit.propagation.integration.AbstractJacobiansMapper;
26  import org.orekit.propagation.numerical.JacobiansMapper;
27  import org.orekit.propagation.numerical.NumericalPropagator;
28  import org.orekit.propagation.numerical.PartialDerivativesEquations;
29  import org.orekit.utils.ParameterDriversList;
30  
31  /** Class defining the process model dynamics to use with a {@link KalmanEstimator}.
32   * @author Romain Gerbaud
33   * @author Maxime Journot
34   * @since 9.2
35   */
36  public class KalmanModel extends AbstractKalmanModel {
37  
38      /** Kalman process model constructor.
39       * @param propagatorBuilders propagators builders used to evaluate the orbits.
40       * @param covarianceMatricesProviders providers for covariance matrices
41       * @param estimatedMeasurementParameters measurement parameters to estimate
42       * @param measurementProcessNoiseMatrix provider for measurement process noise matrix
43       */
44      public KalmanModel(final List<OrbitDeterminationPropagatorBuilder> propagatorBuilders,
45                         final List<CovarianceMatrixProvider> covarianceMatricesProviders,
46                         final ParameterDriversList estimatedMeasurementParameters,
47                         final CovarianceMatrixProvider measurementProcessNoiseMatrix) {
48          // call super constructor
49          super(propagatorBuilders, covarianceMatricesProviders, estimatedMeasurementParameters,
50                measurementProcessNoiseMatrix, new JacobiansMapper[propagatorBuilders.size()]);
51      }
52  
53      /** {@inheritDoc} */
54      @Override
55      protected void updateReferenceTrajectories(final Propagator[] propagators,
56                                                 final PropagationType pType,
57                                                 final PropagationType sType) {
58  
59          // Update the reference trajectory propagator
60          setReferenceTrajectories(propagators);
61  
62          // Jacobian mappers
63          final AbstractJacobiansMapper[] mappers = getMappers();
64  
65          for (int k = 0; k < propagators.length; ++k) {
66              // Link the partial derivatives to this new propagator
67              final String equationName = KalmanEstimator.class.getName() + "-derivatives-" + k;
68              final PartialDerivativesEquations pde = new PartialDerivativesEquations(equationName, (NumericalPropagator) getReferenceTrajectories()[k]);
69  
70              // Reset the Jacobians
71              final SpacecraftState rawState = getReferenceTrajectories()[k].getInitialState();
72              final SpacecraftState stateWithDerivatives = pde.setInitialJacobians(rawState);
73              getReferenceTrajectories()[k].resetInitialState(stateWithDerivatives);
74              mappers[k] = pde.getMapper();
75          }
76  
77          // Update Jacobian mappers
78          setMappers(mappers);
79  
80      }
81  
82      /** {@inheritDoc} */
83      @Override
84      protected void analyticalDerivativeComputations(final AbstractJacobiansMapper mapper, final SpacecraftState state) {
85          // does nothing
86          // numerical method does not require analytical terms calculations
87      }
88  
89  }