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.semianalytical.dsst.DSSTJacobiansMapper;
27  import org.orekit.propagation.semianalytical.dsst.DSSTPartialDerivativesEquations;
28  import org.orekit.propagation.semianalytical.dsst.DSSTPropagator;
29  import org.orekit.utils.ParameterDriversList;
30  
31  /** Class defining the process model dynamics to use with a {@link KalmanEstimator}.
32   * <p>
33   * This class is an adaption of the {@link KalmanModel} class
34   * but for the {@link DSSTPropagator DSST propagator}.
35   * </p>
36   * @author Romain Gerbaud
37   * @author Maxime Journot
38   * @author Bryan Cazabonne
39   * @since 10.0
40   */
41  public class DSSTKalmanModel extends AbstractKalmanModel {
42  
43      /** Kalman process model constructor.
44       * @param propagatorBuilders propagators builders used to evaluate the orbits.
45       * @param covarianceMatricesProviders providers for covariance matrices
46       * @param estimatedMeasurementParameters measurement parameters to estimate
47       * @param measurementProcessNoiseMatrix provider for measurement process noise matrix
48       * @param propagationType type of the orbit used for the propagation (mean or osculating)
49       * @param stateType type of the elements used to define the orbital state (mean or osculating)
50       */
51      public DSSTKalmanModel(final List<OrbitDeterminationPropagatorBuilder> propagatorBuilders,
52                             final List<CovarianceMatrixProvider> covarianceMatricesProviders,
53                             final ParameterDriversList estimatedMeasurementParameters,
54                             final CovarianceMatrixProvider measurementProcessNoiseMatrix,
55                             final PropagationType propagationType,
56                             final PropagationType stateType) {
57          // call super constructor
58          super(propagatorBuilders, covarianceMatricesProviders, estimatedMeasurementParameters,
59                measurementProcessNoiseMatrix, new DSSTJacobiansMapper[propagatorBuilders.size()],
60                propagationType, stateType);
61      }
62  
63      /** {@inheritDoc} */
64      @Override
65      protected void updateReferenceTrajectories(final Propagator[] propagators,
66                                                 final PropagationType pType,
67                                                 final PropagationType sType) {
68  
69          // Update the reference trajectory propagator
70          setReferenceTrajectories(propagators);
71  
72          // Jacobian mappers
73          final AbstractJacobiansMapper[] mappers = getMappers();
74  
75          for (int k = 0; k < propagators.length; ++k) {
76              // Link the partial derivatives to this new propagator
77              final String equationName = KalmanEstimator.class.getName() + "-derivatives-" + k;
78              final DSSTPartialDerivativesEquations pde = new DSSTPartialDerivativesEquations(equationName, (DSSTPropagator) getReferenceTrajectories()[k], pType);
79  
80              // Reset the Jacobians
81              final SpacecraftState rawState = getReferenceTrajectories()[k].getInitialState();
82              final SpacecraftState stateWithDerivatives = pde.setInitialJacobians(rawState);
83              ((DSSTPropagator) getReferenceTrajectories()[k]).setInitialState(stateWithDerivatives, sType);
84              mappers[k] = pde.getMapper();
85          }
86  
87          // Update Jacobian mappers
88          setMappers(mappers);
89  
90      }
91  
92      /** {@inheritDoc} */
93      @Override
94      protected void analyticalDerivativeComputations(final AbstractJacobiansMapper mapper, final SpacecraftState state) {
95          ((DSSTJacobiansMapper) mapper).setShortPeriodJacobians(state);
96      }
97  
98  }