OneWayGNSSPhase.java

  1. /* Copyright 2002-2020 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.gnss;

  18. import java.util.Arrays;
  19. import java.util.HashMap;
  20. import java.util.Map;

  21. import org.hipparchus.analysis.differentiation.Gradient;
  22. import org.orekit.estimation.measurements.AbstractMeasurement;
  23. import org.orekit.estimation.measurements.EstimatedMeasurement;
  24. import org.orekit.estimation.measurements.ObservableSatellite;
  25. import org.orekit.propagation.SpacecraftState;
  26. import org.orekit.time.AbsoluteDate;
  27. import org.orekit.time.FieldAbsoluteDate;
  28. import org.orekit.utils.Constants;
  29. import org.orekit.utils.PVCoordinatesProvider;
  30. import org.orekit.utils.ParameterDriver;
  31. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  32. import org.orekit.utils.TimeStampedPVCoordinates;

  33. /** One-way GNSS phase measurement.
  34.  * <p>
  35.  * This class can be used in precise orbit determination applications
  36.  * for modeling a phase measurement between a GNSS satellite (emitter)
  37.  * and a LEO satellite (receiver).
  38.  * <p>
  39.  * The one-way GNSS phase measurement assumes knowledge of the orbit and
  40.  * the clock offset of the emitting GNSS satellite. For instance, it is
  41.  * possible to use a SP3 file or a GNSS navigation message to recover
  42.  * the satellite's orbit and clock.
  43.  * <p>
  44.  * This class is very similar to {@link InterSatellitesPhase} measurement
  45.  * class. However, using the one-way GNSS phase measurement, the orbit and clock
  46.  * of the emitting GNSS satellite are <b>NOT</b> estimated simultaneously with
  47.  * LEO satellite coordinates.
  48.  *
  49.  * @author Bryan Cazabonne
  50.  * @since 10.3
  51.  */
  52. public class OneWayGNSSPhase extends AbstractMeasurement<OneWayGNSSPhase> {

  53.     /** Name for ambiguity driver. */
  54.     public static final String AMBIGUITY_NAME = "ambiguity";

  55.     /** Driver for ambiguity. */
  56.     private final ParameterDriver ambiguityDriver;

  57.     /** Emitting satellite. */
  58.     private final PVCoordinatesProvider remote;

  59.     /** Clock offset of the emitting satellite. */
  60.     private final double dtRemote;

  61.     /** Wavelength of the phase observed value [m]. */
  62.     private final double wavelength;

  63.     /** Simple constructor.
  64.      * @param remote provider for GNSS satellite which simply emits the signal
  65.      * @param dtRemote clock offset of the GNSS satellite, in seconds
  66.      * @param date date of the measurement
  67.      * @param phase observed value, in cycles
  68.      * @param wavelength phase observed value wavelength, in meters
  69.      * @param sigma theoretical standard deviation
  70.      * @param baseWeight base weight
  71.      * @param local satellite which receives the signal and perform the measurement
  72.      */
  73.     public OneWayGNSSPhase(final PVCoordinatesProvider remote,
  74.                            final double dtRemote,
  75.                            final AbsoluteDate date,
  76.                            final double phase, final double wavelength, final double sigma,
  77.                            final double baseWeight, final ObservableSatellite local) {
  78.         // Call super constructor
  79.         super(date, phase, sigma, baseWeight, Arrays.asList(local));

  80.         // Initialize phase ambiguity driver
  81.         ambiguityDriver = new ParameterDriver(AMBIGUITY_NAME, 0.0, 1.0,
  82.                                               Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  83.         // The local satellite clock offset affects the measurement
  84.         addParameterDriver(ambiguityDriver);
  85.         addParameterDriver(local.getClockOffsetDriver());

  86.         // Initialise fields
  87.         this.dtRemote   = dtRemote;
  88.         this.remote     = remote;
  89.         this.wavelength = wavelength;
  90.     }

  91.     /** Get the wavelength.
  92.      * @return wavelength (m)
  93.      */
  94.     public double getWavelength() {
  95.         return wavelength;
  96.     }

  97.     /** Get the driver for phase ambiguity.
  98.      * @return the driver for phase ambiguity
  99.      */
  100.     public ParameterDriver getAmbiguityDriver() {
  101.         return ambiguityDriver;
  102.     }

  103.     /** {@inheritDoc} */
  104.     @Override
  105.     protected EstimatedMeasurement<OneWayGNSSPhase> theoreticalEvaluation(final int iteration,
  106.                                                                           final int evaluation,
  107.                                                                           final SpacecraftState[] states) {

  108.         // Phase derivatives are computed with respect to spacecrafts states in inertial frame
  109.         // Parameters:
  110.         //  - 0..2  - Position of the receiver satellite in inertial frame
  111.         //  - 3..5  - Velocity of the receiver satellite in inertial frame
  112.         //  - 6..n  - Measurement parameters: ambiguity and clock offset
  113.         int nbEstimatedParamsPhase = 6;
  114.         final Map<String, Integer> parameterIndicesPhase = new HashMap<>();
  115.         for (ParameterDriver phaseMeasurementDriver : getParametersDrivers()) {
  116.             if (phaseMeasurementDriver.isSelected()) {
  117.                 parameterIndicesPhase.put(phaseMeasurementDriver.getName(), nbEstimatedParamsPhase++);
  118.             }
  119.         }

  120.         // Coordinates of both satellites
  121.         final SpacecraftState localState  = states[0];
  122.         final TimeStampedFieldPVCoordinates<Gradient> pvaLocal  = getCoordinates(localState, 0, nbEstimatedParamsPhase);
  123.         final TimeStampedPVCoordinates                pvaRemote = remote.getPVCoordinates(getDate(), localState.getFrame());

  124.         // Downlink delay
  125.         final Gradient dtLocal = getSatellites().get(0).getClockOffsetDriver().getValue(nbEstimatedParamsPhase, parameterIndicesPhase);
  126.         final FieldAbsoluteDate<Gradient> arrivalDate = new FieldAbsoluteDate<>(getDate(), dtLocal.negate());

  127.         final TimeStampedFieldPVCoordinates<Gradient> s1Downlink =
  128.                         pvaLocal.shiftedBy(arrivalDate.durationFrom(pvaLocal.getDate()));
  129.         final Gradient tauD = signalTimeOfFlight(new TimeStampedFieldPVCoordinates<>(pvaRemote.getDate(), dtLocal.getField().getOne(), pvaRemote),
  130.                                                  s1Downlink.getPosition(), arrivalDate);

  131.         // Transit state
  132.         final double   delta      = getDate().durationFrom(pvaRemote.getDate());
  133.         final Gradient deltaMTauD = tauD.negate().add(delta);

  134.         // prepare the evaluation
  135.         final EstimatedMeasurement<OneWayGNSSPhase> estimatedPhase =
  136.                         new EstimatedMeasurement<>(this, iteration, evaluation,
  137.                                                    new SpacecraftState[] {
  138.                                                        localState.shiftedBy(deltaMTauD.getValue())
  139.                                                    }, new TimeStampedPVCoordinates[] {
  140.                                                        pvaRemote.shiftedBy(delta - tauD.getValue()),
  141.                                                        localState.shiftedBy(delta).getPVCoordinates()
  142.                                                    });

  143.         // Phase value
  144.         final double   cOverLambda      = Constants.SPEED_OF_LIGHT / wavelength;
  145.         final Gradient ambiguity        = ambiguityDriver.getValue(nbEstimatedParamsPhase, parameterIndicesPhase);
  146.         final Gradient phase            = tauD.add(dtLocal).subtract(dtRemote).multiply(cOverLambda).add(ambiguity);
  147.         final double[] phaseDerivatives = phase.getGradient();

  148.         // Set value and state derivatives of the estimated measurement
  149.         estimatedPhase.setEstimatedValue(phase.getValue());
  150.         estimatedPhase.setStateDerivatives(0, Arrays.copyOfRange(phaseDerivatives, 0,  6));

  151.         // Set partial derivatives with respect to parameters
  152.         for (final ParameterDriver phaseMeasurementDriver : getParametersDrivers()) {
  153.             final Integer index = parameterIndicesPhase.get(phaseMeasurementDriver.getName());
  154.             if (index != null) {
  155.                 estimatedPhase.setParameterDerivatives(phaseMeasurementDriver, phaseDerivatives[index]);
  156.             }
  157.         }

  158.         // Return the estimated measurement
  159.         return estimatedPhase;

  160.     }

  161. }