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.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 local satellite which receives the signal and performs the measurement
  72.      * @param remote satellite which simply emits the signal in the one-way case,
  73.      * or reflects the signal in the two-way case
  74.      * @param twoWay flag indicating whether it is a two-way measurement
  75.      * @param date date of the measurement
  76.      * @param range observed value
  77.      * @param sigma theoretical standard deviation
  78.      * @param baseWeight base weight
  79.      * @since 9.3
  80.      */
  81.     public InterSatellitesRange(final ObservableSatellite local,
  82.                                 final ObservableSatellite remote,
  83.                                 final boolean twoWay,
  84.                                 final AbsoluteDate date, final double range,
  85.                                 final double sigma, final double baseWeight) {
  86.         super(date, range, sigma, baseWeight, Arrays.asList(local, remote));
  87.         this.twoway = twoWay;
  88.     }

  89.     /** Check if the instance represents a two-way measurement.
  90.      * @return true if the instance represents a two-way measurement
  91.      */
  92.     public boolean isTwoWay() {
  93.         return twoway;
  94.     }

  95.     /** {@inheritDoc} */
  96.     @Override
  97.     protected EstimatedMeasurement<InterSatellitesRange> theoreticalEvaluation(final int iteration,
  98.                                                                                final int evaluation,
  99.                                                                                final SpacecraftState[] states) {

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

  117.         // coordinates of both satellites
  118.         final SpacecraftState local = states[0];
  119.         final TimeStampedFieldPVCoordinates<DerivativeStructure> pvaL = getCoordinates(local, 0, factory);
  120.         final SpacecraftState remote = states[1];
  121.         final TimeStampedFieldPVCoordinates<DerivativeStructure> pvaR = getCoordinates(remote, 6, factory);

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

  125.         // downlink delay
  126.         final DerivativeStructure dtl = getSatellites().get(0).getClockOffsetDriver().getValue(factory, indices);
  127.         final FieldAbsoluteDate<DerivativeStructure> arrivalDate =
  128.                         new FieldAbsoluteDate<DerivativeStructure>(getDate(), dtl.negate());

  129.         final TimeStampedFieldPVCoordinates<DerivativeStructure> s1Downlink =
  130.                         pvaL.shiftedBy(arrivalDate.durationFrom(pvaL.getDate()));
  131.         final DerivativeStructure tauD = signalTimeOfFlight(pvaR, s1Downlink.getPosition(), arrivalDate);

  132.         // Transit state
  133.         final double              delta      = getDate().durationFrom(remote.getDate());
  134.         final DerivativeStructure deltaMTauD = tauD.negate().add(delta);

  135.         // prepare the evaluation
  136.         final EstimatedMeasurement<InterSatellitesRange> estimated;

  137.         final DerivativeStructure range;
  138.         if (twoway) {
  139.             // Transit state (re)computed with derivative structures
  140.             final TimeStampedFieldPVCoordinates<DerivativeStructure> transitStateDS = pvaR.shiftedBy(deltaMTauD);

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

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

  156.         } else {

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

  165.             // Clock offsets
  166.             final DerivativeStructure dtr = getSatellites().get(1).getClockOffsetDriver().getValue(factory, indices);

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

  169.         }
  170.         estimated.setEstimatedValue(range.getValue());

  171.         // Range partial derivatives with respect to states
  172.         final double[] derivatives = range.getAllDerivatives();
  173.         estimated.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 1,  7));
  174.         estimated.setStateDerivatives(1, Arrays.copyOfRange(derivatives, 7, 13));

  175.         return estimated;

  176.     }

  177. }