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.         this.twoway = twoWay;
  87.     }

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

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

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

  115.         // coordinates of both satellites
  116.         final SpacecraftState local = states[0];
  117.         final TimeStampedFieldPVCoordinates<Gradient> pvaL = getCoordinates(local, 0, nbParams);
  118.         final SpacecraftState remote = states[1];
  119.         final TimeStampedFieldPVCoordinates<Gradient> pvaR = getCoordinates(remote, 6, nbParams);

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

  123.         // downlink delay
  124.         final Gradient dtl = getSatellites().get(0).getClockOffsetDriver().getValue(nbParams, indices);
  125.         final FieldAbsoluteDate<Gradient> arrivalDate =
  126.                         new FieldAbsoluteDate<>(getDate(), dtl.negate());

  127.         final TimeStampedFieldPVCoordinates<Gradient> s1Downlink =
  128.                         pvaL.shiftedBy(arrivalDate.durationFrom(pvaL.getDate()));
  129.         final Gradient tauD = signalTimeOfFlight(pvaR, s1Downlink.getPosition(), arrivalDate);

  130.         // Transit state
  131.         final double              delta      = getDate().durationFrom(remote.getDate());
  132.         final Gradient deltaMTauD = tauD.negate().add(delta);

  133.         // prepare the evaluation
  134.         final EstimatedMeasurement<InterSatellitesRange> estimated;

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

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

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

  154.         } else {

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

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

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

  167.         }
  168.         estimated.setEstimatedValue(range.getValue());

  169.         // Range partial derivatives with respect to states
  170.         final double[] derivatives = range.getGradient();
  171.         estimated.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 0,  6));
  172.         estimated.setStateDerivatives(1, Arrays.copyOfRange(derivatives, 6, 12));

  173.         return estimated;

  174.     }

  175. }