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.gnss;
18  
19  import java.util.Arrays;
20  
21  import org.hipparchus.analysis.differentiation.Gradient;
22  import org.orekit.estimation.measurements.ObservableSatellite;
23  import org.orekit.estimation.measurements.ObservedMeasurement;
24  import org.orekit.estimation.measurements.QuadraticClockModel;
25  import org.orekit.propagation.SpacecraftState;
26  import org.orekit.time.AbsoluteDate;
27  import org.orekit.utils.FieldPVCoordinatesProvider;
28  import org.orekit.utils.PVCoordinatesProvider;
29  import org.orekit.utils.ShiftingPVCoordinatesProvider;
30  import org.orekit.utils.TimeStampedFieldPVCoordinates;
31  
32  /** Base class for measurement between two satellites that are both estimated.
33   * <p>
34   * The measurement is considered to be a signal emitted from
35   * a remote satellite and received by a local satellite.
36   * Its value is the number of cycles between emission and reception.
37   * The motion of both spacecraft during the signal flight time
38   * are taken into account. The date of the measurement corresponds to the
39   * reception on ground of the emitted signal.
40   * </p>
41   * @param <T> type of the measurement
42   * @author Luc Maisonobe
43   * @since 12.1
44   */
45  public abstract class AbstractInterSatellitesMeasurement<T extends ObservedMeasurement<T>> extends AbstractOnBoardMeasurement<T> {
46  
47      /** Constructor.
48       * @param date date of the measurement
49       * @param observed observed value
50       * @param sigma theoretical standard deviation
51       * @param baseWeight base weight
52       * @param local satellite which receives the signal and performs the measurement
53       * @param remote remote satellite which simply emits the signal
54       */
55      public AbstractInterSatellitesMeasurement(final AbsoluteDate date, final double observed,
56                                                final double sigma, final double baseWeight,
57                                                final ObservableSatellite local,
58                                                final ObservableSatellite remote) {
59          // Call to super constructor
60          super(date, observed, sigma, baseWeight, Arrays.asList(local, remote));
61      }
62  
63      /** {@inheritDoc} */
64      @Override
65      protected PVCoordinatesProvider getRemotePV(final SpacecraftState[] states) {
66          return new ShiftingPVCoordinatesProvider(states[1].getPVCoordinates(), states[1].getFrame());
67      }
68  
69      /** {@inheritDoc} */
70      @Override
71      protected QuadraticClockModel getRemoteClock() {
72          return getSatellites().get(1).getQuadraticClockModel();
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      protected FieldPVCoordinatesProvider<Gradient> getRemotePV(final SpacecraftState[] states,
78                                                                 final int freeParameters) {
79          // convert the SpacecraftState to a FieldPVCoordinatesProvider<Gradient>
80          return (date, frame) -> {
81  
82              // set up the derivatives with respect to remote state at its date
83              final TimeStampedFieldPVCoordinates<Gradient> pv0 = getCoordinates(states[1], 6, freeParameters);
84  
85              // shift to desired date
86              final TimeStampedFieldPVCoordinates<Gradient> shifted = pv0.shiftedBy(date.durationFrom(states[1].getDate()));
87  
88              // transform to desired frame
89              return states[1].getFrame().getTransformTo(frame, states[1].getDate()).transformPVCoordinates(shifted);
90  
91          };
92      }
93  
94  }