InterSatellitesRange.java

  1. /* Copyright 2002-2019 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.DSFactory;
  22. import org.hipparchus.analysis.differentiation.DerivativeStructure;
  23. import org.orekit.propagation.SpacecraftState;
  24. import org.orekit.time.AbsoluteDate;
  25. import org.orekit.time.FieldAbsoluteDate;
  26. import org.orekit.utils.Constants;
  27. import org.orekit.utils.ParameterDriver;
  28. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  29. import org.orekit.utils.TimeStampedPVCoordinates;

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

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

  70.     /** Simple constructor.
  71.      * @param localIndex index of local satellite propagator
  72.      * (i.e. the satellite which receives the signal and performs
  73.      * the measurement)
  74.      * @param remoteIndex index of remote satellite propagator
  75.      * (i.e. the satellite which simply emits the signal in the one-way
  76.      * case, or reflects the signal in the two-way case)
  77.      * @param twoWay flag indicating whether it is a two-way measurement
  78.      * @param date date of the measurement
  79.      * @param range observed value
  80.      * @param sigma theoretical standard deviation
  81.      * @param baseWeight base weight
  82.      * @deprecated as of 9.3, replaced by {@link #InterSatellitesRange(ObservableSatellite, ObservableSatellite,
  83.      * boolean, AbsoluteDate, double, double, double)}
  84.      */
  85.     @Deprecated
  86.     public InterSatellitesRange(final int localIndex, final int remoteIndex,
  87.                                 final boolean twoWay,
  88.                                 final AbsoluteDate date, final double range,
  89.                                 final double sigma, final double baseWeight) {
  90.         this(new ObservableSatellite(localIndex), new ObservableSatellite(remoteIndex),
  91.              twoWay, date, range, sigma, baseWeight);
  92.     }

  93.     /** Simple constructor.
  94.      * @param local satellite which receives the signal and performs the measurement
  95.      * @param remote satellite which simply emits the signal in the one-way case,
  96.      * or reflects the signal in the two-way case
  97.      * @param twoWay flag indicating whether it is a two-way measurement
  98.      * @param date date of the measurement
  99.      * @param range observed value
  100.      * @param sigma theoretical standard deviation
  101.      * @param baseWeight base weight
  102.      * @since 9.3
  103.      */
  104.     public InterSatellitesRange(final ObservableSatellite local,
  105.                                 final ObservableSatellite remote,
  106.                                 final boolean twoWay,
  107.                                 final AbsoluteDate date, final double range,
  108.                                 final double sigma, final double baseWeight) {
  109.         super(date, range, sigma, baseWeight, Arrays.asList(local, remote));
  110.         this.twoway = twoWay;
  111.     }

  112.     /** Check if the instance represents a two-way measurement.
  113.      * @return true if the instance represents a two-way measurement
  114.      */
  115.     public boolean isTwoWay() {
  116.         return twoway;
  117.     }

  118.     /** {@inheritDoc} */
  119.     @Override
  120.     protected EstimatedMeasurement<InterSatellitesRange> theoreticalEvaluation(final int iteration,
  121.                                                                                final int evaluation,
  122.                                                                                final SpacecraftState[] states) {

  123.         // Range derivatives are computed with respect to spacecrafts states in inertial frame
  124.         // ----------------------
  125.         //
  126.         // Parameters:
  127.         //  - 0..2  - Position of the receiver satellite in inertial frame
  128.         //  - 3..5  - Velocity of the receiver satellite in inertial frame
  129.         //  - 6..8  - Position of the remote satellite in inertial frame
  130.         //  - 9..11 - Velocity of the remote satellite in inertial frame
  131.         //  - 12..  - Measurement parameters: local clock offset, remote clock offset...
  132.         int nbParams = 12;
  133.         final Map<String, Integer> indices = new HashMap<>();
  134.         for (ParameterDriver driver : getParametersDrivers()) {
  135.             if (driver.isSelected()) {
  136.                 indices.put(driver.getName(), nbParams++);
  137.             }
  138.         }
  139.         final DSFactory factory = new DSFactory(nbParams, 1);

  140.         // coordinates of both satellites
  141.         final ObservableSatellite local = getSatellites().get(0);
  142.         final SpacecraftState stateL = states[local.getPropagatorIndex()];
  143.         final TimeStampedFieldPVCoordinates<DerivativeStructure> pvaL = getCoordinates(stateL, 0, factory);
  144.         final ObservableSatellite remote = getSatellites().get(1);
  145.         final SpacecraftState stateR = states[remote.getPropagatorIndex()];
  146.         final TimeStampedFieldPVCoordinates<DerivativeStructure> pvaR = getCoordinates(stateR, 6, factory);

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

  150.         // downlink delay
  151.         final DerivativeStructure dtl = local.getClockOffsetDriver().getValue(factory, indices);
  152.         final FieldAbsoluteDate<DerivativeStructure> arrivalDate =
  153.                         new FieldAbsoluteDate<DerivativeStructure>(getDate(), dtl.negate());

  154.         final TimeStampedFieldPVCoordinates<DerivativeStructure> s1Downlink =
  155.                         pvaL.shiftedBy(arrivalDate.durationFrom(pvaL.getDate()));
  156.         final DerivativeStructure tauD = signalTimeOfFlight(pvaR, s1Downlink.getPosition(), arrivalDate);

  157.         // Transit state
  158.         final double              delta      = getDate().durationFrom(stateR.getDate());
  159.         final DerivativeStructure deltaMTauD = tauD.negate().add(delta);

  160.         // prepare the evaluation
  161.         final EstimatedMeasurement<InterSatellitesRange> estimated;

  162.         final DerivativeStructure range;
  163.         if (twoway) {
  164.             // Transit state (re)computed with derivative structures
  165.             final TimeStampedFieldPVCoordinates<DerivativeStructure> transitStateDS = pvaR.shiftedBy(deltaMTauD);

  166.             // uplink delay
  167.             final DerivativeStructure tauU = signalTimeOfFlight(pvaL,
  168.                                                                 transitStateDS.getPosition(),
  169.                                                                 transitStateDS.getDate());
  170.             estimated = new EstimatedMeasurement<>(this, iteration, evaluation,
  171.                                                    new SpacecraftState[] {
  172.                                                        stateL.shiftedBy(deltaMTauD.getValue()),
  173.                                                        stateR.shiftedBy(deltaMTauD.getValue())
  174.                                                    }, new TimeStampedPVCoordinates[] {
  175.                                                        stateL.shiftedBy(delta - tauD.getValue() - tauU.getValue()).getPVCoordinates(),
  176.                                                        stateR.shiftedBy(delta - tauD.getValue()).getPVCoordinates(),
  177.                                                        stateL.shiftedBy(delta).getPVCoordinates()
  178.                                                    });

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

  181.         } else {

  182.             estimated = new EstimatedMeasurement<>(this, iteration, evaluation,
  183.                                                    new SpacecraftState[] {
  184.                                                        stateL.shiftedBy(deltaMTauD.getValue()),
  185.                                                        stateR.shiftedBy(deltaMTauD.getValue())
  186.                                                    }, new TimeStampedPVCoordinates[] {
  187.                                                        stateR.shiftedBy(delta - tauD.getValue()).getPVCoordinates(),
  188.                                                        stateL.shiftedBy(delta).getPVCoordinates()
  189.                                                    });

  190.             // Clock offsets
  191.             final DerivativeStructure dtr = remote.getClockOffsetDriver().getValue(factory, indices);

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

  194.         }
  195.         estimated.setEstimatedValue(range.getValue());

  196.         // Range partial derivatives with respect to states
  197.         final double[] derivatives = range.getAllDerivatives();
  198.         estimated.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 1,  7));
  199.         estimated.setStateDerivatives(1, Arrays.copyOfRange(derivatives, 7, 13));

  200.         return estimated;

  201.     }

  202. }