OneWayGNSSRange.java

  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.gnss;

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

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

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

  55.     /** Emitting satellite. */
  56.     private final PVCoordinatesProvider remote;

  57.     /** Clock offset of the emitting satellite. */
  58.     private final double dtRemote;

  59.     /** Simple constructor.
  60.      * @param remote provider for GNSS satellite which simply emits the signal
  61.      * @param dtRemote clock offset of the GNSS satellite, in seconds
  62.      * @param date date of the measurement
  63.      * @param range observed value
  64.      * @param sigma theoretical standard deviation
  65.      * @param baseWeight base weight
  66.      * @param local satellite which receives the signal and perform the measurement
  67.      */
  68.     public OneWayGNSSRange(final PVCoordinatesProvider remote,
  69.                            final double dtRemote,
  70.                            final AbsoluteDate date,
  71.                            final double range, final double sigma,
  72.                            final double baseWeight, final ObservableSatellite local) {
  73.         // Call super constructor
  74.         super(date, range, sigma, baseWeight, Collections.singletonList(local));
  75.         // The local satellite clock offset affects the measurement
  76.         addParameterDriver(local.getClockOffsetDriver());
  77.         // Initialise fields
  78.         this.dtRemote = dtRemote;
  79.         this.remote   = remote;
  80.     }

  81.     /** {@inheritDoc} */
  82.     @Override
  83.     protected EstimatedMeasurement<OneWayGNSSRange> theoreticalEvaluation(final int iteration,
  84.                                                                           final int evaluation,
  85.                                                                           final SpacecraftState[] states) {

  86.         // Range derivatives are computed with respect to spacecraft state in inertial frame
  87.         // Parameters:
  88.         //  - 0..2 - Position of the spacecraft in inertial frame
  89.         //  - 3..5 - Velocity of the spacecraft in inertial frame
  90.         //  - 6..n - measurements parameters (clock offset, etc)
  91.         int nbEstimatedParams = 6;
  92.         final Map<String, Integer> parameterIndices = new HashMap<>();
  93.         for (ParameterDriver measurementDriver : getParametersDrivers()) {
  94.             if (measurementDriver.isSelected()) {
  95.                 parameterIndices.put(measurementDriver.getName(), nbEstimatedParams++);
  96.             }
  97.         }

  98.         // Coordinates of both satellites in local satellite frame
  99.         final SpacecraftState localState  = states[0];
  100.         final TimeStampedFieldPVCoordinates<Gradient> pvaLocal  = getCoordinates(localState, 0, nbEstimatedParams);
  101.         final TimeStampedPVCoordinates                pvaRemote = remote.getPVCoordinates(getDate(), localState.getFrame());

  102.         // Downlink delay
  103.         final Gradient dtLocal = getSatellites().get(0).getClockOffsetDriver().getValue(nbEstimatedParams, parameterIndices);
  104.         final FieldAbsoluteDate<Gradient> arrivalDate = new FieldAbsoluteDate<>(getDate(), dtLocal.negate());

  105.         final TimeStampedFieldPVCoordinates<Gradient> s1Downlink = pvaLocal.shiftedBy(arrivalDate.durationFrom(pvaLocal.getDate()));
  106.         final Gradient tauD = signalTimeOfFlight(new TimeStampedFieldPVCoordinates<>(pvaRemote.getDate(), dtLocal.getField().getOne(), pvaRemote),
  107.                                                  s1Downlink.getPosition(), arrivalDate);

  108.         // Transit state
  109.         final double   delta      = getDate().durationFrom(pvaRemote.getDate());
  110.         final Gradient deltaMTauD = tauD.negate().add(delta);

  111.         // Estimated measurement
  112.         final EstimatedMeasurement<OneWayGNSSRange> estimatedRange =
  113.                         new EstimatedMeasurement<>(this, iteration, evaluation,
  114.                                                    new SpacecraftState[] {
  115.                                                        localState.shiftedBy(deltaMTauD.getValue())
  116.                                                    }, new TimeStampedPVCoordinates[] {
  117.                                                        pvaRemote.shiftedBy(delta - tauD.getValue()),
  118.                                                        localState.shiftedBy(delta).getPVCoordinates()
  119.                                                    });

  120.         // Range value
  121.         final Gradient range            = tauD.add(dtLocal).subtract(dtRemote).multiply(Constants.SPEED_OF_LIGHT);
  122.         final double[] rangeDerivatives = range.getGradient();

  123.         // Set value and state derivatives of the estimated measurement
  124.         estimatedRange.setEstimatedValue(range.getValue());
  125.         estimatedRange.setStateDerivatives(0, Arrays.copyOfRange(rangeDerivatives, 0,  6));

  126.         // Set partial derivatives with respect to parameters
  127.         for (final ParameterDriver measurementDriver : getParametersDrivers()) {
  128.             final Integer index = parameterIndices.get(measurementDriver.getName());
  129.             if (index != null) {
  130.                 estimatedRange.setParameterDerivatives(measurementDriver, rangeDerivatives[index]);
  131.             }
  132.         }

  133.         // Return the estimated measurement
  134.         return estimatedRange;

  135.     }

  136. }