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  
19  import java.util.List;
20  
21  import org.hipparchus.linear.MatrixUtils;
22  import org.hipparchus.linear.RealMatrix;
23  import org.junit.Test;
24  import org.orekit.estimation.BrouwerLyddaneContext;
25  import org.orekit.estimation.BrouwerLyddaneEstimationTestUtils;
26  import org.orekit.estimation.measurements.ObservedMeasurement;
27  import org.orekit.estimation.measurements.PVMeasurementCreator;
28  import org.orekit.orbits.Orbit;
29  import org.orekit.orbits.PositionAngle;
30  import org.orekit.propagation.Propagator;
31  import org.orekit.propagation.analytical.BrouwerLyddanePropagator;
32  import org.orekit.propagation.conversion.BrouwerLyddanePropagatorBuilder;
33  
34  public class BrouwerLyddaneKalmanEstimatorTest {
35  
36      /**
37       * Perfect PV measurements with a perfect start
38       * Keplerian formalism
39       */
40      @Test
41      public void testKeplerianPV() {
42  
43          // Create context
44          BrouwerLyddaneContext context = BrouwerLyddaneEstimationTestUtils.eccentricContext("regular-data:potential:tides");
45  
46          // Create initial orbit and propagator builder
47          final PositionAngle positionAngle = PositionAngle.TRUE;
48          final boolean       perfectStart  = true;
49          final double        dP            = 1.;
50          final BrouwerLyddanePropagatorBuilder propagatorBuilder =
51                          context.createBuilder(positionAngle, perfectStart, dP);
52  
53          // Create perfect PV measurements
54          final Propagator propagator = BrouwerLyddaneEstimationTestUtils.createPropagator(context.initialOrbit,
55                                                                             propagatorBuilder);
56          final List<ObservedMeasurement<?>> measurements =
57                          BrouwerLyddaneEstimationTestUtils.createMeasurements(propagator,
58                                                                 new PVMeasurementCreator(),
59                                                                 0.0, 3.0, 300.0);
60          // Reference propagator for estimation performances
61          final BrouwerLyddanePropagator referencePropagator = propagatorBuilder.
62                          buildPropagator(propagatorBuilder.getSelectedNormalizedParameters());
63          
64          // Reference position/velocity at last measurement date
65          final Orbit refOrbit = referencePropagator.
66                          propagate(measurements.get(measurements.size()-1).getDate()).getOrbit();
67          
68          // Covariance matrix initialization
69          final RealMatrix initialP = MatrixUtils.createRealDiagonalMatrix(new double [] {
70              1e-2, 1e-2, 1e-2, 1e-5, 1e-5, 1e-5
71          });        
72  
73          // Process noise matrix
74          RealMatrix Q = MatrixUtils.createRealDiagonalMatrix(new double [] {
75              1.e-8, 1.e-8, 1.e-8, 1.e-8, 1.e-8, 1.e-8
76          });
77    
78  
79          // Build the Kalman filter
80          final KalmanEstimator kalman = new KalmanEstimatorBuilder().
81                          addPropagationConfiguration(propagatorBuilder, new ConstantProcessNoise(initialP, Q)).
82                          build();
83          
84          // Filter the measurements and check the results
85          final double   expectedDeltaPos  = 0.;
86          final double   posEps            = 2.33e-8;
87          final double   expectedDeltaVel  = 0.;
88          final double   velEps            = 6.59e-11;
89          final double[] expectedsigmasPos = {0.998894, 0.933798, 0.997346};
90          final double   sigmaPosEps       = 1e-6;
91          final double[] expectedSigmasVel = {9.475825e-4, 9.903811e-4, 5.061704e-4};
92          final double   sigmaVelEps       = 1e-10;
93          BrouwerLyddaneEstimationTestUtils.checkKalmanFit(context, kalman, measurements,
94                                                           refOrbit, positionAngle,
95                                                           expectedDeltaPos, posEps,
96                                                           expectedDeltaVel, velEps,
97                                                           expectedsigmasPos, sigmaPosEps,
98                                                           expectedSigmasVel, sigmaVelEps);
99      }
100 
101 }