SBASPropagator.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.propagation.analytical.gnss;

  18. import org.hipparchus.analysis.differentiation.UnivariateDerivative2;
  19. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  20. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  21. import org.orekit.attitudes.Attitude;
  22. import org.orekit.attitudes.AttitudeProvider;
  23. import org.orekit.errors.OrekitException;
  24. import org.orekit.errors.OrekitMessages;
  25. import org.orekit.frames.Frame;
  26. import org.orekit.orbits.CartesianOrbit;
  27. import org.orekit.orbits.Orbit;
  28. import org.orekit.propagation.SpacecraftState;
  29. import org.orekit.propagation.analytical.AbstractAnalyticalPropagator;
  30. import org.orekit.propagation.analytical.gnss.data.SBASOrbitalElements;
  31. import org.orekit.time.AbsoluteDate;
  32. import org.orekit.utils.PVCoordinates;

  33. /**
  34.  * This class aims at propagating a SBAS orbit from {@link SBASOrbitalElements}.
  35.  *
  36.  * @see "Tyler Reid, Todd Walker, Per Enge, L1/L5 SBAS MOPS Ephemeris Message to
  37.  *       Support Multiple Orbit Classes, ION ITM, 2013"
  38.  *
  39.  * @author Bryan Cazabonne
  40.  * @since 10.1
  41.  *
  42.  */
  43. public class SBASPropagator extends AbstractAnalyticalPropagator {

  44.     /** The SBAS orbital elements used. */
  45.     private final SBASOrbitalElements sbasOrbit;

  46.     /** The spacecraft mass (kg). */
  47.     private final double mass;

  48.     /** The Earth gravity coefficient used for SBAS propagation. */
  49.     private final double mu;

  50.     /** The ECI frame used for SBAS propagation. */
  51.     private final Frame eci;

  52.     /** The ECEF frame used for SBAS propagation. */
  53.     private final Frame ecef;

  54.     /**
  55.      * Private constructor.
  56.      * @param sbasOrbit Glonass orbital elements
  57.      * @param eci Earth Centered Inertial frame
  58.      * @param ecef Earth Centered Earth Fixed frame
  59.      * @param provider Attitude provider
  60.      * @param mass Satellite mass (kg)
  61.      * @param mu Earth's gravity coefficient used for SBAS propagation
  62.      */
  63.     SBASPropagator(final SBASOrbitalElements sbasOrbit, final Frame eci,
  64.                    final Frame ecef, final AttitudeProvider provider,
  65.                    final double mass, final double mu) {
  66.         super(provider);
  67.         // Stores the SBAS orbital elements
  68.         this.sbasOrbit = sbasOrbit;
  69.         // Sets the start date as the date of the orbital elements
  70.         setStartDate(sbasOrbit.getDate());
  71.         // Sets the mu
  72.         this.mu = mu;
  73.         // Sets the mass
  74.         this.mass = mass;
  75.         // Sets the Earth Centered Inertial frame
  76.         this.eci  = eci;
  77.         // Sets the Earth Centered Earth Fixed frame
  78.         this.ecef = ecef;
  79.         // Sets initial state
  80.         final Orbit orbit = propagateOrbit(getStartDate());
  81.         final Attitude attitude = provider.getAttitude(orbit, orbit.getDate(), orbit.getFrame());
  82.         super.resetInitialState(new SpacecraftState(orbit, attitude).withMass(mass));
  83.     }

  84.     /**
  85.      * Gets the PVCoordinates of the GNSS SV in {@link #getECEF() ECEF frame}.
  86.      *
  87.      * <p>The algorithm uses automatic differentiation to compute velocity and
  88.      * acceleration.</p>
  89.      *
  90.      * @param date the computation date
  91.      * @return the GNSS SV PVCoordinates in {@link #getECEF() ECEF frame}
  92.      */
  93.     public PVCoordinates propagateInEcef(final AbsoluteDate date) {
  94.         // Duration from SBAS ephemeris Reference date
  95.         final UnivariateDerivative2 dt = new UnivariateDerivative2(getDT(date), 1.0, 0.0);
  96.         // Satellite coordinates
  97.         final UnivariateDerivative2 x = dt.multiply(dt.multiply(0.5 * sbasOrbit.getXDotDot()).add(sbasOrbit.getXDot())).add(sbasOrbit.getX());
  98.         final UnivariateDerivative2 y = dt.multiply(dt.multiply(0.5 * sbasOrbit.getYDotDot()).add(sbasOrbit.getYDot())).add(sbasOrbit.getY());
  99.         final UnivariateDerivative2 z = dt.multiply(dt.multiply(0.5 * sbasOrbit.getZDotDot()).add(sbasOrbit.getZDot())).add(sbasOrbit.getZ());
  100.         // Returns the Earth-fixed coordinates
  101.         final FieldVector3D<UnivariateDerivative2> positionwithDerivatives =
  102.                         new FieldVector3D<>(x, y, z);
  103.         return new PVCoordinates(new Vector3D(positionwithDerivatives.getX().getValue(),
  104.                                               positionwithDerivatives.getY().getValue(),
  105.                                               positionwithDerivatives.getZ().getValue()),
  106.                                  new Vector3D(positionwithDerivatives.getX().getFirstDerivative(),
  107.                                               positionwithDerivatives.getY().getFirstDerivative(),
  108.                                               positionwithDerivatives.getZ().getFirstDerivative()),
  109.                                  new Vector3D(positionwithDerivatives.getX().getSecondDerivative(),
  110.                                               positionwithDerivatives.getY().getSecondDerivative(),
  111.                                               positionwithDerivatives.getZ().getSecondDerivative()));
  112.     }

  113.     /** {@inheritDoc} */
  114.     public Orbit propagateOrbit(final AbsoluteDate date) {
  115.         // Gets the PVCoordinates in ECEF frame
  116.         final PVCoordinates pvaInECEF = propagateInEcef(date);
  117.         // Transforms the PVCoordinates to ECI frame
  118.         final PVCoordinates pvaInECI = ecef.getTransformTo(eci, date).transformPVCoordinates(pvaInECEF);
  119.         // Returns the Cartesian orbit
  120.         return new CartesianOrbit(pvaInECI, eci, date, mu);
  121.     }

  122.     /**
  123.      * Get the Earth gravity coefficient used for SBAS propagation.
  124.      * @return the Earth gravity coefficient.
  125.      */
  126.     public double getMU() {
  127.         return mu;
  128.     }

  129.     /**
  130.      * Gets the Earth Centered Inertial frame used to propagate the orbit.
  131.      *
  132.      * @return the ECI frame
  133.      */
  134.     public Frame getECI() {
  135.         return eci;
  136.     }

  137.     /**
  138.      * Gets the Earth Centered Earth Fixed frame used to propagate GNSS orbits.
  139.      *
  140.      * @return the ECEF frame
  141.      */
  142.     public Frame getECEF() {
  143.         return ecef;
  144.     }

  145.     /**
  146.      * Get the underlying SBAS orbital elements.
  147.      *
  148.      * @return the underlying SBAS orbital elements
  149.      */
  150.     public SBASOrbitalElements getSBASOrbitalElements() {
  151.         return sbasOrbit;
  152.     }

  153.     /** {@inheritDoc} */
  154.     public Frame getFrame() {
  155.         return eci;
  156.     }

  157.     /** {@inheritDoc} */
  158.     public void resetInitialState(final SpacecraftState state) {
  159.         throw new OrekitException(OrekitMessages.NON_RESETABLE_STATE);
  160.     }

  161.     /** {@inheritDoc} */
  162.     protected double getMass(final AbsoluteDate date) {
  163.         return mass;
  164.     }

  165.     /** {@inheritDoc} */
  166.     protected void resetIntermediateState(final SpacecraftState state, final boolean forward) {
  167.         throw new OrekitException(OrekitMessages.NON_RESETABLE_STATE);
  168.     }

  169.     /** Get the duration from SBAS Reference epoch.
  170.      * @param date the considered date
  171.      * @return the duration from SBAS orbit Reference epoch (s)
  172.      */
  173.     private double getDT(final AbsoluteDate date) {
  174.         // Time from ephemeris reference epoch
  175.         return date.durationFrom(sbasOrbit.getDate());
  176.     }

  177. }