OneWayGNSSRange.java

  1. /* Copyright 2002-2025 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 org.hipparchus.analysis.differentiation.Gradient;
  20. import org.orekit.estimation.measurements.EstimatedMeasurement;
  21. import org.orekit.estimation.measurements.EstimatedMeasurementBase;
  22. import org.orekit.estimation.measurements.InterSatellitesRange;
  23. import org.orekit.estimation.measurements.ObservableSatellite;
  24. import org.orekit.estimation.measurements.QuadraticClockModel;
  25. import org.orekit.propagation.SpacecraftState;
  26. import org.orekit.time.AbsoluteDate;
  27. import org.orekit.utils.Constants;
  28. import org.orekit.utils.PVCoordinatesProvider;
  29. import org.orekit.utils.ParameterDriver;
  30. import org.orekit.utils.TimeSpanMap.Span;
  31. import org.orekit.utils.TimeStampedPVCoordinates;

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

  52.     /** Type of the measurement. */
  53.     public static final String MEASUREMENT_TYPE = "OneWayGNSSRange";

  54.     /** Simple constructor.
  55.      * @param remote provider for GNSS satellite which simply emits the signal
  56.      * @param dtRemote clock offset of the GNSS satellite, in seconds
  57.      * @param date date of the measurement
  58.      * @param range observed value
  59.      * @param sigma theoretical standard deviation
  60.      * @param baseWeight base weight
  61.      * @param local satellite which receives the signal and perform the measurement
  62.      */
  63.     public OneWayGNSSRange(final PVCoordinatesProvider remote,
  64.                            final double dtRemote,
  65.                            final AbsoluteDate date,
  66.                            final double range, final double sigma,
  67.                            final double baseWeight, final ObservableSatellite local) {
  68.         this(remote, new QuadraticClockModel(date, dtRemote, 0.0, 0.0), date, range, sigma, baseWeight, local);
  69.     }

  70.     /** Simple constructor.
  71.      * @param remote provider for GNSS satellite which simply emits the signal
  72.      * @param remoteClock clock offset of the GNSS satellite
  73.      * @param date date of the measurement
  74.      * @param range observed value
  75.      * @param sigma theoretical standard deviation
  76.      * @param baseWeight base weight
  77.      * @param local satellite which receives the signal and perform the measurement
  78.      * @since 12.1
  79.      */
  80.     public OneWayGNSSRange(final PVCoordinatesProvider remote,
  81.                            final QuadraticClockModel remoteClock,
  82.                            final AbsoluteDate date,
  83.                            final double range, final double sigma,
  84.                            final double baseWeight, final ObservableSatellite local) {
  85.         // Call super constructor
  86.         super(remote, remoteClock, date, range, sigma, baseWeight, local);
  87.     }

  88.     /** {@inheritDoc} */
  89.     @Override
  90.     protected EstimatedMeasurementBase<OneWayGNSSRange> theoreticalEvaluationWithoutDerivatives(final int iteration,
  91.                                                                                                 final int evaluation,
  92.                                                                                                 final SpacecraftState[] states) {


  93.         final OnBoardCommonParametersWithoutDerivatives common = computeCommonParametersWithout(states, false);

  94.         // Estimated measurement
  95.         final EstimatedMeasurementBase<OneWayGNSSRange> estimatedRange =
  96.                         new EstimatedMeasurementBase<>(this, iteration, evaluation,
  97.                                                        new SpacecraftState[] {
  98.                                                            common.getState()
  99.                                                        }, new TimeStampedPVCoordinates[] {
  100.                                                            common.getRemotePV(),
  101.                                                            common.getTransitPV()
  102.                                                        });

  103.         // Range value
  104.         final double range = (common.getTauD() + common.getLocalOffset() - common.getRemoteOffset()) *
  105.                              Constants.SPEED_OF_LIGHT;

  106.         // Set value of the estimated measurement
  107.         estimatedRange.setEstimatedValue(range);

  108.         // Return the estimated measurement
  109.         return estimatedRange;

  110.     }

  111.     /** {@inheritDoc} */
  112.     @Override
  113.     protected EstimatedMeasurement<OneWayGNSSRange> theoreticalEvaluation(final int iteration,
  114.                                                                           final int evaluation,
  115.                                                                           final SpacecraftState[] states) {

  116.         final OnBoardCommonParametersWithDerivatives common = computeCommonParametersWith(states, false);

  117.         // Estimated measurement
  118.         final EstimatedMeasurement<OneWayGNSSRange> estimatedRange =
  119.                         new EstimatedMeasurement<>(this, iteration, evaluation,
  120.                                                    new SpacecraftState[] {
  121.                                                        common.getState()
  122.                                                    }, new TimeStampedPVCoordinates[] {
  123.                                                        common.getRemotePV().toTimeStampedPVCoordinates(),
  124.                                                        common.getTransitPV().toTimeStampedPVCoordinates()
  125.                                                    });

  126.         // Range value
  127.         final Gradient range            = common.getTauD().add(common.getLocalOffset()).subtract(common.getRemoteOffset()).
  128.                                           multiply(Constants.SPEED_OF_LIGHT);
  129.         final double[] rangeDerivatives = range.getGradient();

  130.         // Set value and state first order derivatives of the estimated measurement
  131.         estimatedRange.setEstimatedValue(range.getValue());
  132.         estimatedRange.setStateDerivatives(0, Arrays.copyOfRange(rangeDerivatives, 0,  6));

  133.         // Set first order derivatives with respect to parameters
  134.         for (final ParameterDriver measurementDriver : getParametersDrivers()) {
  135.             for (Span<String> span = measurementDriver.getNamesSpanMap().getFirstSpan(); span != null; span = span.next()) {

  136.                 final Integer index = common.getIndices().get(span.getData());
  137.                 if (index != null) {
  138.                     estimatedRange.setParameterDerivatives(measurementDriver, span.getStart(), rangeDerivatives[index]);
  139.                 }
  140.             }
  141.         }

  142.         // Return the estimated measurement
  143.         return estimatedRange;

  144.     }

  145. }