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

  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.     /** Flag indicating whether it is a two-way measurement. */
  68.     private final boolean twoway;

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

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

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

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

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

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

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

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

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

  139.         // prepare the evaluation
  140.         final EstimatedMeasurement<InterSatellitesRange> estimated;

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

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

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

  160.         } else {

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

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

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

  173.         }
  174.         estimated.setEstimatedValue(range.getValue());

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

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

  186.         return estimated;

  187.     }

  188. }