1   /* Copyright 2022-2025 Thales Alenia Space
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.orekit.attitudes.AttitudeProvider;
20  import org.orekit.estimation.measurements.AbstractMeasurement;
21  import org.orekit.estimation.measurements.EstimatedMeasurementBase;
22  import org.orekit.frames.StaticTransform;
23  import org.orekit.gnss.antenna.FrequencyPattern;
24  import org.orekit.orbits.CartesianOrbit;
25  import org.orekit.orbits.Orbit;
26  import org.orekit.propagation.SpacecraftState;
27  import org.orekit.time.AbsoluteDate;
28  import org.orekit.utils.TimeStampedPVCoordinates;
29  
30  /** On-board antenna offset effect on inter-satellites phase measurements.
31   * @param <T> type of the measurement
32   * @author Luc Maisonobe
33   * @since 12.1
34   */
35  public class PhaseCentersOneWayGNSSBaseModifier<T extends AbstractMeasurement<T>> {
36  
37      /** Link offset model. */
38      private final PhaseCentersOffsetComputer link;
39  
40      /** Attitude provider of the emitting satellite. */
41      private final AttitudeProvider attitudeProvider;
42  
43      /** Simple constructor.
44       * @param receiverPattern pattern for receiver satellite
45       * @param emitterPattern  pattern for emitter satellite
46       * @param attitudeProvider attitude provider of the emitting satellite
47       */
48      public PhaseCentersOneWayGNSSBaseModifier(final FrequencyPattern receiverPattern,
49                                                final FrequencyPattern emitterPattern,
50                                                final AttitudeProvider attitudeProvider) {
51          this.link             = new PhaseCentersOffsetComputer(emitterPattern, receiverPattern);
52          this.attitudeProvider = attitudeProvider;
53      }
54  
55      /** Get the name of the effect modifying the measurement.
56       * @return name of the effect modifying the measurement
57       * @since 13.0
58       */
59      public String getEffectName() {
60          return "mean phase center";
61      }
62  
63      /** Compute distance modification for one way measurement.
64       * @param estimated estimated measurement to modify
65       * @return distance modification to add to raw measurement
66       */
67      public double oneWayDistanceModification(final EstimatedMeasurementBase<T> estimated) {
68  
69          // The participants are remote satellite at emission, local satellite at reception
70          final TimeStampedPVCoordinates[] phaseParticipants  = estimated.getParticipants();
71          final AbsoluteDate               phaseEmissionDate  = phaseParticipants[0].getDate();
72          final AbsoluteDate               phaseReceptionDate = phaseParticipants[1].getDate();
73  
74          // Transforms from spacecraft to inertial frame at reception date
75          final SpacecraftState refStateLocal              = estimated.getStates()[0];
76          final SpacecraftState receptionState             = refStateLocal.shiftedBy(phaseReceptionDate.durationFrom(refStateLocal.getDate()));
77          final StaticTransform receptionSpacecraftToInert = receptionState.toStaticTransform().getInverse();
78  
79          // Orbit of the remote satellite
80          final Orbit orbitRemote = new CartesianOrbit(phaseParticipants[0], refStateLocal.getFrame(), receptionState.getOrbit().getMu());
81  
82          // Transforms from spacecraft to inertial frame at emission date
83          final SpacecraftState refStateRemote            = new SpacecraftState(orbitRemote).withAttitude(
84                                                                                attitudeProvider.getAttitude(orbitRemote,
85                                                                                                             orbitRemote.getDate(),
86                                                                                                             orbitRemote.getFrame()));
87          final SpacecraftState emissionState             = refStateRemote.shiftedBy(phaseEmissionDate.durationFrom(refStateRemote.getDate()));
88          final StaticTransform emissionSpacecraftToInert = emissionState.toStaticTransform().getInverse();
89  
90          // compute offset due to phase centers
91          return link.offset(emissionSpacecraftToInert, receptionSpacecraftToInert);
92      }
93  
94  }