AbstractWindUp.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.gnss;

  18. import java.util.Collections;
  19. import java.util.List;

  20. import org.hipparchus.geometry.euclidean.threed.Rotation;
  21. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  22. import org.hipparchus.util.FastMath;
  23. import org.hipparchus.util.MathUtils;
  24. import org.orekit.estimation.measurements.EstimatedMeasurementBase;
  25. import org.orekit.estimation.measurements.EstimationModifier;
  26. import org.orekit.estimation.measurements.ObservedMeasurement;
  27. import org.orekit.utils.ParameterDriver;
  28. import org.orekit.utils.TimeStampedPVCoordinates;

  29. /** Base class for wind-up effect computation.
  30.  * @see <a href="https://gssc.esa.int/navipedia/index.php/Carrier_Phase_Wind-up_Effect">Carrier Phase Wind-up Effect</a>
  31.  * @param <T> the type of the measurement
  32.  * @author Luc Maisonobe
  33.  * @since 12.0
  34.  */
  35. public abstract class AbstractWindUp<T extends ObservedMeasurement<T>> implements EstimationModifier<T> {

  36.     /** Emitter dipole. */
  37.     private final Dipole emitter;

  38.     /** Receiver dipole. */
  39.     private final Dipole receiver;

  40.     /** Cached angular value of wind-up. */
  41.     private double angularWindUp;

  42.     /** Simple constructor.
  43.      * @param emitter emitter dipole
  44.      * @param receiver receiver dipole
  45.      */
  46.     protected AbstractWindUp(final Dipole emitter, final Dipole receiver) {
  47.         this.emitter  = emitter;
  48.         this.receiver = receiver;
  49.         angularWindUp = 0.0;
  50.     }

  51.     /** {@inheritDoc} */
  52.     @Override
  53.     public String getEffectName() {
  54.         return "wind-up";
  55.     }

  56.     /** {@inheritDoc}
  57.      * <p>
  58.      * Wind-up effect has no parameters, the returned list is always empty.
  59.      * </p>
  60.      */
  61.     @Override
  62.     public List<ParameterDriver> getParametersDrivers() {
  63.         return Collections.emptyList();
  64.     }

  65.     /** Compute rotation from emitter to inertial frame.
  66.      * @param estimated estimated measurement to modify
  67.      * @return rotation from emitter to inertial frame
  68.      */
  69.     protected abstract Rotation emitterToInert(EstimatedMeasurementBase<T> estimated);

  70.     /** Compute rotation from receiver to inertial frame.
  71.      * @param estimated estimated measurement to modify
  72.      * @return rotation from receiver to inertial frame
  73.      */
  74.     protected abstract Rotation receiverToInert(EstimatedMeasurementBase<T> estimated);

  75.     /** Cache angular wind-up.
  76.      * @param participants particpants to the carrier-phase measurement
  77.      * @param receiverToInert rotation for receiver to inertial frame
  78.      * @param emitterToInert rotation from emitter to inertial frame
  79.      * @since 13.0
  80.      */
  81.     public void cacheAngularWindUp(final TimeStampedPVCoordinates[] participants,
  82.                                    final Rotation receiverToInert, final Rotation emitterToInert) {

  83.         // signal line of sight
  84.         final Vector3D los = participants[1].getPosition().subtract(participants[0].getPosition()).normalize();

  85.         // get receiver dipole
  86.         final Vector3D iReceiver       = receiverToInert.applyTo(receiver.getPrimary());
  87.         final Vector3D jReceiver       = receiverToInert.applyTo(receiver.getSecondary());
  88.         final Vector3D dReceiver       = new Vector3D(1.0, iReceiver, -Vector3D.dotProduct(iReceiver, los), los).
  89.                                          add(Vector3D.crossProduct(los, jReceiver));

  90.         // get emitter dipole
  91.         final Vector3D iEmitter       = emitterToInert.applyTo(emitter.getPrimary());
  92.         final Vector3D jEmitter       = emitterToInert.applyTo(emitter.getSecondary());
  93.         final Vector3D dEmitter       = new Vector3D(1.0, iEmitter, -Vector3D.dotProduct(iEmitter, los), los).
  94.                                         subtract(Vector3D.crossProduct(los, jEmitter));

  95.         // raw correction
  96.         final double correction = FastMath.copySign(Vector3D.angle(dEmitter, dReceiver),
  97.                                                     Vector3D.dotProduct(los, Vector3D.crossProduct(dEmitter, dReceiver)));

  98.         // ensure continuity across measurements
  99.         // we assume the various measurements are close enough in time
  100.         // (less the one satellite half-turn) so the angles remain close
  101.         angularWindUp = MathUtils.normalizeAngle(correction, angularWindUp);

  102.     }

  103.     /** Get cached value of angular wind-up.
  104.      * @return cached value of angular wind-up
  105.      * @since 13.0
  106.      */
  107.     public double getAngularWindUp() {
  108.         return angularWindUp;
  109.     }

  110.     /** {@inheritDoc} */
  111.     @Override
  112.     public void modifyWithoutDerivatives(final EstimatedMeasurementBase<T> estimated) {

  113.         // cache new angular wind-up
  114.         final TimeStampedPVCoordinates[] participants = estimated.getParticipants();
  115.         final Rotation receiverToInert = receiverToInert(estimated);
  116.         final Rotation emitterToInert = emitterToInert(estimated);
  117.         cacheAngularWindUp(participants, receiverToInert, emitterToInert);

  118.         // update estimate
  119.         estimated.modifyEstimatedValue(this, estimated.getEstimatedValue()[0] + angularWindUp / MathUtils.TWO_PI);

  120.     }

  121. }