TurnAroundRange.java

  1. /* Copyright 2002-2025 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.Field;
  22. import org.hipparchus.analysis.differentiation.Gradient;
  23. import org.hipparchus.analysis.differentiation.GradientField;
  24. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  25. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  26. import org.orekit.frames.FieldTransform;
  27. import org.orekit.frames.Transform;
  28. import org.orekit.propagation.SpacecraftState;
  29. import org.orekit.time.AbsoluteDate;
  30. import org.orekit.time.FieldAbsoluteDate;
  31. import org.orekit.utils.Constants;
  32. import org.orekit.utils.FieldPVCoordinates;
  33. import org.orekit.utils.PVCoordinates;
  34. import org.orekit.utils.ParameterDriver;
  35. import org.orekit.utils.TimeSpanMap.Span;
  36. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  37. import org.orekit.utils.TimeStampedPVCoordinates;

  38. /** Class modeling a turn-around range measurement using a primary ground station and a secondary ground station.
  39.  * <p>
  40.  * The measurement is considered to be a signal:
  41.  * - Emitted from the primary ground station
  42.  * - Reflected on the spacecraft
  43.  * - Reflected on the secondary ground station
  44.  * - Reflected on the spacecraft again
  45.  * - Received on the primary ground station
  46.  * Its value is the elapsed time between emission and reception
  47.  * divided by 2c were c is the speed of light.
  48.  * The motion of the stations and the spacecraft
  49.  * during the signal flight time are taken into account.
  50.  * The date of the measurement corresponds to the
  51.  * reception on ground of the reflected signal.
  52.  * </p>
  53.  * @author Thierry Ceolin
  54.  * @author Luc Maisonobe
  55.  * @author Maxime Journot
  56.  *
  57.  * @since 9.0
  58.  */
  59. public class TurnAroundRange extends GroundReceiverMeasurement<TurnAroundRange> {

  60.     /** Type of the measurement. */
  61.     public static final String MEASUREMENT_TYPE = "TurnAroundRange";

  62.     /** Secondary ground station reflecting the signal. */
  63.     private final GroundStation secondaryStation;

  64.     /** Simple constructor.
  65.      * @param primaryStation ground station from which measurement is performed
  66.      * @param secondaryStation ground station reflecting the signal
  67.      * @param date date of the measurement
  68.      * @param turnAroundRange observed value
  69.      * @param sigma theoretical standard deviation
  70.      * @param baseWeight base weight
  71.      * @param satellite satellite related to this measurement
  72.      * @since 9.3
  73.      */
  74.     public TurnAroundRange(final GroundStation primaryStation, final GroundStation secondaryStation,
  75.                            final AbsoluteDate date, final double turnAroundRange,
  76.                            final double sigma, final double baseWeight,
  77.                            final ObservableSatellite satellite) {
  78.         super(primaryStation, true, date, turnAroundRange, sigma, baseWeight, satellite);

  79.         // the secondary station clock is not used at all, we ignore the corresponding parameter driver
  80.         addParameterDriver(secondaryStation.getEastOffsetDriver());
  81.         addParameterDriver(secondaryStation.getNorthOffsetDriver());
  82.         addParameterDriver(secondaryStation.getZenithOffsetDriver());
  83.         addParameterDriver(secondaryStation.getPrimeMeridianOffsetDriver());
  84.         addParameterDriver(secondaryStation.getPrimeMeridianDriftDriver());
  85.         addParameterDriver(secondaryStation.getPolarOffsetXDriver());
  86.         addParameterDriver(secondaryStation.getPolarDriftXDriver());
  87.         addParameterDriver(secondaryStation.getPolarOffsetYDriver());
  88.         addParameterDriver(secondaryStation.getPolarDriftYDriver());
  89.         this.secondaryStation = secondaryStation;

  90.     }

  91.     /** Get the primary ground station from which measurement is performed.
  92.      * @return primary ground station from which measurement is performed
  93.      */
  94.     public GroundStation getPrimaryStation() {
  95.         return getStation();
  96.     }

  97.     /** Get the secondary ground station reflecting the signal.
  98.      * @return secondary ground station reflecting the signal
  99.      */
  100.     public GroundStation getSecondaryStation() {
  101.         return secondaryStation;
  102.     }

  103.     /** {@inheritDoc} */
  104.     @Override
  105.     protected EstimatedMeasurementBase<TurnAroundRange> theoreticalEvaluationWithoutDerivatives(final int iteration,
  106.                                                                                                 final int evaluation,
  107.                                                                                                 final SpacecraftState[] states) {

  108.         final SpacecraftState state = states[0];

  109.         // Time-stamped PV
  110.         final TimeStampedPVCoordinates pva = state.getPVCoordinates();

  111.         // The path of the signal is divided in two legs.
  112.         // Leg1: Emission from primary station to satellite in primaryTauU seconds
  113.         //     + Reflection from satellite to secondary station in secondaryTauD seconds
  114.         // Leg2: Reflection from secondary station to satellite in secondaryTauU seconds
  115.         //     + Reflection from satellite to primary station in primaryTaudD seconds
  116.         // The measurement is considered to be time stamped at reception on ground
  117.         // by the primary station. All times are therefore computed as backward offsets
  118.         // with respect to this reception time.
  119.         //
  120.         // Two intermediate spacecraft states are defined:
  121.         //  - transitStateLeg2: State of the satellite when it bounced back the signal
  122.         //                      from secondary station to primary station during the 2nd leg
  123.         //  - transitStateLeg1: State of the satellite when it bounced back the signal
  124.         //                      from primary station to secondary station during the 1st leg

  125.         // Compute propagation time for the 2nd leg of the signal path
  126.         // --

  127.         // Time difference between t (date of the measurement) and t' (date tagged in spacecraft state)
  128.         // (if state has already been set up to pre-compensate propagation delay,
  129.         // we will have delta = primaryTauD + secondaryTauU)
  130.         final double delta = getDate().durationFrom(state.getDate());

  131.         // transform between primary station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  132.         final Transform primaryToInert =
  133.                         getStation().getOffsetToInertial(state.getFrame(), getDate(), false);
  134.         final AbsoluteDate measurementDate = primaryToInert.getDate();

  135.         // Primary station PV in inertial frame at measurement date
  136.         final TimeStampedPVCoordinates primaryArrival =
  137.                         primaryToInert.transformPVCoordinates(new TimeStampedPVCoordinates(measurementDate,
  138.                                                                                            Vector3D.ZERO, Vector3D.ZERO, Vector3D.ZERO));

  139.         // Compute propagation times
  140.         final double primaryTauD = signalTimeOfFlightAdjustableEmitter(pva, primaryArrival.getPosition(), measurementDate,
  141.                                                                        state.getFrame());

  142.         // Elapsed time between state date t' and signal arrival to the transit state of the 2nd leg
  143.         final double dtLeg2 = delta - primaryTauD;

  144.         // Transit state where the satellite reflected the signal from secondary to primary station
  145.         final SpacecraftState transitStateLeg2 = state.shiftedBy(dtLeg2);

  146.         // Transit state pv of leg2 (re)computed with gradient
  147.         final TimeStampedPVCoordinates transitStateLeg2PV = pva.shiftedBy(dtLeg2);

  148.         // transform between secondary station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  149.         // The components of secondary station's position in offset frame are the 3 last derivative parameters
  150.         final AbsoluteDate approxReboundDate = measurementDate.shiftedBy(-delta);
  151.         final Transform secondaryToInertApprox =
  152.                         secondaryStation.getOffsetToInertial(state.getFrame(), approxReboundDate, true);

  153.         // Secondary station PV in inertial frame at approximate rebound date on secondary station
  154.         final TimeStampedPVCoordinates QSecondaryApprox =
  155.                         secondaryToInertApprox.transformPVCoordinates(new TimeStampedPVCoordinates(approxReboundDate,
  156.                                                                                                    Vector3D.ZERO, Vector3D.ZERO, Vector3D.ZERO));

  157.         // Uplink time of flight from secondary station to transit state of leg2
  158.         final double secondaryTauU = signalTimeOfFlightAdjustableEmitter(QSecondaryApprox,
  159.                                                                          transitStateLeg2PV.getPosition(),
  160.                                                                          transitStateLeg2PV.getDate(),
  161.                                                                          state.getFrame());

  162.         // Total time of flight for leg 2
  163.         final double tauLeg2 = primaryTauD + secondaryTauU;

  164.         // Compute propagation time for the 1st leg of the signal path
  165.         // --

  166.         // Absolute date of rebound of the signal to secondary station
  167.         final AbsoluteDate reboundDate   = measurementDate.shiftedBy(-tauLeg2);
  168.         final Transform secondaryToInert = secondaryStation.getOffsetToInertial(state.getFrame(), reboundDate, true);

  169.         // Secondary station PV in inertial frame at rebound date on secondary station
  170.         final TimeStampedPVCoordinates secondaryRebound =
  171.                         secondaryToInert.transformPVCoordinates(new TimeStampedPVCoordinates(reboundDate,
  172.                                                                                              Vector3D.ZERO, Vector3D.ZERO, Vector3D.ZERO));

  173.         // Downlink time of flight from transitStateLeg1 to secondary station at rebound date
  174.         final double secondaryTauD = signalTimeOfFlightAdjustableEmitter(transitStateLeg2PV,
  175.                                                                          secondaryRebound.getPosition(),
  176.                                                                          reboundDate,
  177.                                                                          state.getFrame());


  178.         // Elapsed time between state date t' and signal arrival to the transit state of the 1st leg
  179.         final double dtLeg1 = dtLeg2 - secondaryTauU - secondaryTauD;

  180.         // Transit state pv of leg2 (re)computed
  181.         final TimeStampedPVCoordinates transitStateLeg1PV = pva.shiftedBy(dtLeg1);

  182.         // transform between primary station topocentric frame (east-north-zenith) and inertial frame
  183.         final AbsoluteDate approxEmissionDate = measurementDate.shiftedBy(-2 * (secondaryTauU + primaryTauD));
  184.         final Transform primaryToInertApprox  = getStation().getOffsetToInertial(state.getFrame(), approxEmissionDate, true);

  185.         // Primary station PV in inertial frame at approximate emission date
  186.         final TimeStampedPVCoordinates QPrimaryApprox =
  187.                         primaryToInertApprox.transformPVCoordinates(new TimeStampedPVCoordinates(approxEmissionDate,
  188.                                                                                                  Vector3D.ZERO, Vector3D.ZERO, Vector3D.ZERO));

  189.         // Uplink time of flight from primary station to transit state of leg1
  190.         final double primaryTauU = signalTimeOfFlightAdjustableEmitter(QPrimaryApprox,
  191.                                                                        transitStateLeg1PV.getPosition(),
  192.                                                                        transitStateLeg1PV.getDate(),
  193.                                                                        state.getFrame());

  194.         // Primary station PV in inertial frame at exact emission date
  195.         final AbsoluteDate emissionDate = transitStateLeg1PV.getDate().shiftedBy(-primaryTauU);
  196.         final TimeStampedPVCoordinates primaryDeparture =
  197.                         primaryToInertApprox.shiftedBy(emissionDate.durationFrom(primaryToInertApprox.getDate())).
  198.                         transformPVCoordinates(new TimeStampedPVCoordinates(emissionDate, PVCoordinates.ZERO));

  199.         // Total time of flight for leg 1
  200.         final double tauLeg1 = secondaryTauD + primaryTauU;


  201.         // --
  202.         // Evaluate the turn-around range value and its derivatives
  203.         // --------------------------------------------------------

  204.         // The state we use to define the estimated measurement is a middle ground between the two transit states
  205.         // This is done to avoid calling "SpacecraftState.shiftedBy" function on long duration
  206.         // Thus we define the state at the date t" = date of rebound of the signal at the secondary station
  207.         // Or t" = t -primaryTauD -secondaryTauU
  208.         // The iterative process in the estimation ensures that, after several iterations, the date stamped in the
  209.         // state S in input of this function will be close to t"
  210.         // Therefore we will shift state S by:
  211.         //  - +secondaryTauU to get transitStateLeg2
  212.         //  - -secondaryTauD to get transitStateLeg1
  213.         final EstimatedMeasurementBase<TurnAroundRange> estimated =
  214.                         new EstimatedMeasurementBase<>(this, iteration, evaluation,
  215.                                                    new SpacecraftState[] {
  216.                                                        transitStateLeg2.shiftedBy(-secondaryTauU)
  217.                                                    },
  218.                                                    new TimeStampedPVCoordinates[] {
  219.                                                        primaryDeparture,
  220.                                                        transitStateLeg1PV,
  221.                                                        secondaryRebound,
  222.                                                        transitStateLeg2.getPVCoordinates(),
  223.                                                        primaryArrival
  224.                                                    });

  225.         // Turn-around range value = Total time of flight for the 2 legs divided by 2 and multiplied by c
  226.         final double cOver2 = 0.5 * Constants.SPEED_OF_LIGHT;
  227.         final double turnAroundRange = (tauLeg2 + tauLeg1) * cOver2;
  228.         estimated.setEstimatedValue(turnAroundRange);

  229.         return estimated;

  230.     }

  231.     /** {@inheritDoc} */
  232.     @Override
  233.     protected EstimatedMeasurement<TurnAroundRange> theoreticalEvaluation(final int iteration, final int evaluation,
  234.                                                                           final SpacecraftState[] states) {

  235.         final SpacecraftState state = states[0];

  236.         // Turn around range derivatives are computed with respect to:
  237.         // - Spacecraft state in inertial frame
  238.         // - Primary station parameters
  239.         // - Secondary station parameters
  240.         // --------------------------
  241.         //
  242.         //  - 0..2 - Position of the spacecraft in inertial frame
  243.         //  - 3..5 - Velocity of the spacecraft in inertial frame
  244.         //  - 6..n - stations' parameters (clock offset, station offsets, pole, prime meridian...)
  245.         int nbParams = 6;
  246.         final Map<String, Integer> indices = new HashMap<>();
  247.         for (ParameterDriver driver : getParametersDrivers()) {
  248.             // we have to check for duplicate keys because primary and secondary station share
  249.             // pole and prime meridian parameters names that must be considered
  250.             // as one set only (they are combined together by the estimation engine)
  251.             if (driver.isSelected()) {
  252.                 for (Span<String> span = driver.getNamesSpanMap().getFirstSpan(); span != null; span = span.next()) {

  253.                     if (!indices.containsKey(span.getData())) {
  254.                         indices.put(span.getData(), nbParams++);
  255.                     }
  256.                 }
  257.             }
  258.         }
  259.         final Field<Gradient>         field   = GradientField.getField(nbParams);
  260.         final FieldVector3D<Gradient> zero    = FieldVector3D.getZero(field);

  261.         // Place the gradient in a time-stamped PV
  262.         final TimeStampedFieldPVCoordinates<Gradient> pvaDS = getCoordinates(state, 0, nbParams);

  263.         // The path of the signal is divided in two legs.
  264.         // Leg1: Emission from primary station to satellite in primaryTauU seconds
  265.         //     + Reflection from satellite to secondary station in secondaryTauD seconds
  266.         // Leg2: Reflection from secondary station to satellite in secondaryTauU seconds
  267.         //     + Reflection from satellite to primary station in primaryTaudD seconds
  268.         // The measurement is considered to be time stamped at reception on ground
  269.         // by the primary station. All times are therefore computed as backward offsets
  270.         // with respect to this reception time.
  271.         //
  272.         // Two intermediate spacecraft states are defined:
  273.         //  - transitStateLeg2: State of the satellite when it bounced back the signal
  274.         //                      from secondary station to primary station during the 2nd leg
  275.         //  - transitStateLeg1: State of the satellite when it bounced back the signal
  276.         //                      from primary station to secondary station during the 1st leg

  277.         // Compute propagation time for the 2nd leg of the signal path
  278.         // --

  279.         // Time difference between t (date of the measurement) and t' (date tagged in spacecraft state)
  280.         // (if state has already been set up to pre-compensate propagation delay,
  281.         // we will have delta = primaryTauD + secondaryTauU)
  282.         final double delta = getDate().durationFrom(state.getDate());

  283.         // transform between primary station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  284.         final FieldTransform<Gradient> primaryToInert =
  285.                         getStation().getOffsetToInertial(state.getFrame(), getDate(), nbParams, indices);
  286.         final FieldAbsoluteDate<Gradient> measurementDateDS = primaryToInert.getFieldDate();

  287.         // Primary station PV in inertial frame at measurement date
  288.         final TimeStampedFieldPVCoordinates<Gradient> primaryArrival =
  289.                         primaryToInert.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(measurementDateDS,
  290.                                                                                                   zero, zero, zero));

  291.         // Compute propagation times
  292.         final Gradient primaryTauD = signalTimeOfFlightAdjustableEmitter(pvaDS, primaryArrival.getPosition(),
  293.                                                                          measurementDateDS, state.getFrame());

  294.         // Elapsed time between state date t' and signal arrival to the transit state of the 2nd leg
  295.         final Gradient dtLeg2 = primaryTauD.negate().add(delta);

  296.         // Transit state where the satellite reflected the signal from secondary to primary station
  297.         final SpacecraftState transitStateLeg2 = state.shiftedBy(dtLeg2.getValue());

  298.         // Transit state pv of leg2 (re)computed with gradient
  299.         final TimeStampedFieldPVCoordinates<Gradient> transitStateLeg2PV = pvaDS.shiftedBy(dtLeg2);

  300.         // transform between secondary station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  301.         // The components of secondary station's position in offset frame are the 3 last derivative parameters
  302.         final FieldAbsoluteDate<Gradient> approxReboundDate = measurementDateDS.shiftedBy(-delta);
  303.         final FieldTransform<Gradient> secondaryToInertApprox =
  304.                         secondaryStation.getOffsetToInertial(state.getFrame(), approxReboundDate, nbParams, indices);

  305.         // Secondary station PV in inertial frame at approximate rebound date on secondary station
  306.         final TimeStampedFieldPVCoordinates<Gradient> QSecondaryApprox =
  307.                         secondaryToInertApprox.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(approxReboundDate,
  308.                                                                                                           zero, zero, zero));

  309.         // Uplink time of flight from secondary station to transit state of leg2
  310.         final Gradient secondaryTauU = signalTimeOfFlightAdjustableEmitter(QSecondaryApprox,
  311.                                                                            transitStateLeg2PV.getPosition(),
  312.                                                                            transitStateLeg2PV.getDate(),
  313.                                                                            state.getFrame());

  314.         // Total time of flight for leg 2
  315.         final Gradient tauLeg2 = primaryTauD.add(secondaryTauU);

  316.         // Compute propagation time for the 1st leg of the signal path
  317.         // --

  318.         // Absolute date of rebound of the signal to secondary station
  319.         final FieldAbsoluteDate<Gradient> reboundDateDS = measurementDateDS.shiftedBy(tauLeg2.negate());
  320.         final FieldTransform<Gradient> secondaryToInert =
  321.                         secondaryStation.getOffsetToInertial(state.getFrame(), reboundDateDS, nbParams, indices);

  322.         // Secondary station PV in inertial frame at rebound date on secondary station
  323.         final TimeStampedFieldPVCoordinates<Gradient> secondaryRebound =
  324.                         secondaryToInert.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(reboundDateDS,
  325.                                                                                                     FieldPVCoordinates.getZero(field)));

  326.         // Downlink time of flight from transitStateLeg1 to secondary station at rebound date
  327.         final Gradient secondaryTauD = signalTimeOfFlightAdjustableEmitter(transitStateLeg2PV,
  328.                                                                            secondaryRebound.getPosition(),
  329.                                                                            reboundDateDS,
  330.                                                                            state.getFrame());


  331.         // Elapsed time between state date t' and signal arrival to the transit state of the 1st leg
  332.         final Gradient dtLeg1 = dtLeg2.subtract(secondaryTauU).subtract(secondaryTauD);

  333.         // Transit state pv of leg2 (re)computed with gradients
  334.         final TimeStampedFieldPVCoordinates<Gradient> transitStateLeg1PV = pvaDS.shiftedBy(dtLeg1);

  335.         // transform between primary station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  336.         // The components of primary station's position in offset frame are the 3 third derivative parameters
  337.         final FieldAbsoluteDate<Gradient> approxEmissionDate =
  338.                         measurementDateDS.shiftedBy(-2 * (secondaryTauU.getValue() + primaryTauD.getValue()));
  339.         final FieldTransform<Gradient> primaryToInertApprox =
  340.                         getStation().getOffsetToInertial(state.getFrame(), approxEmissionDate, nbParams, indices);

  341.         // Primary station PV in inertial frame at approximate emission date
  342.         final TimeStampedFieldPVCoordinates<Gradient> QPrimaryApprox =
  343.                         primaryToInertApprox.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(approxEmissionDate,
  344.                                                                                                         zero, zero, zero));

  345.         // Uplink time of flight from primary station to transit state of leg1
  346.         final Gradient primaryTauU = signalTimeOfFlightAdjustableEmitter(QPrimaryApprox,
  347.                                                                          transitStateLeg1PV.getPosition(),
  348.                                                                          transitStateLeg1PV.getDate(),
  349.                                                                          state.getFrame());

  350.         // Primary station PV in inertial frame at exact emission date
  351.         final AbsoluteDate emissionDate = transitStateLeg1PV.getDate().toAbsoluteDate().shiftedBy(-primaryTauU.getValue());
  352.         final TimeStampedPVCoordinates primaryDeparture =
  353.                         primaryToInertApprox.shiftedBy(emissionDate.durationFrom(primaryToInertApprox.getDate())).
  354.                         transformPVCoordinates(new TimeStampedPVCoordinates(emissionDate, PVCoordinates.ZERO)).
  355.                         toTimeStampedPVCoordinates();

  356.         // Total time of flight for leg 1
  357.         final Gradient tauLeg1 = secondaryTauD.add(primaryTauU);


  358.         // --
  359.         // Evaluate the turn-around range value and its derivatives
  360.         // --------------------------------------------------------

  361.         // The state we use to define the estimated measurement is a middle ground between the two transit states
  362.         // This is done to avoid calling "SpacecraftState.shiftedBy" function on long duration
  363.         // Thus we define the state at the date t" = date of rebound of the signal at the secondary station
  364.         // Or t" = t -primaryTauD -secondaryTauU
  365.         // The iterative process in the estimation ensures that, after several iterations, the date stamped in the
  366.         // state S in input of this function will be close to t"
  367.         // Therefore we will shift state S by:
  368.         //  - +secondaryTauU to get transitStateLeg2
  369.         //  - -secondaryTauD to get transitStateLeg1
  370.         final EstimatedMeasurement<TurnAroundRange> estimated =
  371.                         new EstimatedMeasurement<>(this, iteration, evaluation,
  372.                                                    new SpacecraftState[] {
  373.                                                        transitStateLeg2.shiftedBy(-secondaryTauU.getValue())
  374.                                                    },
  375.                                                    new TimeStampedPVCoordinates[] {
  376.                                                        primaryDeparture,
  377.                                                        transitStateLeg1PV.toTimeStampedPVCoordinates(),
  378.                                                        secondaryRebound.toTimeStampedPVCoordinates(),
  379.                                                        transitStateLeg2.getPVCoordinates(),
  380.                                                        primaryArrival.toTimeStampedPVCoordinates()
  381.                                                    });

  382.         // Turn-around range value = Total time of flight for the 2 legs divided by 2 and multiplied by c
  383.         final double cOver2 = 0.5 * Constants.SPEED_OF_LIGHT;
  384.         final Gradient turnAroundRange = (tauLeg2.add(tauLeg1)).multiply(cOver2);
  385.         estimated.setEstimatedValue(turnAroundRange.getValue());

  386.         // Turn-around range first order derivatives with respect to state
  387.         final double[] derivatives = turnAroundRange.getGradient();
  388.         estimated.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 0, 6));

  389.         // Set first order derivatives with respect to parameters
  390.         for (final ParameterDriver driver : getParametersDrivers()) {
  391.             for (Span<String> span = driver.getNamesSpanMap().getFirstSpan(); span != null; span = span.next()) {
  392.                 final Integer index = indices.get(span.getData());
  393.                 if (index != null) {
  394.                     estimated.setParameterDerivatives(driver, span.getStart(), derivatives[index]);
  395.                 }
  396.             }
  397.         }

  398.         return estimated;

  399.     }

  400. }