WindUp.java

  1. /* Copyright 2002-2022 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.EstimatedMeasurement;
  25. import org.orekit.estimation.measurements.EstimationModifier;
  26. import org.orekit.estimation.measurements.GroundStation;
  27. import org.orekit.frames.Frame;
  28. import org.orekit.utils.ParameterDriver;
  29. import org.orekit.utils.TimeStampedPVCoordinates;

  30. /** Modifier for wind-up effect in GNSS {@link Phase phase measurements}.
  31.  * @see <a href="https://gssc.esa.int/navipedia/index.php/Carrier_Phase_Wind-up_Effect">Carrier Phase Wind-up Effect</a>
  32.  * @see WindUpFactory
  33.  * @author Luc Maisonobe
  34.  * @since 10.1
  35.  */
  36. public class WindUp implements EstimationModifier<Phase> {

  37.     /** Cached angular value of wind-up. */
  38.     private double angularWindUp;

  39.     /** Simple constructor.
  40.      * <p>
  41.      * The constructor is package protected to enforce use of {@link WindUpFactory}
  42.      * and preserve phase continuity for successive measurements involving the same
  43.      * satellite/receiver pair.
  44.      * </p>
  45.      */
  46.     WindUp() {
  47.         angularWindUp = 0.0;
  48.     }

  49.     /** {@inheritDoc}
  50.      * <p>
  51.      * Wind-up effect has no parameters, the returned list is always empty.
  52.      * </p>
  53.      */
  54.     @Override
  55.     public List<ParameterDriver> getParametersDrivers() {
  56.         return Collections.emptyList();
  57.     }

  58.     /** {@inheritDoc} */
  59.     @Override
  60.     public void modify(final EstimatedMeasurement<Phase> estimated) {

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

  64.         // get ground antenna dipole
  65.         final Frame         inertial      = estimated.getStates()[0].getFrame();
  66.         final GroundStation station       = estimated.getObservedMeasurement().getStation();
  67.         final Rotation      offsetToInert = station.getOffsetToInertial(inertial, estimated.getDate()).getRotation();
  68.         final Vector3D      iGround       = offsetToInert.applyTo(Vector3D.PLUS_I);
  69.         final Vector3D      jGround       = offsetToInert.applyTo(Vector3D.PLUS_J);
  70.         final Vector3D      dGround       = new Vector3D(1.0, iGround, -Vector3D.dotProduct(iGround, los), los).
  71.                                             add(Vector3D.crossProduct(los, jGround));

  72.         // get satellite dipole
  73.         // we don't use the basic yaw steering attitude model from ESA navipedia page
  74.         // but rely on the attitude that was computed by the propagator, which takes
  75.         // into account the proper noon and midnight turns for each satellite model
  76.         final Rotation      satToInert    = estimated.getStates()[0].toTransform().getRotation().revert();
  77.         final Vector3D      iSat          = satToInert.applyTo(Vector3D.PLUS_I);
  78.         final Vector3D      jSat          = satToInert.applyTo(Vector3D.PLUS_J);
  79.         final Vector3D      dSat          = new Vector3D(1.0, iSat, -Vector3D.dotProduct(iSat, los), los).
  80.                                             subtract(Vector3D.crossProduct(los, jSat));

  81.         // raw correction
  82.         final double correction = FastMath.copySign(Vector3D.angle(dSat, dGround),
  83.                                                     Vector3D.dotProduct(los, Vector3D.crossProduct(dSat, dGround)));

  84.         // ensure continuity accross measurements
  85.         // we assume the various measurements are close enough in time
  86.         // (less the one satellite half-turn) so the angles remain close
  87.         angularWindUp = MathUtils.normalizeAngle(correction, angularWindUp);

  88.         // update estimate
  89.         estimated.setEstimatedValue(estimated.getEstimatedValue()[0] + angularWindUp / MathUtils.TWO_PI);

  90.     }

  91. }