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