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.measurements.modifiers;
18  
19  import org.hipparchus.geometry.euclidean.threed.Vector3D;
20  import org.junit.Assert;
21  import org.junit.Before;
22  import org.junit.Test;
23  import org.orekit.Utils;
24  import org.orekit.estimation.measurements.EstimatedMeasurement;
25  import org.orekit.estimation.measurements.EstimationModifier;
26  import org.orekit.estimation.measurements.ObservableSatellite;
27  import org.orekit.estimation.measurements.gnss.OneWayGNSSRange;
28  import org.orekit.propagation.SpacecraftState;
29  import org.orekit.propagation.analytical.tle.TLE;
30  import org.orekit.propagation.analytical.tle.TLEPropagator;
31  import org.orekit.time.AbsoluteDate;
32  import org.orekit.time.TimeScalesFactory;
33  
34  public class RelativisticClockOneWayGNSSRangeModifierTest {
35  
36      /** Date. */
37      private static AbsoluteDate date;
38  
39      /** Spacecraft states. */
40      private static SpacecraftState[] states;
41  
42      @Test
43      public void testRelativisticClockCorrection() {
44  
45          // Measurement
46          final OneWayGNSSRange range = new OneWayGNSSRange(states[1].getOrbit(), 0.0, date,
47                                                            Vector3D.distance(states[0].getPVCoordinates().getPosition(),
48                                                                              states[1].getPVCoordinates().getPosition()),
49                                                            1.0, 1.0, new ObservableSatellite(0));
50  
51          // Inter-satellites range before applying the modifier
52          final EstimatedMeasurement<OneWayGNSSRange> estimatedBefore = range.estimate(0, 0, states);
53  
54          // Inter-satellites range before applying the modifier
55          final EstimationModifier<OneWayGNSSRange> modifier = new RelativisticClockOneWayGNSSRangeModifier();
56          range.addModifier(modifier);
57          final EstimatedMeasurement<OneWayGNSSRange> estimatedAfter = range.estimate(0, 0, states);
58  
59          // Verify
60          Assert.assertEquals(-10.57, estimatedBefore.getEstimatedValue()[0] - estimatedAfter.getEstimatedValue()[0], 1.0e-2);
61          Assert.assertEquals(0, modifier.getParametersDrivers().size());
62  
63      }
64  
65      @Before
66      public void setUp() {
67          // Data root
68          Utils.setDataRoot("regular-data");
69  
70          // Date
71          date = new AbsoluteDate("2004-01-13T00:00:00.000", TimeScalesFactory.getUTC());
72  
73          // Spacecraft states
74          states = new SpacecraftState[2];
75          final TLE local = new TLE("1 27642U 03002A   04013.91734903  .00000108  00000-0  12227-4 0  3621",
76                                    "2 27642  93.9970   6.8623 0003169  80.1383 280.0205 14.90871424 54508");
77          final TLE remote = new TLE("1 20061U 89044A   04013.44391333  .00000095  00000-0  10000-3 0  3242",
78                                     "2 20061  53.4233 172.2072 0234017 261.4179  95.8975  2.00577231106949");
79          states[0] = TLEPropagator.selectExtrapolator(local).propagate(date);
80          states[1] = TLEPropagator.selectExtrapolator(remote).propagate(date);
81      }
82  
83  }