GPSPropagator.java

  1. /* Copyright 2002-2020 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.orekit.annotation.DefaultDataContext;
  19. import org.orekit.attitudes.AttitudeProvider;
  20. import org.orekit.data.DataContext;
  21. import org.orekit.frames.Frame;
  22. import org.orekit.frames.Frames;
  23. import org.orekit.propagation.Propagator;
  24. import org.orekit.utils.IERSConventions;

  25. /**
  26.  * This class aims at propagating a GPS orbit from {@link GPSOrbitalElements}.
  27.  *
  28.  * @see <a href="http://www.gps.gov/technical/icwg/IS-GPS-200H.pdf">GPS Interface Specification</a>
  29.  * @author Pascal Parraud
  30.  * @since 8.0
  31.  */
  32. public class GPSPropagator extends AbstractGNSSPropagator {

  33.     // Constants
  34.     /** WGS 84 value of the earth's rotation rate in rad/s. */
  35.     private static final double GPS_AV = 7.2921151467e-5;

  36.     /** Duration of the GPS cycle in seconds. */
  37.     private static final double GPS_CYCLE_DURATION = GPSOrbitalElements.GPS_WEEK_IN_SECONDS *
  38.                                                      GPSOrbitalElements.GPS_WEEK_NB;

  39.     // Fields
  40.     /** The GPS orbital elements used. */
  41.     private final GPSOrbitalElements gpsOrbit;

  42.     /**
  43.      * This nested class aims at building a GPSPropagator.
  44.      * <p>It implements the classical builder pattern.</p>
  45.      *
  46.      */
  47.     public static class Builder {

  48.         // Required parameter
  49.         /** The GPS orbital elements. */
  50.         private final GPSOrbitalElements orbit;

  51.         // Optional parameters
  52.         /** The attitude provider. */
  53.         private AttitudeProvider attitudeProvider;
  54.         /** The mass. */
  55.         private double mass = DEFAULT_MASS;
  56.         /** The ECI frame. */
  57.         private Frame eci  = null;
  58.         /** The ECEF frame. */
  59.         private Frame ecef = null;

  60.         /** Initializes the builder.
  61.          * <p>The GPS orbital elements is the only requested parameter to build a GPSPropagator.</p>
  62.          * <p>The attitude provider is set by default to the
  63.          *  {@link org.orekit.propagation.Propagator#DEFAULT_LAW DEFAULT_LAW} in the
  64.          *  default data context.<br>
  65.          * The mass is set by default to the
  66.          *  {@link org.orekit.propagation.Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
  67.          * The ECI frame is set by default to the
  68.          *  {@link org.orekit.frames.Predefined#EME2000 EME2000 frame} in the default data
  69.          *  context.<br>
  70.          * The ECEF frame is set by default to the
  71.          *  {@link org.orekit.frames.Predefined#ITRF_CIO_CONV_2010_SIMPLE_EOP
  72.          *  CIO/2010-based ITRF simple EOP} in the default data context.
  73.          * </p>
  74.          *
  75.          * <p>This constructor uses the {@link DataContext#getDefault() default data context}.
  76.          * Another data context can be set using
  77.          * {@code Builder(final GPSOrbitalElements gpsOrbElt, final Frames frames)}</p>
  78.          *
  79.          * @param gpsOrbElt the GPS orbital elements to be used by the GPSpropagator.
  80.          * @see #attitudeProvider(AttitudeProvider provider)
  81.          * @see #mass(double mass)
  82.          * @see #eci(Frame inertial)
  83.          * @see #ecef(Frame bodyFixed)
  84.          */
  85.         @DefaultDataContext
  86.         public Builder(final GPSOrbitalElements gpsOrbElt) {
  87.             this(gpsOrbElt, DataContext.getDefault().getFrames());
  88.         }

  89.         /** Initializes the builder.
  90.          * <p>The GPS orbital elements is the only requested parameter to build a GPSPropagator.</p>
  91.          * <p>The attitude provider is set by default to the
  92.          *  {@link org.orekit.propagation.Propagator#getDefaultLaw(Frames)}  DEFAULT_LAW}.<br>
  93.          * The mass is set by default to the
  94.          *  {@link org.orekit.propagation.Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
  95.          * The ECI frame is set by default to the
  96.          *  {@link Frames#getEME2000() EME2000 frame}.<br>
  97.          * The ECEF frame is set by default to the
  98.          *  {@link Frames#getITRF(IERSConventions, boolean)} CIO/2010-based ITRF simple EOP}.
  99.          * </p>
  100.          *
  101.          * @param gpsOrbElt the GPS orbital elements to be used by the GPSpropagator.
  102.          * @param frames set of frames to use.
  103.          * @see #attitudeProvider(AttitudeProvider provider)
  104.          * @see #mass(double mass)
  105.          * @see #eci(Frame inertial)
  106.          * @see #ecef(Frame bodyFixed)
  107.          * @since 10.1
  108.          */
  109.         public Builder(final GPSOrbitalElements gpsOrbElt, final Frames frames) {
  110.             this.orbit = gpsOrbElt;
  111.             this.eci   = frames.getEME2000();
  112.             this.ecef  = frames.getITRF(IERSConventions.IERS_2010, true);
  113.             attitudeProvider = Propagator.getDefaultLaw(frames);
  114.         }

  115.         /** Sets the attitude provider.
  116.          *
  117.          * @param userProvider the attitude provider
  118.          * @return the updated builder
  119.          */
  120.         public Builder attitudeProvider(final AttitudeProvider userProvider) {
  121.             this.attitudeProvider = userProvider;
  122.             return this;
  123.         }

  124.         /** Sets the mass.
  125.          *
  126.          * @param userMass the mass (in kg)
  127.          * @return the updated builder
  128.          */
  129.         public Builder mass(final double userMass) {
  130.             this.mass = userMass;
  131.             return this;
  132.         }

  133.         /** Sets the Earth Centered Inertial frame used for propagation.
  134.          *
  135.          * @param inertial the ECI frame
  136.          * @return the updated builder
  137.          */
  138.         public Builder eci(final Frame inertial) {
  139.             this.eci = inertial;
  140.             return this;
  141.         }

  142.         /** Sets the Earth Centered Earth Fixed frame assimilated to the WGS84 ECEF.
  143.          *
  144.          * @param bodyFixed the ECEF frame
  145.          * @return the updated builder
  146.          */
  147.         public Builder ecef(final Frame bodyFixed) {
  148.             this.ecef = bodyFixed;
  149.             return this;
  150.         }

  151.         /** Finalizes the build.
  152.          *
  153.          * @return the built GPSPropagator
  154.          */
  155.         public GPSPropagator build() {
  156.             return new GPSPropagator(this);
  157.         }
  158.     }

  159.     /**
  160.      * Private constructor.
  161.      *
  162.      * @param builder the builder
  163.      */
  164.     private GPSPropagator(final Builder builder) {
  165.         super(builder.orbit, builder.attitudeProvider,
  166.               builder.eci, builder.ecef, builder.mass,
  167.               GPS_AV, GPS_CYCLE_DURATION, GPSOrbitalElements.GPS_MU);
  168.         // Stores the GPS orbital elements
  169.         this.gpsOrbit = builder.orbit;
  170.     }

  171.     /**
  172.      * Gets the underlying GPS orbital elements.
  173.      *
  174.      * @return the underlying GPS orbital elements
  175.      */
  176.     public GPSOrbitalElements getGPSOrbitalElements() {
  177.         return gpsOrbit;
  178.     }

  179. }