1   package org.orekit.estimation.sequential;
2   
3   import org.hipparchus.exception.MathIllegalStateException;
4   import org.hipparchus.linear.MatrixUtils;
5   import org.hipparchus.linear.RealMatrix;
6   import org.junit.jupiter.api.Assertions;
7   import org.junit.jupiter.api.Test;
8   import org.orekit.estimation.Context;
9   import org.orekit.estimation.EstimationTestUtils;
10  import org.orekit.estimation.measurements.ObservedMeasurement;
11  import org.orekit.estimation.measurements.PVMeasurementCreator;
12  import org.orekit.orbits.OrbitType;
13  import org.orekit.orbits.PositionAngleType;
14  import org.orekit.propagation.Propagator;
15  import org.orekit.propagation.conversion.NumericalPropagatorBuilder;
16  
17  import java.util.List;
18  
19  public class RtsSmootherTest {
20  
21      @Test
22      void testNoUpdates() {
23          // Create context
24          Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
25  
26          // Create initial orbit and propagator builder
27          final OrbitType orbitType     = OrbitType.KEPLERIAN;
28          final PositionAngleType positionAngleType = PositionAngleType.TRUE;
29          final boolean       perfectStart  = true;
30          final double        minStep       = 1.e-6;
31          final double        maxStep       = 60.;
32          final double        dP            = 1.;
33          final NumericalPropagatorBuilder propagatorBuilder =
34                  context.createBuilder(orbitType, positionAngleType, perfectStart,
35                          minStep, maxStep, dP);
36  
37          // Create perfect PV measurements
38          final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit,
39                  propagatorBuilder);
40          final List<ObservedMeasurement<?>> measurements =
41                  EstimationTestUtils.createMeasurements(propagator,
42                          new PVMeasurementCreator(),
43                          0.0, 3.0, 300.0);
44  
45          // Covariance matrix initialization
46          final RealMatrix initialP = MatrixUtils.createRealDiagonalMatrix(new double [] {
47                  1e-2, 1e-2, 1e-2, 1e-5, 1e-5, 1e-5
48          });
49  
50          // Process noise matrix
51          RealMatrix Q = MatrixUtils.createRealDiagonalMatrix(new double [] {
52                  1.e-8, 1.e-8, 1.e-8, 1.e-8, 1.e-8, 1.e-8
53          });
54  
55          // Build the Kalman filter
56          final KalmanEstimator kalman = new KalmanEstimatorBuilder().
57                  addPropagationConfiguration(propagatorBuilder, new ConstantProcessNoise(initialP, Q)).
58                  build();
59  
60          // Add smoother
61          final RtsSmoother rtsSmoother = new RtsSmoother(kalman);
62          kalman.setObserver(rtsSmoother);
63  
64          // No measurements processed - should throw
65          Assertions.assertThrows(MathIllegalStateException.class, rtsSmoother::backwardsSmooth);
66  
67          // Single measurement processed - should be OK
68          kalman.estimationStep(measurements.get(0));
69          Assertions.assertDoesNotThrow(rtsSmoother::backwardsSmooth);
70      }
71  }