OneWayGNSSRange.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.InterSatellitesRange;
  25. import org.orekit.estimation.measurements.ObservableSatellite;
  26. import org.orekit.propagation.SpacecraftState;
  27. import org.orekit.time.AbsoluteDate;
  28. import org.orekit.time.FieldAbsoluteDate;
  29. import org.orekit.utils.Constants;
  30. import org.orekit.utils.PVCoordinatesProvider;
  31. import org.orekit.utils.ParameterDriver;
  32. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  33. import org.orekit.utils.TimeStampedPVCoordinates;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  134.     }

  135. }