AbstractWindUp.java

  1. /* Copyright 2002-2024 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.      * <p>
  53.      * Wind-up effect has no parameters, the returned list is always empty.
  54.      * </p>
  55.      */
  56.     @Override
  57.     public List<ParameterDriver> getParametersDrivers() {
  58.         return Collections.emptyList();
  59.     }

  60.     /** Compute rotation from emitter to inertial frame.
  61.      * @param estimated estimated measurement to modify
  62.      * @return rotation from emitter to inertial frame
  63.      */
  64.     protected abstract Rotation emitterToInert(EstimatedMeasurementBase<T> estimated);

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

  70.     /** {@inheritDoc} */
  71.     @Override
  72.     public void modifyWithoutDerivatives(final EstimatedMeasurementBase<T> estimated) {

  73.         // signal line of sight
  74.         final TimeStampedPVCoordinates[] participants = estimated.getParticipants();
  75.         final Vector3D los = participants[1].getPosition().subtract(participants[0].getPosition()).normalize();

  76.         // get receiver dipole
  77.         final Rotation receiverToInert = receiverToInert(estimated);
  78.         final Vector3D iReceiver       = receiverToInert.applyTo(receiver.getPrimary());
  79.         final Vector3D jReceiver       = receiverToInert.applyTo(receiver.getSecondary());
  80.         final Vector3D dReceiver       = new Vector3D(1.0, iReceiver, -Vector3D.dotProduct(iReceiver, los), los).
  81.                                          add(Vector3D.crossProduct(los, jReceiver));

  82.         // get emitter dipole
  83.         final Rotation emitterToInert = emitterToInert(estimated);
  84.         final Vector3D iEmitter       = emitterToInert.applyTo(emitter.getPrimary());
  85.         final Vector3D jEmitter       = emitterToInert.applyTo(emitter.getSecondary());
  86.         final Vector3D dEmitter       = new Vector3D(1.0, iEmitter, -Vector3D.dotProduct(iEmitter, los), los).
  87.                                         subtract(Vector3D.crossProduct(los, jEmitter));

  88.         // raw correction
  89.         final double correction = FastMath.copySign(Vector3D.angle(dEmitter, dReceiver),
  90.                                                     Vector3D.dotProduct(los, Vector3D.crossProduct(dEmitter, dReceiver)));

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

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

  97.     }

  98. }