1   /* Copyright 2002-2021 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 java.util.Collections;
20  import java.util.List;
21  
22  import org.hipparchus.geometry.euclidean.threed.Vector3D;
23  import org.orekit.estimation.measurements.EstimatedMeasurement;
24  import org.orekit.estimation.measurements.EstimationModifier;
25  import org.orekit.estimation.measurements.gnss.InterSatellitesPhase;
26  import org.orekit.frames.Transform;
27  import org.orekit.propagation.SpacecraftState;
28  import org.orekit.time.AbsoluteDate;
29  import org.orekit.utils.ParameterDriver;
30  import org.orekit.utils.TimeStampedPVCoordinates;
31  
32  /** On-board antenna offset effect on inter-satellites phase measurements.
33   * @author Bryan Cazabonne
34   * @since 10.3
35   */
36  public class OnBoardAntennaInterSatellitesPhaseModifier implements EstimationModifier<InterSatellitesPhase> {
37  
38      /** Position of the Antenna Phase Center in satellite 1 frame. */
39      private final Vector3D antennaPhaseCenter1;
40  
41      /** Position of the Antenna Phase Center in satellite 2 frame. */
42      private final Vector3D antennaPhaseCenter2;
43  
44      /** Simple constructor.
45       * @param antennaPhaseCenter1 position of the Antenna Phase Center in satellite 1 frame
46       * (i.e. the satellite which receives the signal and performs the measurement)
47       * @param antennaPhaseCenter2 position of the Antenna Phase Center in satellite 2 frame
48       * (i.e. the satellite which simply emits the signal in the one-way
49       * case, or reflects the signal in the two-way case)
50       */
51      public OnBoardAntennaInterSatellitesPhaseModifier(final Vector3D antennaPhaseCenter1,
52                                                        final Vector3D antennaPhaseCenter2) {
53          this.antennaPhaseCenter1 = antennaPhaseCenter1;
54          this.antennaPhaseCenter2 = antennaPhaseCenter2;
55      }
56  
57      /** {@inheritDoc} */
58      @Override
59      public List<ParameterDriver> getParametersDrivers() {
60          return Collections.emptyList();
61      }
62  
63      @Override
64      public void modify(final EstimatedMeasurement<InterSatellitesPhase> estimated) {
65  
66          // The participants are satellite 2 at emission, satellite 1 at reception
67          final TimeStampedPVCoordinates[] participants  = estimated.getParticipants();
68          final AbsoluteDate               emissionDate  = participants[0].getDate();
69          final AbsoluteDate               receptionDate = participants[1].getDate();
70  
71          // transforms from spacecraft to inertial frame at emission/reception dates
72          final SpacecraftState localState                 = estimated.getStates()[0];
73          final SpacecraftState receptionState             = localState.shiftedBy(receptionDate.durationFrom(localState.getDate()));
74          final Transform       receptionSpacecraftToInert = receptionState.toTransform().getInverse();
75          final SpacecraftState remoteState                = estimated.getStates()[1];
76          final SpacecraftState emissionState              = remoteState.shiftedBy(emissionDate.durationFrom(remoteState.getDate()));
77          final Transform       emissionSpacecraftToInert  = emissionState.toTransform().getInverse();
78  
79          // Compute the geometrical value of the inter-satellites range directly from participants positions.
80          final Vector3D pSpacecraftReception = receptionSpacecraftToInert.transformPosition(Vector3D.ZERO);
81          final Vector3D pSpacecraftEmission  = emissionSpacecraftToInert.transformPosition(Vector3D.ZERO);
82          final double interSatellitesRangeUsingSpacecraftCenter = Vector3D.distance(pSpacecraftEmission, pSpacecraftReception);
83  
84          // Compute the geometrical value of the range replacing
85          // The spacecraft positions with antenna phase center positions
86          final Vector3D pAPCReception = receptionSpacecraftToInert.transformPosition(antennaPhaseCenter1);
87          final Vector3D pAPCEmission  = emissionSpacecraftToInert.transformPosition(antennaPhaseCenter2);
88          final double interSatellitesRangeUsingAntennaPhaseCenter = Vector3D.distance(pAPCEmission, pAPCReception);
89  
90          // Get the estimated value before this modifier is applied
91          final double[] value = estimated.getEstimatedValue();
92  
93          // Modify the phase value by applying measurement wavelength
94          final double wavelength = estimated.getObservedMeasurement().getWavelength();
95          value[0] += (interSatellitesRangeUsingAntennaPhaseCenter - interSatellitesRangeUsingSpacecraftCenter) / wavelength;
96          estimated.setEstimatedValue(value);
97  
98      }
99  
100 
101 }