GLONASSNavigationMessage.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.data;

  18. import org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator;
  19. import org.hipparchus.util.FastMath;
  20. import org.orekit.annotation.DefaultDataContext;
  21. import org.orekit.attitudes.AttitudeProvider;
  22. import org.orekit.data.DataContext;
  23. import org.orekit.frames.Frame;
  24. import org.orekit.propagation.numerical.GLONASSNumericalPropagator;
  25. import org.orekit.propagation.numerical.GLONASSNumericalPropagatorBuilder;

  26. /**
  27.  * Container for data contained in a Glonass navigation message.
  28.  * @author Bryan Cazabonne
  29.  * @since 11.0
  30.  */
  31. public class GLONASSNavigationMessage extends AbstractEphemerisMessage implements GLONASSOrbitalElements {

  32.     /** Message frame time. */
  33.     private double time;

  34.     /** SV clock bias. */
  35.     private double tauN;

  36.     /** SV relative frequency bias. */
  37.     private double gammaN;

  38.     /** Frequency number. */
  39.     private int frequencyNumber;

  40.     /** Status flags.
  41.      * @since 12.0
  42.      */
  43.     private int statusFlags;

  44.     /** Health flags.
  45.      * @since 12.0
  46.      */
  47.     private int healthFlags;

  48.     /** Group Delay Difference (s).
  49.      * @since 12.0
  50.      */
  51.     private double groupDelayDifference;

  52.     /** User range accuracy (m).
  53.      * @since 12.0
  54.      */
  55.     private double ura;

  56.     /** Constructor. */
  57.     public GLONASSNavigationMessage() {
  58.         // Nothing to do ...
  59.     }

  60.     /**
  61.      * Get the propagator corresponding to the navigation message.
  62.      * <p>The attitude provider is set by default to EME2000 aligned in the
  63.      *  default data context.<br>
  64.      * The mass is set by default to the
  65.      *  {@link org.orekit.propagation.Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
  66.      * The data context is by default to the
  67.      *  {@link DataContext#getDefault() default data context}.<br>
  68.      * The ECI frame is set by default to the
  69.      *  {@link org.orekit.frames.Predefined#EME2000 EME2000 frame} in the default data
  70.      *  context.<br>
  71.      * </p>
  72.      * @param step integration step in seconds
  73.      * @return the propagator corresponding to the navigation message
  74.      * @see #getPropagator(double, DataContext)
  75.      * @see #getPropagator(double, DataContext, AttitudeProvider, Frame, double)
  76.      * @since 12.0
  77.      */
  78.     @DefaultDataContext
  79.     public GLONASSNumericalPropagator getPropagator(final double step) {
  80.         return new GLONASSNumericalPropagatorBuilder(new ClassicalRungeKuttaIntegrator(step),
  81.                                                      this, isAccAvailable()).build();
  82.     }

  83.     /**
  84.      * Get the propagator corresponding to the navigation message.
  85.      * <p>The attitude provider is set by default to EME2000 aligned in the
  86.      *  default data context.<br>
  87.      * The mass is set by default to the
  88.      *  {@link org.orekit.propagation.Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
  89.      * The data context is by default to the
  90.      *  {@link DataContext#getDefault() default data context}.<br>
  91.      * The ECI frame is set by default to the
  92.      *  {@link org.orekit.frames.Predefined#EME2000 EME2000 frame} in the default data
  93.      *  context.<br>
  94.      * </p>
  95.      * @param step integration step in seconds
  96.      * @param context data context
  97.      * @return the propagator corresponding to the navigation message
  98.      * @see #getPropagator(double)
  99.      * @see #getPropagator(double, DataContext, AttitudeProvider, Frame, double)
  100.      * @since 12.0
  101.      */
  102.     public GLONASSNumericalPropagator getPropagator(final double step, final DataContext context) {
  103.         return new GLONASSNumericalPropagatorBuilder(new ClassicalRungeKuttaIntegrator(step),
  104.                                                      this, isAccAvailable(), context).build();
  105.     }

  106.     /**
  107.      * Get the propagator corresponding to the navigation message.
  108.      * @param step integration step in seconds
  109.      * @param context data context
  110.      * @param provider attitude provider
  111.      * @param inertial inertial frame, use to provide the propagated orbit
  112.      * @param mass spacecraft mass in kg
  113.      * @return the propagator corresponding to the navigation message
  114.      * @see #getPropagator(double)
  115.      * @see #getPropagator(double, DataContext)
  116.      * @since 12.0
  117.      */
  118.     public GLONASSNumericalPropagator getPropagator(final double step, final DataContext context,
  119.                                                     final AttitudeProvider provider, final Frame inertial,
  120.                                                     final double mass) {
  121.         return new GLONASSNumericalPropagatorBuilder(new ClassicalRungeKuttaIntegrator(step),
  122.                                                      this, isAccAvailable(), context).attitudeProvider(provider)
  123.                                                                                      .eci(inertial)
  124.                                                                                      .mass(mass)
  125.                                                                                      .build();
  126.     }

  127.     /** {@inheritDoc} */
  128.     @Override
  129.     public double getTN() {
  130.         return tauN;
  131.     }

  132.     /**
  133.      * Setter for the SV clock bias.
  134.      * @param tn the SV clock bias
  135.      */
  136.     public void setTauN(final double tn) {
  137.         this.tauN = tn;
  138.     }

  139.     /** {@inheritDoc} */
  140.     @Override
  141.     public double getGammaN() {
  142.         return gammaN;
  143.     }

  144.     /**
  145.      * Setter for the SV relative frequency bias.
  146.      * @param gammaN the SV relative frequency bias.
  147.      */
  148.     public void setGammaN(final double gammaN) {
  149.         this.gammaN = gammaN;
  150.     }

  151.     /**
  152.      * Getter for the frequency number.
  153.      * @return the frequency number
  154.      */
  155.     public int getFrequencyNumber() {
  156.         return frequencyNumber;
  157.     }

  158.     /**
  159.      * Setter for the frequency number.
  160.      * @param frequencyNumber the number to set
  161.      */
  162.     public void setFrequencyNumber(final double frequencyNumber) {
  163.         this.frequencyNumber = (int) frequencyNumber;
  164.     }

  165.     /** {@inheritDoc} */
  166.     @Override
  167.     public double getTime() {
  168.         return time;
  169.     }

  170.     /**
  171.      * Setter for the message frame time.
  172.      * @param time the time to set
  173.      */
  174.     public void setTime(final double time) {
  175.         this.time = time;
  176.     }

  177.     /** Get status flags.
  178.      * @return status flags
  179.      * @since 12.0
  180.      */
  181.     public int getStatusFlags() {
  182.         return statusFlags;
  183.     }

  184.     /** Set status flag.
  185.      * @param statusFlags status flag (parsed as a double)
  186.      * @since 12.0
  187.      */
  188.     public void setStatusFlags(final double statusFlags) {
  189.         this.statusFlags = (int) FastMath.rint(statusFlags);
  190.     }

  191.     /** Set health flag.
  192.      * @param healthFlags health flag (parsed as a double)
  193.      * @since 12.0
  194.      */
  195.     public void setHealthFlags(final double healthFlags) {
  196.         this.healthFlags = Double.isNaN(healthFlags) ? 15 : (int) FastMath.rint(healthFlags);
  197.     }

  198.     /** Get health flags.
  199.      * @return health flags
  200.      * @since 12.0
  201.      */
  202.     public int getHealthFlags() {
  203.         return healthFlags;
  204.     }

  205.     /** Get group delay difference.
  206.      * @return group delay difference
  207.      * @since 12.0
  208.      */
  209.     public double getGroupDelayDifference() {
  210.         return groupDelayDifference;
  211.     }

  212.     /** Set group delay difference.
  213.      * @param groupDelayDifference group delay difference
  214.      * @since 12.0
  215.      */
  216.     public void setGroupDelayDifference(final double groupDelayDifference) {
  217.         this.groupDelayDifference = Double.isNaN(groupDelayDifference) ?
  218.                                     0.999999999999e+09 :
  219.                                     groupDelayDifference;
  220.     }

  221.     /**
  222.      * Getter for the user range accuray (meters).
  223.      * @return the user range accuracy
  224.      * @since 12.0
  225.      */
  226.     public double getURA() {
  227.         return ura;
  228.     }

  229.     /**
  230.      * Setter for the user range accuracy.
  231.      * @param accuracy the value to set
  232.      * @since 12.0
  233.      */
  234.     public void setURA(final double accuracy) {
  235.         this.ura = accuracy;
  236.     }

  237.     /**
  238.      * Check if the acceleration is available in the navigation message.
  239.      * @return true if the acceleration is available
  240.      */
  241.     private boolean isAccAvailable() {
  242.         return getXDotDot() != 0.0 || getYDotDot() != 0.0 || getZDotDot() != 0.0;
  243.     }

  244. }