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

  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.propagation.SpacecraftState;
  23. import org.orekit.time.AbsoluteDate;
  24. import org.orekit.time.FieldAbsoluteDate;
  25. import org.orekit.utils.Constants;
  26. import org.orekit.utils.ParameterDriver;
  27. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  28. import org.orekit.utils.TimeStampedPVCoordinates;

  29. /** One-way or two-way range measurements between two satellites.
  30.  * <p>
  31.  * For one-way measurements, a signal is emitted by a remote satellite and received
  32.  * by local satellite. The measurement value is the elapsed time between emission
  33.  * and reception multiplied by c where c is the speed of light.
  34.  * </p>
  35.  * <p>
  36.  * For two-way measurements, a signal is emitted by local satellite, reflected on
  37.  * remote satellite, and received back by local satellite. The measurement value
  38.  * is the elapsed time between emission and reception multiplied by c/2 where c
  39.  * is the speed of light.
  40.  * </p>
  41.  * <p>
  42.  * Since 9.3, this class also uses the clock offsets of both satellites,
  43.  * which manage the value that must be added to each satellite reading of time to
  44.  * compute the real physical date. In this measurement, these offsets have two effects:
  45.  * </p>
  46.  * <ul>
  47.  *   <li>as measurement date is evaluated at reception time, the real physical date
  48.  *   of the measurement is the observed date to which the local satellite clock
  49.  *   offset is subtracted</li>
  50.  *   <li>as range is evaluated using the total signal time of flight, for one-way
  51.  *   measurements the observed range is the real physical signal time of flight to
  52.  *   which (Δtl - Δtr) ⨉ c is added, where Δtl (resp. Δtr) is the clock offset for the
  53.  *   local satellite (resp. remote satellite). A similar effect exists in
  54.  *   two-way measurements but it is computed as (Δtl - Δtl) ⨉ c / 2 as the local satellite
  55.  *   clock is used for both initial emission and final reception and therefore it evaluates
  56.  *   to zero.</li>
  57.  * </ul>
  58.  * <p>
  59.  * The motion of both satellites during the signal flight time is
  60.  * taken into account. The date of the measurement corresponds to
  61.  * the reception of the signal by satellite 1.
  62.  * </p>
  63.  * @author Luc Maisonobe
  64.  * @since 9.0
  65.  */
  66. public class InterSatellitesRange extends AbstractMeasurement<InterSatellitesRange> {

  67.     /** Type of the measurement. */
  68.     public static final String MEASUREMENT_TYPE = "InterSatellitesRange";

  69.     /** Flag indicating whether it is a two-way measurement. */
  70.     private final boolean twoway;

  71.     /** Simple constructor.
  72.      * @param local satellite which receives the signal and performs the measurement
  73.      * @param remote satellite which simply emits the signal in the one-way case,
  74.      * or reflects the signal in the two-way case
  75.      * @param twoWay flag indicating whether it is a two-way measurement
  76.      * @param date date of the measurement
  77.      * @param range observed value
  78.      * @param sigma theoretical standard deviation
  79.      * @param baseWeight base weight
  80.      * @since 9.3
  81.      */
  82.     public InterSatellitesRange(final ObservableSatellite local,
  83.                                 final ObservableSatellite remote,
  84.                                 final boolean twoWay,
  85.                                 final AbsoluteDate date, final double range,
  86.                                 final double sigma, final double baseWeight) {
  87.         super(date, range, sigma, baseWeight, Arrays.asList(local, remote));
  88.         // for one way and two ways measurements, the local satellite clock offsets affects the measurement
  89.         addParameterDriver(local.getClockOffsetDriver());
  90.         if (!twoWay) {
  91.             // for one way measurements, the remote satellite clock offsets also affects the measurement
  92.             addParameterDriver(remote.getClockOffsetDriver());
  93.         }
  94.         this.twoway = twoWay;
  95.     }

  96.     /** Check if the instance represents a two-way measurement.
  97.      * @return true if the instance represents a two-way measurement
  98.      */
  99.     public boolean isTwoWay() {
  100.         return twoway;
  101.     }

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

  107.         // Range derivatives are computed with respect to spacecrafts states in inertial frame
  108.         // ----------------------
  109.         //
  110.         // Parameters:
  111.         //  - 0..2  - Position of the receiver satellite in inertial frame
  112.         //  - 3..5  - Velocity of the receiver satellite in inertial frame
  113.         //  - 6..8  - Position of the remote satellite in inertial frame
  114.         //  - 9..11 - Velocity of the remote satellite in inertial frame
  115.         //  - 12..  - Measurement parameters: local clock offset, remote clock offset...
  116.         int nbParams = 12;
  117.         final Map<String, Integer> indices = new HashMap<>();
  118.         for (ParameterDriver driver : getParametersDrivers()) {
  119.             if (driver.isSelected()) {
  120.                 indices.put(driver.getName(), nbParams++);
  121.             }
  122.         }

  123.         // coordinates of both satellites
  124.         final SpacecraftState local = states[0];
  125.         final TimeStampedFieldPVCoordinates<Gradient> pvaL = getCoordinates(local, 0, nbParams);
  126.         final SpacecraftState remote = states[1];
  127.         final TimeStampedFieldPVCoordinates<Gradient> pvaR = getCoordinates(remote, 6, nbParams);

  128.         // compute propagation times
  129.         // (if state has already been set up to pre-compensate propagation delay,
  130.         //  we will have delta == tauD and transitState will be the same as state)

  131.         // downlink delay
  132.         final Gradient dtl = getSatellites().get(0).getClockOffsetDriver().getValue(nbParams, indices);
  133.         final FieldAbsoluteDate<Gradient> arrivalDate =
  134.                         new FieldAbsoluteDate<>(getDate(), dtl.negate());

  135.         final TimeStampedFieldPVCoordinates<Gradient> s1Downlink =
  136.                         pvaL.shiftedBy(arrivalDate.durationFrom(pvaL.getDate()));
  137.         final Gradient tauD = signalTimeOfFlight(pvaR, s1Downlink.getPosition(), arrivalDate);

  138.         // Transit state
  139.         final double              delta      = getDate().durationFrom(remote.getDate());
  140.         final Gradient deltaMTauD = tauD.negate().add(delta);

  141.         // prepare the evaluation
  142.         final EstimatedMeasurement<InterSatellitesRange> estimated;

  143.         final Gradient range;
  144.         if (twoway) {
  145.             // Transit state (re)computed with derivative structures
  146.             final TimeStampedFieldPVCoordinates<Gradient> transitStateDS = pvaR.shiftedBy(deltaMTauD);

  147.             // uplink delay
  148.             final Gradient tauU = signalTimeOfFlight(pvaL,
  149.                                                      transitStateDS.getPosition(),
  150.                                                      transitStateDS.getDate());
  151.             estimated = new EstimatedMeasurement<>(this, iteration, evaluation,
  152.                                                    new SpacecraftState[] {
  153.                                                        local.shiftedBy(deltaMTauD.getValue()),
  154.                                                        remote.shiftedBy(deltaMTauD.getValue())
  155.                                                    }, new TimeStampedPVCoordinates[] {
  156.                                                        local.shiftedBy(delta - tauD.getValue() - tauU.getValue()).getPVCoordinates(),
  157.                                                        remote.shiftedBy(delta - tauD.getValue()).getPVCoordinates(),
  158.                                                        local.shiftedBy(delta).getPVCoordinates()
  159.                                                    });

  160.             // Range value
  161.             range  = tauD.add(tauU).multiply(0.5 * Constants.SPEED_OF_LIGHT);

  162.         } else {

  163.             estimated = new EstimatedMeasurement<>(this, iteration, evaluation,
  164.                                                    new SpacecraftState[] {
  165.                                                        local.shiftedBy(deltaMTauD.getValue()),
  166.                                                        remote.shiftedBy(deltaMTauD.getValue())
  167.                                                    }, new TimeStampedPVCoordinates[] {
  168.                                                        remote.shiftedBy(delta - tauD.getValue()).getPVCoordinates(),
  169.                                                        local.shiftedBy(delta).getPVCoordinates()
  170.                                                    });

  171.             // Clock offsets
  172.             final Gradient dtr = getSatellites().get(1).getClockOffsetDriver().getValue(nbParams, indices);

  173.             // Range value
  174.             range  = tauD.add(dtl).subtract(dtr).multiply(Constants.SPEED_OF_LIGHT);

  175.         }
  176.         estimated.setEstimatedValue(range.getValue());

  177.         // Range partial derivatives with respect to states
  178.         final double[] derivatives = range.getGradient();
  179.         estimated.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 0,  6));
  180.         estimated.setStateDerivatives(1, Arrays.copyOfRange(derivatives, 6, 12));

  181.         // Set partial derivatives with respect to parameters
  182.         for (final ParameterDriver driver : getParametersDrivers()) {
  183.             final Integer index = indices.get(driver.getName());
  184.             if (index != null) {
  185.                 estimated.setParameterDerivatives(driver, derivatives[index]);
  186.             }
  187.         }

  188.         return estimated;

  189.     }

  190. }