1   /* Copyright 2022-2025 Luc Maisonobe
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.measurements.generation;
18  
19  import java.util.Arrays;
20  
21  import org.hipparchus.linear.MatrixUtils;
22  import org.hipparchus.linear.RealMatrix;
23  import org.hipparchus.random.CorrelatedRandomVectorGenerator;
24  import org.hipparchus.random.GaussianRandomGenerator;
25  import org.hipparchus.random.RandomGenerator;
26  import org.hipparchus.util.FastMath;
27  import org.junit.jupiter.api.Test;
28  import org.orekit.estimation.measurements.AngularAzEl;
29  import org.orekit.estimation.measurements.GroundStation;
30  import org.orekit.estimation.measurements.MultiplexedMeasurement;
31  import org.orekit.estimation.measurements.ObservableSatellite;
32  import org.orekit.estimation.measurements.Range;
33  import org.orekit.estimation.measurements.modifiers.Bias;
34  
35  public class MultiplexedMeasurementBuilderTest extends AbstractGroundMeasurementBuilderTest<MultiplexedMeasurement> {
36  
37      private static final double RANGE_SIGMA = 10.0;
38      private static final double RANGE_BIAS  =  3.0;
39      private static final double AZEL_SIGMA  = 1.0e-3;
40      private static final double AZEL_BIAS   = 1.0e-4;
41  
42      protected MeasurementBuilder<MultiplexedMeasurement> getBuilder(final RandomGenerator random,
43                                                                      final GroundStation groundStation,
44                                                                      final ObservableSatellite satellite) {
45          final RealMatrix rangeCovariance = MatrixUtils.createRealDiagonalMatrix(new double[] { RANGE_SIGMA * RANGE_SIGMA });
46          MeasurementBuilder<Range> rb =
47                          new RangeBuilder(random == null ? null : new CorrelatedRandomVectorGenerator(rangeCovariance,
48                                                                                                       1.0e-10,
49                                                                                                       new GaussianRandomGenerator(random)),
50                                           groundStation, true, RANGE_SIGMA, 1.0, satellite);
51  
52          final RealMatrix azelCovariance = MatrixUtils.createRealDiagonalMatrix(new double[] {
53              AZEL_SIGMA * AZEL_SIGMA, AZEL_SIGMA * AZEL_SIGMA
54          });
55          MeasurementBuilder<AngularAzEl> ab =
56                          new AngularAzElBuilder(random == null ? null : new CorrelatedRandomVectorGenerator(azelCovariance,
57                                                                                                             1.0e-10,
58                                                                                                             new GaussianRandomGenerator(random)),
59                                                 groundStation, new double[] { AZEL_SIGMA, AZEL_SIGMA}, new double[] { 1.0, 1.0 },
60                                                 satellite);
61  
62          MultiplexedMeasurementBuilder mb = new MultiplexedMeasurementBuilder(Arrays.asList(rb, ab ));
63          mb.addModifier(new Bias<>(new String[] { "rBias", "aBias", "eBias" },
64                                    new double[] { RANGE_BIAS, AZEL_BIAS, AZEL_BIAS },
65                                    new double[] { 1.0, 1.0, 1.0 },
66                                    new double[] { Double.NEGATIVE_INFINITY, -FastMath.PI, -0.5 * FastMath.PI },
67                                    new double[] { Double.POSITIVE_INFINITY, +FastMath.PI, +0.5 * FastMath.PI }));
68  
69        return mb;
70  
71      }
72  
73      @Test
74      public void testForward() {
75          doTest(0xb715507647d63318l, 0.4, 0.9, 128, 2.7 * RANGE_SIGMA);
76      }
77  
78      @Test
79      public void testBackward() {
80          doTest(0xceac6c6c358e95d0l, -0.2, -0.6, 100, 2.8 * RANGE_SIGMA);
81      }
82  
83  }